Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

FinanceToolkit

> 数据库
Open source

Transparent and Efficient Financial Analysis

5.2K stars0 likes2 views
WebsiteGitHub

About

Transparent and Efficient Financial Analysis

While browsing a variety of websites, I repeatedly observed significant fluctuations in the same financial metric among different sources. Similarly, the reported financial statements often didn't line up, and there was limited information on the methodology used to calculate each metric.

For example, Microsoft's Price-to-Earnings (PE) ratio on the 6th of May, 2023 is reported to be 28.93 (Stockopedia), 32.05 (Morningstar), 32.66 (Macrotrends), 33.09 (Finance Charts), 33.66 (Y Charts), 33.67 (Wall Street Journal), 33.80 (Yahoo Finance) and 34.4 (Companies Market Cap). All of these calculations are correct, however the method of calculation varies leading to different results. Therefore, collecting data from multiple sources can lead to wrong interpretation of the results given that one source could apply a different definition than another. And that is, if that definition is even available as often the underlying methods are hidden behind a paid subscription.

This is why I designed the FinanceToolkit, this is an open-source toolkit in which all relevant financial methods (500+) are written down in the most simplistic way allowing for complete transparency of the method of calculation (proof). This enables you to avoid dependence on metrics from other providers that do not provide their methods. With a large selection of financial statements in hand, it facilitates streamlined calculations, promoting the adoption of a consistent and universally understood methods and formulas.

Beyond Equities, it supports Options, Currencies, Cryptocurrencies, ETFs, Mutual Funds, Indices, Money Markets, Commodities, Key Economic Indicators and more, allowing you to obtain historical data as well as important performance and risk measurements such as the Sharpe Ratio and Value at Risk.

Complementing this is the Finance Database , a database featuring 300.000+ symbols containing Equities, ETFs, Funds, Indices, Currencies, Cryptocurrencies and Money Markets. By utilising both, it is possible to do a fully-fledged competitive analysis with the tickers found from the FinanceDatabase inputted into the FinanceToolkit.


** The Finance Toolkit is also available as an MCP Server**

Query 500+ methods from Claude, Copilot, Cursor, Windsurf or any MCP-compatible client without writing code.

  • Hosted: connect to https://financetoolkit.jeroenbouma.com/mcp — OAuth handles the rest on first use.
  • Local: uvx --from "financetoolkit[mcp]" financetoolkit-mcp-setup — sets up your client config and API key automatically. See MCP Server Documentation for manual setup.

Also on Smithery, Glama, MCP Servers and more.


Table of Contents

  1. Installation
  2. Functionality
  3. MCP Server
  4. Questions & Answers
  5. Contributing
  6. Mentions
  7. Contact

Installation

Before installation, consider starring the project on GitHub which helps others find the project as well.

To install the Finance Toolkit it simply requires the following:

bash
pip install financetoolkit -U

Then within Python use:

python
from financetoolkit import Toolkit

companies = Toolkit(
    tickers=['AAPL', 'MSFT'],
    api_key="FINANCIAL_MODELING_PREP_KEY",  # replace with your actual API key
)

To be able to get started, you need to obtain an API Key from FinancialModelingPrep. This is used to gain access to 30+ years of financial statement both annually and quarterly. Note that the Free plan is limited to 250 requests each day, 5 years of data and only features companies listed on US exchanges.


___

Through the link you are able to subscribe for the free plan and also premium plans at a 15% discount. This is an affiliate link and thus supports the project at the same time. I have chosen FinancialModelingPrep as a source as I find it to be the most transparent, reliable and at an affordable price. I have yet to find a platform offering such low prices for the amount of data offered. When you notice that the data is inaccurate or have any other issue related to the data, note that I simply provide the means to access this data and I am not responsible for the accuracy of the data itself. For this, use their contact form or provide the data yourself.

By default, the Finance Toolkit prioritizes Financial Modeling Prep for data retrieval. If data acquisition from Financial Modeling Prep is unsuccessful (e.g., due to plan restrictions or API key issues), the toolkit automatically switches to Yahoo Finance as a secondary source. To disable this fallback behavior and exclusively use Financial Modeling Prep, set enforce_source="FinancialModelingPrep" during Toolkit initialization. This configuration ensures that an error is raised if Financial Modeling Prep data cannot be accessed. Alternatively, you can set enforce_source="YahooFinance" to exclusively use Yahoo Finance as the data source.

The same enforce_source argument is also accepted per call on get_historical_data, get_treasury_data and the four statement functions (get_balance_sheet_statement, get_income_statement, get_cash_flow_statement and get_statistics_statement), where it overrides whatever the Toolkit was initialised with.

