<!-- mcp-name: io.github.JerBouma/financetoolkit --> 
          
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 ratios (200+), indicators and performance measurements 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 200+ metrics 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
- Installation
- Basic Usage
- Functionality and Metrics
- MCP Server
- Questions & Answers
- Contributing
- Mentions
- Contact
Installation
Before installation, consider starring the project on GitHub which helps others find the project as well.
<a href="https://github.com/JerBouma/FinanceToolkit" target="_blank"><img width="1415" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/014109fe-0c68-47d4-99bd-217c69dcea8d"></a>
To install the Finance Toolkit it simply requires the following:
pip install financetoolkit -U
Then within Python use:
from financetoolkit import Toolkit
companies = Toolkit(
tickers=['GOOGL', 'MSFT', 'AMZN'],
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.
___
<b><div align="center">Obtain an API Key from FinancialModelingPrep <a href="https://www.jeroenbouma.com/fmp" target="_blank">here</a>.</div></b> ___
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.
Basic Usage
This section is an introduction to the Finance Toolkit. Also see this notebook for a detailed Getting Started guide as well as this notebook that includes the Finance Database 🌎 and a proper financial analysis. Next to that, find below a 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.
___
<b><div align="center">Find a variety of How-To Guides including Code Documentation for the FinanceToolkit <a href="https://www.jeroenbouma.com/projects/financetoolkit">here</a>.</div></b> ___
A basic example of how to use the Finance Toolkit is shown below.
from financetoolkit import Toolkit
companies = Toolkit(["AAPL", "MSFT"], api_key=API_KEY, start_date="2017-12-31")
# a Historical example
historical_data = companies.get_historical_data()
# a Financial Statement example
income_statement = companies.get_income_statement()
# a Ratios example
profitability_ratios = companies.ratios.collect_profitability_ratios()
# a Models example
extended_dupont_analysis = companies.models.get_extended_dupont_analysis()
# an Options example
all_greeks = companies.options.collect_all_greeks(expiration_time_range=180)
# a Performance example
factor_asset_correlations = companies.performance.get_factor_asset_correlations(
period="quarterly"
)
# a Risk example
value_at_risk = companies.risk.get_value_at_risk(period="weekly")
# a Technical example
ichimoku_cloud = companies.technicals.get_ichimoku_cloud()
# a Fixed Income example
corporate_bond_yields = companies.fixedincome.get_ice_bofa_effective_yield()
# an Economics example
unemployment_rates = companies.economics.get_unemployment_rate()
Generally, the functions return a DataFrame with a multi-index in which all tickers, in this case Apple and Microsoft, are presented. To keep things manageable for this README, I select just Apple but in essence the list of tickers can be endless as I've seen DataFrames with thousands of tickers. The filtering is done through .loc['AAPL'] and .xs('AAPL', level=1, axis=1) based on whether it's fundamental data or historical data respectively.
Obtaining Historical Data
Obtain historical data on a daily, weekly, monthly or yearly basis. This includes OHLC, volumes, dividends, returns, cumulative returns and volatility calculations for each corresponding period. For example, the a portion of the historical data for Apple is shown below.
| date | Open | High | Low | Close | Adj Close | Volume | Dividends | Return | Volatility | Excess Return | Excess Volatility | Cumulative Return | |:-----------|--------:|--------:|--------:|--------:|------------:|------------:|------------:|---------:|-------------:|----------------:|--------------------:|--------------------:| | 2018-01-02 | 42.54 | 43.075 | 42.315 | 43.065 | 40.78 | 1.02224e+08 | 0 | 0 | 0.0202 | -0.0067 | 0.0233 | 1 | | 2018-01-03 | 43.1325 | 43.6375 | 42.99 | 43.0575 | 40.77 | 1.17982e+08 | 0 | -0.0002 | 0.0202 | -0.0247 | 0.0233 | 0.9998 | | 2018-01-04 | 43.135 | 43.3675 | 43.02 | 43.2575 | 40.96 | 8.97384e+07 | 0 | 0.0047 | 0.0202 | -0.0198 | 0.0233 | 1.0044 | | 2018-01-05 | 43.36 | 43.8425 | 43.2625 | 43.75 | 41.43 | 9.46401e+07 | 0 | 0.0115 | 0.0202 | -0.0133 | 0.0233 | 1.0159 | | 2018-01-08 | 43.5875 | 43.9025 | 43.4825 | 43.5875 | 41.27 | 8.22711e+07 | 0 | -0.0039 | 0.0202 | -0.0287 | 0.0233 | 1.012 |
And below the cumulative returns are plotted which include the S&P 500 as benchmark:
Obtaining Financial Statements
Obtain an Income Statement on an annual or quarterly basis. This can also be a balance statement (companies.get_balance_sheet_statement()) or cash flow statement (companies.get_cash_flow_statement()). For example, the first 5 rows of the Income Statement for Apple are shown below.
| | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | |:----------------------------------|------------:|------------:|------------:|------------:|------------:|------------:|------------:| | Revenue | 2.29234e+11 | 2.65595e+11 | 2.60174e+11 | 2.74515e+11 | 3.65817e+11 | 3.94328e+11 | 3.83285e+11 | | Cost of Goods Sold | 1.41048e+11 | 1.63756e+11 | 1.61782e+11 | 1.69559e+11 | 2.12981e+11 | 2.23546e+11 | 2.14137e+11 | | Gross Profit | 8.8186e+10 | 1.01839e+11 | 9.8392e+10 | 1.04956e+11 | 1.52836e+11 | 1.70782e+11 | 1.69148e+11 | | Gross Profit Ratio | 0.3847 | 0.3834 | 0.3782 | 0.3823 | 0.4178 | 0.4331 | 0.4413 | | Research and Development Expenses | 1.1581e+10 | 1.4236e+10 | 1.6217e+10 | 1.8752e+10 | 2.1914e+10 | 2.6251e+10 | 2.9915e+10 |
And below the Earnings Before Interest, Taxes, Depreciation and Amortization (EBITDA) are plotted for both Apple and Microsoft.
Obtaining Financial Ratios
Get Profitability Ratios based on the inputted balance sheet, income and cash flow statements. This can be any of the 50+ ratios within the ratios module. The get_ functions show a single ratio whereas the collect_ functions show an aggregation of multiple ratios. For example, see some of the profitability ratios of Microsoft below.
| | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | |:--------------------------------|--------:|--------:|--------:|--------:|--------:|--------:|--------:| | Gross Margin | 0.6191 | 0.6525 | 0.659 | 0.6778 | 0.6893 | 0.684 | 0.6892 | | Operating Margin | 0.2482 | 0.3177 | 0.3414 | 0.3703 | 0.4159 | 0.4206 | 0.4177 | | Net Profit Margin | 0.2357 | 0.1502 | 0.3118 | 0.3096 | 0.3645 | 0.3669 | 0.3415 | | Interest Coverage Ratio | 13.9982 | 16.5821 | 20.3429 | 25.3782 | 34.7835 | 47.4275 | 52.0244 | | Income Before Tax Profit Margin | 0.2574 | 0.3305 | 0.3472 | 0.3708 | 0.423 | 0.4222 | 0.4214 |
And below a few of the profitability ratios are plotted for Microsoft.
Obtaining Financial Models
Get an Extended DuPont Analysis based on the inputted balance sheet, income and cash flow statements. This can also be an Enterprise Value Breakdown, Weighted Average Cost of Capital (WACC), Altman Z-Score and many more models. For example, this shows the Extended DuPont Analysis for Apple:
| | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | |:------------------------|---------:|-------:|-------:|-------:|-------:|-------:|-------:| | Interest Burden Ratio | 0.9572 | 0.9725 | 0.9725 | 0.988 | 0.9976 | 1.0028 | 1.005 | | Tax Burden Ratio | 0.7882 | 0.8397 | 0.8643 | 0.8661 | 0.869 | 0.8356 | 0.8486 | | Operating Profit Margin | 0.2796 | 0.2745 | 0.2527 | 0.2444 | 0.2985 | 0.302 | 0.2967 | | Asset Turnover | nan | 0.7168 | 0.7389 | 0.8288 | 1.0841 | 1.1206 | 1.0868 | | Equity Multiplier | nan | 3.0724 | 3.5633 | 4.2509 | 5.255 | 6.1862 | 6.252 | | Return on Equity | nan | 0.4936 | 0.5592 | 0.7369 | 1.4744 | 1.7546 | 1.7195 |
And below each component of the Extended Dupont Analysis is plotted including the resulting Return on Equity (ROE).
Obtaining Options and Greeks
Get the Black Scholes Model for both call and put options including the relevant Greeks, in this case Delta, Gamma, Theta and Vega. This can be any of the First, Second or Third Order Greeks as found in the the options module. The get_ functions show a single Greek whereas the collect_ functions show an aggregation of Greeks. For example, see the delta of the Call options for Apple for multiple expiration times and strike prices below (Stock Price: 185.92, Volatility: 31.59%, Dividend Yield: 0.49% and Risk Free Rate: 3.95%):
| | 1 Month | 2 Months | 3 Months | 4 Months | 5 Months | 6 Months | |----:|----------:|-----------:|-----------:|-----------:|-----------:|-----------:| | 175 | 0.7686 | 0.7178 | 0.6967 | 0.6857 | 0.6794 | 0.6759 | | 180 | 0.6659 | 0.64 | 0.6318 | 0.629 | 0.6285 | 0.6291 | | 185 | 0.5522 | 0.5583 | 0.5648 | 0.571 | 0.5767 | 0.5816 | | 190 | 0.4371 | 0.4762 | 0.4977 | 0.513 | 0.5249 | 0.5342 | | 195 | 0.3298 | 0.3971 | 0.4324 | 0.4562 | 0.474 | 0.4875 |
Which can also be plotted together with Gamma, Theta and Vega as follows:
Obtaining Performance Metrics
Get the correlations with the factors as defined by Fama-and-French. These include market, size, value, operating profitability and investment. The beauty of all functionality here is that it can be based on any period as the function accepts the period intraday, weekly, monthly, quarterly and yearly. For example, this shows the quarterly correlations for Apple:
| | Mkt-RF | SMB | HML | RMW | CMA | |:-------|---------:|--------:|--------:|--------:|--------:| | 2022Q2 | 0.9177 | -0.1248 | -0.5077 | -0.3202 | -0.2624 | | 2022Q3 | 0.8092 | 0.1528 | -0.5046 | -0.1997 | -0.5231 | | 2022Q4 | 0.8998 | 0.2309 | -0.5968 | -0.1868 | -0.5946 | | 2023Q1 | 0.7737 | 0.1606 | -0.3775 | -0.228 | -0.5707 | | 2023Q2 | 0.7416 | -0.1166 | -0.2722 | 0.0093 | -0.4745 |
And below the correlations with each factor are plotted over time for both Apple and Microsoft.
Obtaining Risk Metrics
Get the Value at Risk for each week. Here, the days within each week are considered for the Value at Risk. This makes it so that you can understand within each period what is the expected Value at Risk (VaR) which can again be any period but also based on distributions such as Historical, Gaussian, Student-t, Cornish-Fisher.
| | AAPL | MSFT | Benchmark | |:----------------------|--------:|--------:|------------:| | 2023-09-25/2023-10-01 | -0.0205 | -0.0133 | -0.0122 | | 2023-10-02/2023-10-08 | -0.0048 | -0.0206 | -0.0108 | | 2023-10-09/2023-10-15 | -0.0089 | -0.0092 | -0.0059 | | 2023-10-16/2023-10-22 | -0.0135 | -0.0124 | -0.0131 | | 2023-10-23/2023-10-29 | -0.0224 | -0.0293 | -0.0139 |
And below the Value at Risk (VaR) for Apple, Microsoft and the benchmark (S&P 500) are plotted also demonstrating the impact of COVID-19.
!Risk
Obtaining Technical Indicators
Get the Ichimoku Cloud parameters based on the historical market data. This can be any of the 30+ technical indicators within the technicals module. The get_ functions show a single indicator whereas the collect_ functions show an aggregation of multiple indicators. For example, see some of the parameters for Apple below:
| Date | Base Line | Conversion Line | Leading Span A | Leading Span B | |:-----------|------------:|------------------:|-----------------:|-----------------:| | 2023-10-30 | 174.005 | 171.755 | 176.245 | 178.8 | | 2023-10-31 | 174.005 | 171.755 | 176.37 | 178.8 | | 2023-11-01 | 174.005 | 170.545 | 176.775 | 178.8 | | 2023-11-02 | 174.005 | 171.725 | 176.235 | 178.8 | | 2023-11-03 | 174.005 | 171.725 | 175.558 | 178.8 |
And below the Ichimoku Cloud parameters are plotted for Apple and Microsoft side-by-side.
Obtaining Fixed Income Metrics
Get access to the ICE BofA Corporate Bond benchmark indices and a variety of other bond and derivative related valuations within the fixedincome module. For example, see the Effective Yield for the ICE BofA Corporate Bond Index below for each Credit Rating:
| Date | AAA | AA | A | BBB | BB | B | CCC | |:-----------|-------:|-------:|-------:|-------:|-------:|-------:|-------:| | 2024-04-19 | 0.0518 | 0.0532 | 0.0561 | 0.0594 | 0.0678 | 0.0804 | 0.1385 | | 2024-04-22 | 0.0517 | 0.0532 | 0.056 | 0.0593 | 0.0671 | 0.0793 | 0.1377 | | 2024-04-23 | 0.0514 | 0.0528 | 0.0556 | 0.0589 | 0.066 | 0.0777 | 0.1364 | | 2024-04-24 | 0.0518 | 0.0531 | 0.0559 | 0.0592 | 0.0664 | 0.0778 | 0.1361 | | 2024-04-25 | 0.0524 | 0.0537 | 0.0564 | 0.0598 | 0.0673 | 0.079 | 0.1368 |
And below a variety of Fixed Income metrics are shown all acquired from the Fixed Income module.
Understanding Key Economic Indicators
Get insights for 60+ countries into key economic indicators such as the Consumer Price Index (CPI), Gross Domestic Product (GDP), Unemployment Rates and 3-month and 10-year Government Interest Rates. This is done through the economics module and can be used as a standalone module as well by using from financetoolkit import Economics. For example see a selection of the countries below:
| | Colombia | United States | Sweden | Japan | Germany | |:-----|-----------:|----------------:|---------:|--------:|----------:| | 2017 | 0.093 | 0.0435 | 0.0686 | 0.0281 | 0.0357 | | 2018 | 0.0953 | 0.039 | 0.0648 | 0.0244 | 0.0321 | | 2019 | 0.1037 | 0.0367 | 0.0691 | 0.0235 | 0.0298 | | 2020 | 0.1586 | 0.0809 | 0.0848 | 0.0278 | 0.0362 | | 2021 | 0.1381 | 0.0537 | 0.0889 | 0.0282 | 0.0358 | | 2022 | 0.1122 | 0.0365 | 0.0748 | 0.026 | 0.0307 |
And below these Unemployment Rates are plotted over time:
Explore your own Portfolio
Through a custom XLSX, XLS or CSV file you are able to load in your own portfolio directly into the Finance Toolkit. This allows you to view your positions and performance (over time) versus a benchmark and other positions as well as your PnL development over time. Furthermore, the portfolio can be directly loaded in the core functionality of the Finance Toolkit as well making it possible to calculate all metrics and ratios for your portfolio (which is a time-weighted sum of all positions). The portfolio module is a standalone module and can be used as such by using from financetoolkit import Portfolio.
___ <b><div align="center">It is important to note that it requires a specific Excel template to work, see for further instructions the following notebook <a href="https://www.jeroenbouma.com/projects/financetoolkit/portfolio-notebook" target="_blank">here</a>.</div></b> ___
The table below shows one of the functionalities of the Portfolio module but is purposely shrunken down given the >30 assets.
| Identifier | Volume | Costs | Price | Invested | Latest Price | Latest Value | Return | Return Value | Benchmark Return | Volatility | Benchmark Volatility | Alpha | Beta | Weight | |:-------------|---------:|--------:|---------:|-----------:|---------------:|---------------:|---------:|---------------:|-------------------:|-------------:|-----------------------:|--------:|-------:|---------:| | AAPL | 137 | -28 | 38.9692 | 5310.78 | 241.84 | 33132.1 | 5.2386 | 27821.3 | 2.2258 | 0.3858 | 0.1937 | 3.0128 | 1.2027 | 0.0405 | | ALGN | 81 | -34 | 117.365 | 9472.53 | 187.03 | 15149.4 | 0.5993 | 5676.9 | 2.1413 | 0.5985 | 0.1937 | -1.542 | 1.5501 | 0.0185 | | AMD | 78 | -30 | 11.9075 | 898.784 | 99.86 | 7789.08 | 7.6662 | 6890.3 | 3.7945 | 0.6159 | 0.1937 | 3.8718 | 1.6551 | 0.0095 | | AMZN | 116 | -28 | 41.5471 | 4791.46 | 212.28 | 24624.5 | 4.1392 | 19833 | 1.8274 | 0.4921 | 0.1937 | 2.3118 | 1.1594 | 0.0301 | | ASML | 129 | -25 | 33.3184 | 4273.07 | 709.08 | 91471.3 | 20.4065 | 87198.3 | 3.8005 | 0.4524 | 0.1937 | 16.606 | 1.4407 | 0.1119 | | VOO | 77 | -12 | 238.499 | 18352.5 | 546.33 | 42067.4 | 1.2922 | 23715 | 1.1179 | 0.1699 | 0.1937 | 0.1743 | 0.9973 | 0.0515 | | WMT | 92 | -18 | 17.8645 | 1625.53 | 98.61 | 9072.12 | 4.581 | 7446.59 | 2.4787 | 0.2334 | 0.1937 | 2.1024 | 0.4948 | 0.0111 | | Portfolio | 2142 | -532 | 59.8406 | 128710 | 381.689 | 817577 | 5.3521 | 688867 | 2.0773 | 0.4193 | 0.1937 | 3.2747 | 1.2909 | 1 |
In which the weights and returns can be depicted as follows:
Core Functionality and Metrics
The Finance Toolkit has the ability to collect 30+ years of financial statements and calculate 200+ financial metrics. The following list shows all of the available functionality and metrics.
___
<b><div align="center">Find a variety of How-To Guides including Code Documentation for the Finance Toolkit <a href="https://www.jeroenbouma.com/projects/financetoolkit">here</a>.</div></b> ___
Each ratio and indicator has a corresponding function that can be called directly for example ratios.get_return_on_equity or technicals.get_relative_strength_index. However, there are also functions that collect multiple ratios or indicators at once such as ratios.collect_profitability_ratios. These functions are useful when you want to collect a large amount of ratios or indicators at once.
<p align="center"> <img src="examples/Finance Toolkit - Video Demo.gif" alt="Finance Toolkit Illustration" width="100%" onerror="this.style.display = 'none'"/> </p>
Core Functionality
These are the core functionalities of the Finance Toolkit. For any calculation, it often first collects data via these functions. For example, financial ratios require the financial statements and historical data which are obtained through the Toolkit without needing to specify this first.
<details> <summary><b>Financial Statements</b></summary>
Acquire a full history of both annual and quarterly financial statements, including balance sheets, income statements, and cash flow statements.
These financial statements are adjusted for the following reasons:
- The financial statements are automatically standardized (based on these files to allow for the ability to enter any type of dataset given that the names used are what all of the functionalities rely on.
- The fiscal year of each company is automatically converted to the calendar year so that all companies can be compared on the same basis. As an example, Apple's Q4 2023 is related to the period July 2023 until September 2023 which corresponds to Q3 2023. This means that in the Finance Toolkit these results are reported in the Q3 2023 column.
- When
convert_currency=True(automatically enabled with a Premium FMP plan) the currency of the historical data is compared to the currency of the financial statements. If they do not match, the financial statement data is converted to the currency of the historical data. This is done to ensure that calculations such as the Price-to-Earnings Ratio (PE) have both the Share Price and Earnings denoted in the same currency.
To get insights related to the reported currency, CIK ID and SEC Links, it is possible to retrieve a statististics statement as well.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit(["MSFT", "MU"], api_key="FINANCIAL_MODELING_PREP_KEY", quarterly=True, start_date='2022-05-01')
balance_sheet_statements = toolkit.get_balance_sheet_statement()
balance_sheet_statements.loc['MU']
Which returns:
| | 2022Q2 | 2022Q3 | 2022Q4 | 2023Q1 | 2023Q2 | |:-----------------------------------------|------------:|------------:|------------:|------------:|------------:| | Cash and Cash Equivalents | 9.157e+09 | 8.262e+09 | 9.574e+09 | 9.798e+09 | 9.298e+09 | | Short Term Investments | 1.07e+09 | 1.069e+09 | 1.007e+09 | 1.02e+09 | 1.054e+09 | | Cash and Short Term Investments | 1.0227e+10 | 9.331e+09 | 1.0581e+10 | 1.0818e+10 | 1.0352e+10 | | Accounts Receivable | 6.229e+09 | 5.13e+09 | 3.318e+09 | 2.278e+09 | 2.429e+09 | | Inventory | 5.629e+09 | 6.663e+09 | 8.359e+09 | 8.129e+09 | 8.238e+09 | | Other Current Assets | 6.08e+08 | 6.44e+08 | 6.63e+08 | 6.73e+08 | 7.15e+08 | | Total Current Assets | 2.2708e+10 | 2.1781e+10 | 2.2921e+10 | 2.1898e+10 | 2.1734e+10 | | Property, Plant and Equipment | 3.7355e+10 | 3.9227e+10 | 4.0028e+10 | 3.9758e+10 | 3.9382e+10 | | Goodwill | 1.228e+09 | 1.228e+09 | 1.228e+09 | 1.228e+09 | 1.252e+09 | | Intangible Assets | 4.15e+08 | 4.21e+08 | 4.28e+08 | 4.1e+08 | 4.1e+08 | | Long Term Investments | 1.646e+09 | 1.647e+09 | 1.426e+09 | 1.212e+09 | 9.73e+08 | | Tax Assets | 6.82e+08 | 7.02e+08 | 6.72e+08 | 6.97e+08 | 7.08e+08 | | Other Fixed Assets | 1.262e+09 | 1.277e+09 | 1.171e+09 | 1.317e+09 | 1.221e+09 | | Fixed Assets | 4.2588e+10 | 4.4502e+10 | 4.4953e+10 | 4.4622e+10 | 4.3946e+10 | | Other Assets | 0 | 0 | 0 | 0 | 0 | | Total Assets | 6.5296e+10 | 6.6283e+10 | 6.7874e+10 | 6.652e+10 | 6.568e+10 | | Accounts Payable | 2.019e+09 | 2.142e+09 | 1.789e+09 | 1.689e+09 | 1.64e+09 | | Short Term Debt | 1.07e+08 | 1.03e+08 | 1.71e+08 | 2.37e+08 | 2.59e+08 | | Tax Payables | 3.82e+08 | 4.2e+08 | 4.19e+08 | 2.41e+08 | 1.48e+08 | | Deferred Revenue | 0 | 0 | 0 | 0 | -1.64e+09 | | Other Current Liabilities | 4.883e+09 | 5.294e+09 | 4.565e+09 | 3.329e+09 | 4.845e+09 | | Total Current Liabilities | 7.009e+09 | 7.539e+09 | 6.525e+09 | 5.255e+09 | 5.104e+09 | | Long Term Debt | 7.485e+09 | 7.413e+09 | 1.0719e+10 | 1.2647e+10 | 1.3589e+10 | | Deferred Revenue Non Current | 6.63e+08 | 5.89e+08 | 5.16e+08 | 5.29e+08 | 6.32e+08 | | Deferred Tax Liabilities | 0 | 0 | 0 | 0 | 0 | | Other Non Current Liabilities | 8.58e+08 | 8.35e+08 | 8.08e+08 | 8.32e+08 | 9.5e+08 | | Total Non Current Liabilities | 9.006e+09 | 8.837e+09 | 1.2043e+10 | 1.4008e+10 | 1.5171e+10 | | Other Liabilities | 0 | 0 | 0 | 0 | 0 | | Capital Lease Obligations | 6.29e+08 | 6.1e+08 | 6.25e+08 | 6.1e+08 | 6.03e+08 | | Total Liabilities | 1.6015e+10 | 1.6376e+10 | 1.8568e+10 | 1.9263e+10 | 2.0275e+10 | | Preferred Stock | 0 | 0 | 0 | 0 | 0 | | Common Stock | 1.22e+08 | 1.23e+08 | 1.23e+08 | 1.23e+08 | 1.24e+08 | | Retained Earnings | 4.5916e+10 | 4.7274e+10 | 4.6873e+10 | 4.4426e+10 | 4.2391e+10 | | Accumulated Other Comprehensive Income | -3.64e+08 | -5.6e+08 | -4.73e+08 | -3.73e+08 | -3.4e+08 | | Other Total Shareholder Equity | 3.607e+09 | 3.07e+09 | 2.783e+09 | 3.081e+09 | 3.23e+09 | | Total Shareholder Equity | 4.9281e+10 | 4.9907e+10 | 4.9306e+10 | 4.7257e+10 | 4.5405e+10 | | Total Equity | 4.9281e+10 | 4.9907e+10 | 4.9306e+10 | 4.7257e+10 | 4.5405e+10 | | Total Liabilities and Shareholder Equity | 6.5296e+10 | 6.6283e+10 | 6.7874e+10 | 6.652e+10 | 6.568e+10 | | Minority Interest | 0 | 0 | 0 | 0 | 0 | | Total Liabilities and Equity | 6.5296e+10 | 6.6283e+10 | 6.7874e+10 | 6.652e+10 | 6.568e+10 | | Total Investments | 2.716e+09 | 2.716e+09 | 2.433e+09 | 2.232e+09 | 2.027e+09 | | Total Debt | 7.592e+09 | 7.516e+09 | 1.089e+10 | 1.2884e+10 | 1.3848e+10 | | Net Debt | -1.565e+09 | -7.46e+08 | 1.316e+09 | 3.086e+09 | 4.55e+09 |
</details>
<details> <summary><b>Company Overviews</b></summary>
Obtain the profile of the specified tickers. These include important metrics such as the beta, market capitalization, currency, isin, industry, and ipo date that give an overall understanding about the company.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit(["MSFT", "AAPL"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.get_profile()
Which returns:
| | MSFT | AAPL | |:----------------------|:--------------------------|:----------------------| | Symbol | MSFT | AAPL | | Price | 316.48 | 174.49 | | Beta | 0.903706 | 1.286802 | | Average Volume | 28153120 | 57348456 | | Market Capitalization | 2353183809372 | 2744500935588 | | Last Dividend | 2.7199999999999998 | 0.96 | | Range | 213.43-366.78 | 124.17-198.23 | | Changes | -0.4 | 0.49 | | Company Name | Microsoft Corporation | Apple Inc. | | Currency | USD | USD | | CIK | 789019 | 320193 | | ISIN | US5949181045 | US0378331005 | | CUSIP | 594918104 | 37833100 | | Exchange | NASDAQ Global Select | NASDAQ Global Select | | Exchange Short Name | NASDAQ | NASDAQ | | Industry | Software - Infrastructure | Consumer Electronics | | Website | https://www.microsoft.com | https://www.apple.com | | CEO | Mr. Satya Nadella | Mr. Timothy D. Cook | | Sector | Technology | Technology | | Country | US | US | | Full Time Employees | 221000 | 164000 | | Phone | 425 882 8080 | 408 996 1010 | | Address | One Microsoft Way | One Apple Park Way | | City | Redmond | Cupertino | | State | WA | CA | | ZIP Code | 98052-6399 | 95014 | | DCF Difference | 4.56584 | 4.15176 | | DCF | 243.594 | 150.082 | | IPO Date | 1986-03-13 | 1980-12-12 |
Get the quote of the specified tickers. These include important metrics such as the price, changes, day low, day high, year low, year high, market capitalization, volume, average volume, open, previous close, earnings per share (EPS), price to earnings ratio (PE), earnings announcement, shares outstanding and timestamp that give an overall understanding about the company.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit(["TSLA", "AAPL"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.get_quote()
Which returns:
| | TSLA | AAPL | |:-----------------------|:-----------------------------|:-----------------------------| | Symbol | TSLA | AAPL | | Name | Tesla, Inc. | Apple Inc. | | Price | 215.49 | 174.49 | | Changes Percentage | -1.7015 | 0.2816 | | Change | -3.73 | 0.49 | | Day Low | 212.36 | 171.96 | | Day High | 217.58 | 175.1 | | Year High | 313.8 | 198.23 | | Year Low | 101.81 | 124.17 | | Market Capitalization | 682995534313 | 2744500935588 | | Price Average 50 Days | 258.915 | 187.129 | | Price Average 200 Days | 196.52345 | 161.4698 | | Exchange | NASDAQ | NASDAQ | | Volume | 136276584 | 61172150 | | Average Volume | 133110158 | 57348456 | | Open | 214.12 | 172.3 | | Previous Close | 219.22 | 174 | | EPS | 3.08 | 5.89 | | PE | 69.96 | 29.62 | | Earnings Announcement | 2023-10-17T20:00:00.000+0000 | 2023-10-25T10:59:00.000+0000 | | Shares Outstanding | 3169499904 | 15728700416 | | Timestamp | 2023-08-18 20:00:00 | 2023-08-18 20:00:01 |
Get the rating of the specified tickers. These scores and recommendations are categorized as follows:
- An overall rating
- Discounted Cash Flow (DCF)
- Return on Equity (ROE)
- Return on Assets (ROA)
- Debt to Equity (DE)
- Price Earnings (PE)
- Price to Book (PB)
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
rating = toolkit.get_rating()
rating.loc['AMZN', 'Rating Recommendation'].tail()
Which returns:
| date | Rating Recommendation | |:--------------------|:------------------------| | 2023-08-01 00:00:00 | Strong Buy | | 2023-08-02 00:00:00 | Strong Buy | | 2023-08-03 00:00:00 | Strong Buy | | 2023-08-04 00:00:00 | Strong Buy | | 2023-08-07 00:00:00 | Strong Buy |
</details>
<details> <summary><b>(Intraday) Historical Market Data</b></summary>
Obtain historical market data for the specified tickers. This contains the following columns:
- Open: The opening price for the period.
- High: The highest price for the period.
- Low: The lowest price for the period.
- Close: The closing price for the period.
- Adj Close: The adjusted closing price for the period.
- Volume: The volume for the period.
- Dividends: The dividends for the period.
- Return: The return for the period.
- Volatility: The volatility for the period.
- Excess Return: The excess return for the period. This is defined as the return minus the a predefined risk free rate. Only calculated when excess_return is True.
- Excess Volatility: The excess volatility for the period. This is defined as the volatility of the excess return. Only calculated when
excess_returnis True. - Cumulative Return: The cumulative return for the period.
If a benchmark ticker is selected, it also calculates the benchmark ticker together with the results. By default this is set to “SPY” (S&P 500 Index) but can be any ticker. This is relevant for calculations for models such as CAPM, Alpha and Beta.
Important to note is that when an api_key is included in the Toolkit initialization that the data collection defaults to FinancialModelingPrep which is a more stable source and utilises your subscription. However, if this is undesired, it can be disabled by setting historical_source to YahooFinance. If data collection fails from FinancialModelingPrep it automatically reverts back to YahooFinance.
You are able to specify the period which can be daily (default), weekly, monthly, quarterly or yearly.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit("AAPL", api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.get_historical_data(period="yearly")
Which returns:
| Date | Open | High | Low | Close | Adj Close | Volume | Dividends | Return | Volatility | Excess Return | Excess Volatility | Cumulative Return | |:-------|---------:|---------:|---------:|---------:|------------:|------------:|------------:|-----------:|-------------:|----------------:|--------------------:|--------------------:| | 2013 | 19.7918 | 20.0457 | 19.7857 | 20.0364 | 17.5889 | 2.23084e+08 | 0.108929 | 0 | 0.240641 | 0 | 0.244248 | 1 | | 2014 | 28.205 | 28.2825 | 27.5525 | 27.595 | 24.734 | 1.65614e+08 | 0.461429 | 0.406225 | 0.216574 | 0.384525 | 0.219536 | 1.40623 | | 2015 | 26.7525 | 26.7575 | 26.205 | 26.315 | 23.9886 | 1.63649e+08 | 0.5075 | -0.0301373 | 0.267373 | -0.0528273 | 0.269845 | 1.36385 | | 2016 | 29.1625 | 29.3 | 28.8575 | 28.955 | 26.9824 | 1.22345e+08 | 0.5575 | 0.124804 | 0.233383 | 0.100344 | 0.240215 | 1.53406 | | 2017 | 42.63 | 42.6475 | 42.305 | 42.3075 | 40.0593 | 1.04e+08 | 0.615 | 0.484644 | 0.176058 | 0.460594 | 0.17468 | 2.27753 | | 2018 | 39.6325 | 39.84 | 39.12 | 39.435 | 37.9 | 1.40014e+08 | 0.705 | -0.0539019 | 0.287421 | -0.0807619 | 0.289905 | 2.15477 | | 2019 | 72.4825 | 73.42 | 72.38 | 73.4125 | 71.615 | 1.00806e+08 | 0.76 | 0.889578 | 0.261384 | 0.870388 | 0.269945 | 4.0716 | | 2020 | 134.08 | 134.74 | 131.72 | 132.69 | 130.559 | 9.91166e+07 | 0.8075 | 0.823067 | 0.466497 | 0.813897 | 0.470743 | 7.4228 | | 2021 | 178.09 | 179.23 | 177.26 | 177.57 | 175.795 | 6.40623e+07 | 0.865 | 0.346482 | 0.251019 | 0.331362 | 0.251429 | 9.99467 | | 2022 | 128.41 | 129.95 | 127.43 | 129.93 | 129.378 | 7.70342e+07 | 0.91 | -0.264042 | 0.356964 | -0.302832 | 0.377293 | 7.35566 | | 2023 | 187.84 | 188.51 | 187.68 | 188.108 | 188.108 | 4.72009e+06 | 0.71 | 0.453941 | 0.213359 | 0.412901 | 0.22327 | 10.6947 |
It is also possible to retrieve intraday data. This has the option to get you 1 minute, 5 minute, 15 minute, 30 minute or 1 hour data. It can also be used as part of the Risk, Performance and Technicals modules when defining intraday_period as part of the Toolkit initialization.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit("MSFT", api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.get_intraday_data(period="1min")
Which returns:
| date | Open | High | Low | Close | Volume | Return | Volatility | Cumulative Return | |:-----------------|-------:|-------:|--------:|--------:|---------:|---------:|-------------:|--------------------:| | 2024-01-19 15:45 | 397.64 | 397.88 | 397.63 | 397.88 | 49202 | 0.0006 | 0.0005 | 1.0266 | | 2024-01-19 15:46 | 397.86 | 397.93 | 397.788 | 397.82 | 68913 | -0.0002 | 0.0005 | 1.0264 | | 2024-01-19 15:47 | 397.81 | 397.97 | 397.76 | 397.78 | 62605 | -0.0001 | 0.0005 | 1.0263 | | 2024-01-19 15:48 | 397.78 | 397.85 | 397.675 | 397.845 | 62146 | 0.0002 | 0.0005 | 1.0265 | | 2024-01-19 15:49 | 397.85 | 397.97 | 397.8 | 397.94 | 72700 | 0.0002 | 0.0005 | 1.0267 | | 2024-01-19 15:50 | 397.92 | 398.27 | 397.9 | 398.04 | 140754 | 0.0003 | 0.0005 | 1.027 | | 2024-01-19 15:51 | 398.04 | 398.15 | 397.96 | 398 | 122208 | -0.0001 | 0.0005 | 1.0269 | | 2024-01-19 15:52 | 397.99 | 398.26 | 397.98 | 398.05 | 83546 | 0.0001 | 0.0005 | 1.027 | | 2024-01-19 15:53 | 398.04 | 398.12 | 397.98 | 398.09 | 85098 | 0.0001 | 0.0005 | 1.0271 | | 2024-01-19 15:54 | 398.1 | 398.52 | 398.03 | 398.45 | 187358 | 0.0009 | 0.0005 | 1.028 | | 2024-01-19 15:55 | 398.45 | 398.62 | 398.25 | 398.335 | 237902 | -0.0003 | 0.0005 | 1.0278 | | 2024-01-19 15:56 | 398.33 | 398.44 | 398.3 | 398.415 | 149157 | 0.0002 | 0.0005 | 1.028 | | 2024-01-19 15:57 | 398.42 | 398.5 | 398.29 | 398.43 | 181074 | 0 | 0.0005 | 1.028 | | 2024-01-19 15:58 | 398.46 | 398.47 | 398.29 | 398.35 | 278802 | -0.0002 | 0.0005 | 1.0278 | | 2024-01-19 15:59 | 398.35 | 398.66 | 398.22 | 398.66 | 586344 | 0.0008 | 0.0005 | 1.0286 |
</details>
<details> <summary><b>Treasury Rates</b></summary>
Just like the historical market data, obtain a full history for the treasury rates which also serve as risk-free rate by default allowing for calculations such as the Sharpe Ratio. This also includes normalization of the data as well as auto-adjustments for missing values. It can also be obtained from both FinancialModelingPrep and Yahoo Finance.
It returns the following columns:
- 13 Week Treasury Bond
- 5 Year Treasury Bond
- 10 Year Treasury Bond
- 30 Year Treasury Bond
By default, the Finance Toolkit uses the 10 Year Treasury Bond as risk-free rate but this can be changed by setting risk_free_rate to any of the other treasury rates.
As an example:
from financetoolkit import Toolkit
companies = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2023-08-10")
companies.get_treasury_data()
Which returns:
| date | 13 Week | 5 Year | 10 Year | 30 Year | |:-----------|----------:|---------:|----------:|----------:| | 2023-10-16 | 0.0533 | 0.0472 | 0.0471 | 0.0487 | | 2023-10-17 | 0.0534 | 0.0487 | 0.0485 | 0.0495 | | 2023-10-18 | 0.0533 | 0.0492 | 0.049 | 0.05 | | 2023-10-19 | 0.0531 | 0.0496 | 0.0499 | 0.051 | | 2023-10-20 | 0.053 | 0.0491 | 0.0496 | 0.0512 |
</details>
<details> <summary><b>Earnings & Dividend Calendars</b></summary>
Obtain Earnings Calendars for any range of companies. You have the option to obtain the actual dates or to convert to the corresponding quarters and can obtain a rich history. This returns:
- Date: The date of the earnings release.
- EPS: The actual earnings-per-share.
- EPS Estimate: The estimated earnings-per-share.
- Revenue: The actual revenue.
- Revenue Estimate: The estimated revenue.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "GOOGL", "AMZN"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2022-08-01", quarterly=False
)
earning_calendar = toolkit.get_earnings_calendar()
earning_calendar.loc['AMZN']
Which returns:
| date | EPS | Estimated EPS | Revenue | Estimated Revenue | Fiscal Date Ending | Time | |:------------|-------:|----------------:|--------------:|--------------------:|:---------------------|:-------| | 2022-10-27 | 0.17 | 0.22 | 1.27101e+11 | nan | 2022-09-30 | amc | | 2023-02-02 | 0.25 | 0.18 | 1.49204e+11 | 1.5515e+11 | 2022-12-31 | amc | | 2023-04-27 | 0.31 | 0.21 | 1.27358e+11 | 1.24551e+11 | 2023-03-31 | amc | | 2023-08-03 | 0.65 | 0.35 | 1.34383e+11 | 1.19573e+11 | 2023-06-30 | amc | | 2023-10-25 | nan | 0.56 | nan | 1.41407e+11 | 2023-09-30 | amc | | 2024-01-31 | nan | nan | nan | nan | 2023-12-30 | amc | | 2024-04-25 | nan | nan | nan | nan | 2024-03-30 | amc | | 2024-08-01 | nan | nan | nan | nan | 2024-06-30 | amc |
Furthermore, find Dividend Calendars which includes:
- Date: The date of the dividend.
- Adj Dividend: The adjusted dividend amount.
- Dividend: The dividend amount.
- Record Date: The record date of the dividend.
- Payment Date: The payment date of the dividend.
- Declaration Date: The declaration date of the dividend.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "GOOGL", "AMZN"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2022-08-01", quarterly=False
)
dividend_calendar = toolkit.get_dividend_calendar()
dividend_calendar.loc['AAPL']
Which returns:
| date | Adj Dividend | Dividend | Record Date | Payment Date | Declaration Date | |:-----------|---------------:|-----------:|:--------------|:---------------|:-------------------| | 2022-08-05 | 0.23 | 0.23 | 2022-08-08 | 2022-08-11 | 2022-07-28 | | 2022-11-04 | 0.23 | 0.23 | 2022-11-07 | 2022-11-10 | 2022-10-27 | | 2023-02-10 | 0.23 | 0.23 | 2022-12-28 | 2023-02-16 | 2022-12-19 | | 2023-05-12 | 0.24 | 0.24 | 2023-05-15 | 2023-05-18 | 2023-05-04 | | 2023-08-11 | 0.24 | 0.24 | 2023-08-14 | 2023-08-17 | 2023-08-03 |
</details>
<details> <summary><b>Analyst Estimates</b></summary>
Obtain the Analyst Estimates which include estimates for Revenue, Earnings-per-Share (EPS), EBITDA, EBIT, Net Income, and SGA Expense from the past and future from a large collection of analysts.
It includes the lower, average and upper bound for each estimate which gives insights whether analysts have reached a consensus on the prices or think wildly different. The larger the difference between the lower and upper bound, the more uncertain the analysts are.
As an example:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "GOOGL", "AMZN"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2021-05-01", quarterly=False
)
analyst_estimates = toolkit.get_analyst_estimates()
analyst_estimates.loc['AAPL']
Which returns:
| | 2021 | 2022 | 2023 | 2024 | |:------------------------------|-------------:|-------------:|-------------:|-------------:| | Estimated Revenue Low | 2.98738e+11 | 3.07919e+11 | 3.3871e+11 | 2.93633e+11 | | Estimated Revenue High | 4.48107e+11 | 4.61878e+11 | 5.08066e+11 | 4.4045e+11 | | Estimated Revenue Average | 3.73422e+11 | 3.84898e+11 | 4.23388e+11 | 3.67042e+11 | | Estimated EBITDA Low | 8.50991e+10 | 1.00742e+11 | 1.10816e+11 | 1.07415e+11 | | Estimated EBITDA High | 1.27649e+11 | 1.51113e+11 | 1.66224e+11 | 1.61122e+11 | | Estimated EBITDA Average | 1.06374e+11 | 1.25928e+11 | 1.3852e+11 | 1.34269e+11 | | Estimated EBIT Low | 7.62213e+10 | 9.05428e+10 | 9.9597e+10 | 9.81566e+10 | | Estimated EBIT High | 1.14332e+11 | 1.35814e+11 | 1.49396e+11 | 1.47235e+11 | | Estimated EBIT Average | 9.52766e+10 | 1.13178e+11 | 1.24496e+11 | 1.22696e+11 | | Estimated Net Income Low | 6.54258e+10 | 7.62265e+10 | 8.38492e+10 | 8.23371e+10 | | Estimated Net Income High | 9.81387e+10 | 1.1434e+11 | 1.25774e+11 | 1.23506e+11 | | Estimated Net Income Average | 8.17822e+10 | 9.52832e+10 | 1.04811e+11 | 1.02921e+11 | | Estimated SGA Expense Low | 1.48491e+10 | 1.85317e+10 | 2.03848e+10 | 2.04857e+10 | | Estimated SGA Expense High | 2.22737e+10 | 2.77975e+10 | 3.05772e+10 | 3.07286e+10 | | Estimated SGA Expense Average | 1.85614e+10 | 2.31646e+10 | 2.5481e+10 | 2.56072e+10 | | Estimated EPS Average | 4.26 | 5.465 | 6.01 | 6.2612 | | Estimated EPS High | 5.12 | 6.56 | 7.21 | 7.5135 | | Estimated EPS Low | 3.4 | 4.37 | 4.81 | 5.009 | | Number of Analysts | 14 | 16 | 12 | 10 |
</details>
<details> <summary><b>Revenue Segmentations</b></summary>
Retrieve the [product