Functionality

This section is an introduction to the Finance Toolkit. Find with the link below fully-fledged code documentation as well as Jupyter Notebooks in which you can see many examples ranging from basic examples to creating custom ratios to working with your own datasets.


___

A basic example of how to use the Finance Toolkit is shown below. Every code snippet in the sections that follow builds on this same companies instance.

python
from financetoolkit import Toolkit

# Initialize the Toolkit for Apple and Microsoft
companies = Toolkit(["AAPL", "MSFT"], api_key=API_KEY, start_date="2017-12-31")

Each ratio, indicator and metric has a corresponding function that can be called directly, for example ratios.get_return_on_equity or technicals.get_relative_strength_index. Every module also has one or more collect_ functions that return a whole category at once, e.g. ratios.collect_profitability_ratios, useful when you want everything in one call instead of assembling it metric by metric.

Three capabilities cut across nearly the whole toolkit:

  • rolling and trailing windows. Many metrics return one value per reporting period by default. Pass rolling=<n> to compute the metric over a sliding window instead, or trailing=<n> for a trailing sum/average (e.g. a trailing 4-quarter sum to annualize a quarterly flow) — turning a snapshot into a proper time series.
  • growth and lag. Pass growth=True on almost any get_ or collect_ function to return the period-over-period growth instead of the raw value. lag (an int or list of ints, default 1) controls how many periods back that growth is measured against, e.g. lag=4 for year-over-year growth on quarterly data. Combine with trailing (e.g. trailing=4, growth=True) to get TTM growth.
  • standardize (Z-Score). Most get_* methods across Economics, Ratios, Technicals, Risk, Performance, Models, Options and Fixed Income accept standardize=True, converting raw values into standard deviations from their own historical mean/std. Useful for ranking, scoring, or spotting an unusual reading across metrics that otherwise live on incompatible scales.

Every module below also has a How-To Guide notebook and full code documentation (formulas, parameters, worked examples) linked in its own section, see the documentation hub for the complete index.

Discovering Instruments & News

Before analyzing a ticker you often need to find it. The Discovery module is standalone and covers among other things lists of companies, cryptocurrencies, forex, commodities, ETFs and indices.

python
from financetoolkit import Discovery

# Initialize the standalone Discovery module
discovery = Discovery(api_key="FINANCIAL_MODELING_PREP_KEY")

# Screen for stocks matching a set of criteria
discovery.get_stock_screener(
    market_cap_higher=1000000,
    price_higher=100,
    price_lower=200,
    beta_higher=1,
    beta_lower=1.5,
    dividend_higher=1,
)

Which returns:

Symbol Name Market Cap Sector Industry Beta Price Dividend Exchange Country
NKE NIKE, Inc. 163403295604 Consumer Cyclical Footwear & Accessories 1.079 107.36 1.48 New York Stock Exchange US
SAF.PA Safran SA 66234006559 Industrials Aerospace & Defense 1.339 160.16 1.35 Paris FR
ROST Ross Stores, Inc. 46724188589 Consumer Cyclical Apparel Retail 1.026 138.785 1.34 NASDAQ Global Select US

Furthermore, you can find in this module stock screeners, sector/industry performance and news feeds and more. Find the Notebook here and the full instrument discovery documentation here.

Obtaining Historical Data

Obtain historical data on a daily, weekly, monthly or yearly basis. This includes OHLC, volumes, dividends, returns and cumulative returns for each corresponding period.

python
# Obtain historical market data for all tickers
historical_data = companies.get_historical_data()

# Select the results for Apple
historical_data.xs('AAPL', axis=1, level=1)

For example, a portion of the historical data for Apple is shown below.

date Open High Low Close Adj Close Volume Dividends Return Cumulative Return
2018-01-02 42.54 43.075 42.315 43.065 40.78 1.02224e+08 0 0 1
2018-01-03 43.1325 43.6375 42.99 43.0575 40.77 1.17982e+08 0 -0.0002 0.9998
2018-01-04 43.135 43.3675 43.02 43.2575 40.96 8.97384e+07 0 0.0047 1.0044
2018-01-05 43.36 43.8425 43.2625 43.75 41.43 9.46401e+07 0 0.0115 1.0159
2018-01-08 43.5875 43.9025 43.4825 43.5875 41.27 8.22711e+07 0 -0.0039 1.012

And below the cumulative returns are plotted which include the S&P 500 as benchmark:

Metrics

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythonalgorithmic-tradingequitiesfactor-analysisfinance

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库