This page includes all the documentation for the Finance Toolkit, 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 calculation method. Each functionality includes an example of how to use it and is therefore an excellent way to better understand how to use each functionality. These examples are also directly embedded in the code. For simplicity sake, only the controller modules are included here given that the models themselves should be relatively straightforward. Make sure to also have a look at the example notebooks as found here.

The Toolkit Module is a collection of functions that collect and parse data, including historical data, fundamental data (balance, income and cash flow statements) and metrics from Financial Modeling Prep such as enterprise values, company profiles and more. From this module you can access all related sub-modules.

To install the FinanceToolkit it simply requires the following:

pip install financetoolkit -U
Search Results

ratios

The Ratios Module contains over 50+ ratios that can be used to analyse companies. These ratios are divided into 5 categories which are efficiency, liquidity, profitability, solvency and valuation. Each ratio is calculated using the data from the Toolkit module.

Some examples of ratios are the Current Ratio, Debt to Equity Ratio, Return on Assets (ROA), Return on Equity (ROE), Return on Invested Capital (ROIC), Return on Capital Employed (ROCE), Price to Earnings Ratio (P/E), Price to Book Ratio (P/B), Price to Sales Ratio (P/S), Price to Cash Flow Ratio (P/CF), Price to Free Cash Flow Ratio (P/FCF), Dividend Yield and Dividend Payout Ratio.

Next to that, it is also possible to define custom ratios.

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/ratios

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

profitability_ratios = toolkit.ratios.collect_profitability_ratios()

profitability_ratios.loc['AAPL']

Which returns:

  2018 2019 2020 2021 2022
Gross Margin 0.383437 0.378178 0.382332 0.417794 0.433096
Operating Margin 0.26694 0.24572 0.241473 0.297824 0.302887
Net Profit Margin 0.224142 0.212381 0.209136 0.258818 0.253096
Interest Burden Ratio 1.02828 1.02827 1.01211 1.00237 0.997204
Income Before Tax Profit Margin 0.274489 0.252666 0.244398 0.298529 0.30204
Effective Tax Rate 0.183422 0.159438 0.144282 0.133023 0.162045
Return on Assets (ROA) 0.162775 0.16323 0.177256 0.269742 0.282924
Return on Equity (ROE) 0.555601 0.610645 0.878664 1.50071 1.96959
Return on Invested Capital (ROIC) 0.269858 0.293721 0.344126 0.503852 0.562645
Return on Capital Employed (ROCE) 0.305968 0.297739 0.320207 0.495972 0.613937
Return on Tangible Assets 0.555601 0.610645 0.878664 1.50071 1.96959
Income Quality Ratio 1.30073 1.25581 1.4052 1.09884 1.22392
Net Income per EBT 0.816578 0.840562 0.855718 0.866977 0.837955
Free Cash Flow to Operating Cash Flow Ratio 0.828073 0.848756 0.909401 0.893452 0.912338
EBT to EBIT Ratio 0.957448 0.948408 0.958936 0.976353 0.975982
EBIT to Revenue 0.286688 0.26641 0.254864 0.305759 0.309473

models

Gives access to the Models module. The Models module is meant to execute well-known models such as DUPONT and the Discounted Cash Flow (DCF) model. These models are also directly related to the data retrieved from the Toolkit module.

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/models

from financetoolkit import Toolkit

toolkit = Toolkit(["TSLA", "AMZN"], api_key="FINANCIAL_MODELING_PREP_KEY", quarterly=True, start_date='2022-12-31')

dupont_analysis = toolkit.models.get_extended_dupont_analysis()

dupont_analysis.loc['AMZN']

Which returns:

  2022Q2 2022Q3 2022Q4 2023Q1 2023Q2
Interest Burden Ratio -1.24465 0.858552 -2.88409 1.20243 1.01681
Tax Burden Ratio -0.611396 1.13743 0.101571 0.640291 0.878792
Operating Profit Margin -0.0219823 0.0231391 -0.00636042 0.0323498 0.0562125
Asset Turnover nan 0.299735 0.3349 0.274759 0.285319
Equity Multiplier nan 3.15403 3.14263 3.08433 2.91521
Return on Equity nan 0.0213618 0.00196098 0.0211066 0.0417791

options

This gives access to the Options module. The Options Module is meant to provide Options valuations based on real market data. This includes the Black-Scholes model and in the future the Binomial model and the Monte Carlo model. It also includes all available first-order, second-order and third-order Greeks such as Delta, Gamma, Theta, Vega, Rho, Charm, Vanna, Vomma, Veta, Speed and Zomma.

It gives insights in the sensitivity of an option to changes in the underlying asset price, volatility, years to maturity, dividend yilds and interest rates and several derivatives of these sensitivities.

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/options

from financetoolkit import Toolkit

toolkit = Toolkit(["TSLA", "MU"], api_key="FINANCIAL_MODELING_PREP_KEY")

all_greeks = toolkit.options.collect_all_greeks(start_date='2024-01-03')

all_greeks.loc['TSLA', '2024-01-04']

Which returns:

Strike Price Delta Dual Delta Vega Theta Rho Epsilon Lambda Gamma Dual Gamma Vanna Charm Vomma Vera Veta PD Speed Zomma Color Ultima
180 1 -0.9999 0 -0.0193 0.0049 -0.6533 0.0408 0 0 -0 0 0 -0 0 0 -0 0 0 0
185 1 -0.9999 0 -0.0198 0.0051 -0.6533 0.0446 0 0 -0 0 0 -0 0 0 -0 0 0 0
190 1 -0.9999 0 -0.0204 0.0052 -0.6533 0.0492 0 0 -0 0 0 -0 0 0 -0 0 0 0
195 1 -0.9999 0 -0.0209 0.0053 -0.6533 0.0549 0 0 -0 0 0 -0 0 0 -0 0 0 0
200 1 -0.9999 0 -0.0214 0.0055 -0.6533 0.062 0 0 -0 0 0 -0 0.0014 0 -0 0 0 0
205 1 -0.9999 0 -0.022 0.0056 -0.6533 0.0712 0 0 -0 0.0005 0.0003 -0 0.1236 0 -0 0 0.0004 0.0001
210 1 -0.9999 0 -0.0226 0.0058 -0.6533 0.0837 0 0 -0.0002 0.0221 0.0119 -0.0001 4.6313 0 -0 0.0001 0.0132 0.0034
215 0.9998 -0.9997 0.0001 -0.0254 0.0059 -0.6532 0.1016 0.0001 0.0001 -0.0044 0.4426 0.1942 -0.0029 77.6496 0.0001 -0.0001 0.0021 0.209 0.0336
220 0.9973 -0.9969 0.001 -0.0526 0.006 -0.6515 0.1287 0.0012 0.0014 -0.0414 4.1955 1.4351 -0.0273 600.92 0.0014 -0.0005 0.0144 1.4569 0.1196
225 0.9777 -0.976 0.0066 -0.2079 0.006 -0.6387 0.1723 0.0076 0.0086 -0.1884 19.0888 4.7244 -0.1249 2187.89 0.0086 -0.0022 0.0407 4.1228 0.0829
230 0.8953 -0.8898 0.0226 -0.6528 0.0056 -0.5849 0.2419 0.0261 0.028 -0.3993 40.3564 6.2557 -0.267 3816.31 0.028 -0.0048 0.0253 2.5239 -0.1641
235 0.6978 -0.6874 0.0435 -1.2304 0.0044 -0.4558 0.3442 0.0502 0.0516 -0.306 30.653 1.9785 -0.2119 3623.7 0.0516 -0.0039 -0.0672 -6.8719 -0.0977
240 0.4192 -0.4078 0.0488 -1.3691 0.0027 -0.2739 0.4789 0.0562 0.0555 0.1634 -17.1438 0.4159 0.0934 3407.79 0.0555 0.0014 -0.096 -9.7512 -0.0222
245 0.1812 -0.1736 0.0329 -0.9207 0.0012 -0.1184 0.6396 0.0379 0.0359 0.4445 -45.5549 5.0536 0.2814 4080.87 0.0359 0.0048 -0.0098 -0.9474 -0.1945
250 0.0544 -0.0513 0.0138 -0.3848 0.0004 -0.0355 0.8183 0.0159 0.0144 0.3232 -33.01 6.468 0.2073 3328.37 0.0144 0.0036 0.0461 4.7176 -0.0443
255 0.0112 -0.0104 0.0037 -0.1028 0.0001 -0.0073 1.0084 0.0042 0.0037 0.1223 -12.477 3.4845 0.0789 1542.52 0.0037 0.0014 0.0325 3.3216 0.1424
260 0.0016 -0.0015 0.0006 -0.018 0 -0.001 1.205 0.0007 0.0006 0.0276 -2.8148 1.0161 0.0179 421.028 0.0006 0.0003 0.0104 1.0578 0.1054
265 0.0002 -0.0001 0.0001 -0.0021 0 -0.0001 1.4049 0.0001 0.0001 0.004 -0.4041 0.1783 0.0026 71.3544 0.0001 0 0.0019 0.1933 0.0322
270 0 -0 0 -0.0002 0 -0 1.6059 0 0 0.0004 -0.0385 0.02 0.0002 7.8471 0 0 0.0002 0.0222 0.0054
275 0 -0 0 -0 0 -0 1.8068 0 0 0 -0.0025 0.0015 0 0.5804 0 0 0 0.0017 0.0006
280 0 -0 0 -0 0 -0 2.0066 0 0 0 -0.0001 0.0001 0 0.0297 0 0 0 0.0001 0
285 0 -0 0 -0 0 -0 2.2048 0 0 0 -0 0 0 0.0011 0 0 0 0 0
290 0 -0 0 -0 0 -0 2.401 0 0 0 -0 0 0 0 0 0 0 0 0
295 0 -0 0 -0 0 -0 2.595 0 0 0 -0 0 0 0 0 0 0 0 0

technicals

This gives access to the Technicals module. The Technicals Module contains nearly 50 Technical Indicators that can be used to analyse companies. These indicators are divided into 3 categories: breadth, overlap and volatility. Each indicator is calculated using the data from the Toolkit module.

Some examples of technical indicators are the Average Directional Index (ADX), the Accumulation/Distribution Line (ADL), the Average True Range (ATR), the Bollinger Bands (BBANDS), the Commodity Channel Index (CCI), the Chaikin Oscillator (CHO), the Chaikin Money Flow (CMF), the Double Exponential Moving Average (DEMA), the Exponential Moving Average (EMA) and the Moving Average Convergence Divergence (MACD).

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/technicals

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

average_directional_index = toolkit.technicals.get_average_directional_index()

Which returns:

Date AAPL MSFT
2023-08-21 62.8842 36.7468
2023-08-22 65.7063 36.5525
2023-08-23 67.3596 35.5149
2023-08-24 66.4527 35.4399
2023-08-25 63.4837 32.3323

performance

This gives access to the Performance module. The Performance Module is meant to calculate metrics related to the risk-return relationship. These are things such as Beta, Sharpe Ratio, Sortino Ratio, CAPM, Alpha and the Treynor Ratio.

It gives insights in the performance a stock has to e.g. a benchmark that is not easily identified by looking at the raw data. This class is closely related to the Risk class which highlights things such as Value at Risk (VaR) and Maximum Drawdown.

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/performance

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.performance.get_capital_asset_pricing_model(period='quarterly')

Which returns:

Date AAPL TSLA
2022Q3 -0.0684 -0.1047
2022Q4 0.0857 0.0828
2023Q1 0.075 0.1121
2023Q2 0.0922 0.1342
2023Q3 0.0052 -0.0482

risk

This gives access to the Risk module. The Risk Module is meant to calculate metrics related to risk such as Value at Risk (VaR), Conditional Value at Risk (cVaR), EMWA/GARCH models and similar models. It also houses cross-asset systemic risk and liquidity measures (CoVaR, Tail Dependence, Amihud Illiquidity, Roll Spread).

Note that the time-series diagnostic and econometric tests (unit root tests, cointegration, Granger causality, ARCH-LM, Jarque-Bera and similar tests) live in the separate Econometrics module instead.

It gives insights in the risk a stock composes that is not perceived as easily by looking at the data. This class is closely related to the Performance class which highlights things such as Sharpe Ratio and Sortino Ratio.

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/risk

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.risk.get_value_at_risk(period='yearly')

Which returns:

Date AAPL TSLA
2012 0 0
2013 0.1754 4.96
2014 1.7515 0.9481
2015 -0.1958 0.1454
2016 0.4177 -0.3437
2017 2.6368 1.2225
2018 -0.2786 0.0718
2019 3.2243 0.4707
2020 1.729 8.3319
2021 1.3179 0.8797
2022 -0.8026 -1.0046
2023 1.8549 1.8238

econometrics

This gives access to the Econometrics module, a thin wrapper that funnels this Toolkit’s price/return data through statsmodels and linearmodels – regression (OLS/WLS/GLS/ Logit/Probit/Quantile), panel data (Fixed/Random Effects, Hausman), causal inference (IV-2SLS, Difference-in-Differences, Regression Discontinuity, Propensity Score Matching), specification/hypothesis tests (Breusch-Pagan, White, Durbin-Watson, VIF, RESET, Chow, t/F/LR/Wald tests), stationarity (Augmented Dickey-Fuller, KPSS, Phillips-Perron, Zivot-Andrews unit root tests), long-run equilibrium relationships (Engle-Granger and Johansen cointegration), predictive lead-lag relationships (Granger causality), model/ residual diagnostics (ARCH-LM, Jarque-Bera, Ljung-Box, Variance Ratio, CUSUM), forecast comparison (Diebold-Mariano), and time series forecasting (ARIMA, VAR, VECM).

This class is closely related to the Risk class, which houses the risk measures (VaR, CVaR, GARCH) that these tests often inform the choice of.

Requires the optional financetoolkit[econometrics] extra (statsmodels and linearmodels) – install with pip install financetoolkit[econometrics].

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/econometrics

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.econometrics.get_augmented_dickey_fuller(period='yearly')

fixedincome

This gives access to the Fixed Income module. This module contains a wide variety of fixed income related calculations such as the Effective Yield, the Macaulay Duration, the Modified Duration, the Convexity, the Yield to Maturity and models such as Black and Bachelier to valuate derivative instruments such as Swaptions.

Next to that, it is also possible to acquire Central Bank Rates and ICE BofA Indices such as the ICE BofA US High Yield Index, the ICE BofA US Corporate Index and the ICE BofA US Treasury Index.

Note that this class can also be directly accessed by importing the FixedIncome class directly via from financetoolkit import FixedIncome. This is useful if you only want to use the FixedIncome class and not the other classes within the Toolkit module.

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/fixedincome

from financetoolkit import FixedIncome

fixedincome = FixedIncome(
    start_date='2024-01-01',
    end_date='2024-01-15',
)

fixedincome.get_effective_yield(maturity=False)

Which returns:

Date AAA AA A BBB BB B CCC
2024-01-01 0.0456 0.047 0.0505 0.054 0.0613 0.0752 0.1319
2024-01-02 0.0459 0.0473 0.0509 0.0543 0.0622 0.0763 0.1333
2024-01-03 0.0459 0.0474 0.051 0.0544 0.0634 0.0779 0.1358
2024-01-04 0.0466 0.0481 0.0518 0.0551 0.0639 0.0784 0.1367
2024-01-05 0.047 0.0485 0.0521 0.0554 0.0641 0.0787 0.137
2024-01-08 0.0465 0.0481 0.0517 0.055 0.0633 0.0776 0.1365
2024-01-09 0.0464 0.048 0.0516 0.0548 0.0629 0.0771 0.1359
2024-01-10 0.0464 0.048 0.0515 0.0547 0.0622 0.0762 0.1351
2024-01-11 0.0456 0.0472 0.0507 0.054 0.0619 0.076 0.1344
2024-01-12 0.0451 0.0467 0.0502 0.0534 0.0613 0.0753 0.1338
2024-01-15 0.0451 0.0467 0.0501 0.0533 0.0611 0.0751 0.1328

economics

This gives access to the Economics module. This module contains a wide variety of economic data obtained from OECD. These include things such as the Consumer Price Index (CPI), the Producer Price Index (PPI), the Unemployment Rate, the GDP Growth Rate, the Long and Short Term Interest Rate and the Consumer Confidence Index.

Note that this class can also be directly accessed by importing the Economics class directly via from financetoolkit import Economics. This is useful if you only want to use the Economics class and not the other classes within the Toolkit module.

See the following link for more information: https://www.jeroenbouma.com/projects/financetoolkit/docs/economics

from financetoolkit import Toolkit

toolkit = Toolkit(["AMZN", "ASML"])

cpi = toolkit.economics.get_consumer_price_index(period='yearly')

cpi.loc['2015':, ['United States', 'Netherlands', 'Japan']]

Which returns:

  United States Netherlands Japan
2015 100 100 100
2016 101.262 100.317 99.8727
2017 103.419 101.703 100.356
2018 105.945 103.435 101.349
2019 107.865 106.159 101.824
2020 109.195 107.51 101.799
2021 114.325 110.387 101.561
2022 123.474 121.427 104.098

get_profile

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.

Also known as: company description, sector, industry, CEO, employee count.

Args:

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_quote

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.

Also known as: real-time price, current stock price, live quote.

Args:

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 443.21 254.43
Change % 0.6380600000000001 -0.40319000000000005
Change 2.81 -1.03
Volume 78840639 39443231
Day Low 439.5 253.01
Day High 450.98 254.87
Year High 488.54 260.1
Year Low 212.11 169.21
Market Capitalization 1429511519286 3775840427700
Price Average 50 Days 354.2336 229.3156
Price Average 200 Days 334.7398 222.012
Exchange NASDAQ NASDAQ
Open 444.355 254.64
Previous Close 440.4 255.46
Timestamp 2025-09-29 20:00:00 2025-09-29 20:00:01

get_rating

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)

Also known as: analyst consensus, buy sell hold recommendation.

Args:

Raises:

ValueError: If an API key is not defined for FinancialModelingPrep.

Returns:

pd.DataFrame: The stock rating information for the specified tickers.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["AMZN", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

rating = toolkit.get_rating()

rating.loc['AMZN'].tail()

Which returns:

date Rating Rating Score DCF Score ROE Score ROA Score DE Score PE Score PB Score
2025-09-23 00:00:00 B+ 3 2 5 5 3 2 1
2025-09-24 00:00:00 B+ 3 2 5 5 3 2 1
2025-09-25 00:00:00 B+ 3 2 5 5 3 2 1
2025-09-26 00:00:00 B+ 3 2 5 5 3 2 1
2025-09-29 00:00:00 B+ 3 2 5 5 3 2 1

get_analyst_estimates

Obtain analyst estimates regarding revenues, EBITDA, EBIT, Net Income SGA Expenses and EPS. The number of analysts are also reported.

Note that this information requires a Premium FMP subscription.

Also known as: earnings estimates, revenue estimates, analyst consensus.

Args:

  • overwrite (bool, optional): Defines whether to overwrite the existing data. Defaults to False.
  • rounding (int \| None, optional): Defines the number of decimal places to round the data to. Defaults to None.
  • growth (bool, optional): Defines whether to return the growth of the data. Defaults to False.
  • lag (int \| list[int], optional): Defines the number of periods to lag the growth data by. Defaults to 1.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pandas.DataFrame: The analyst estimates for the specified tickers.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "GOOGL", "AMZN"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2024-05-01", quarterly=False
)

analyst_estimates = toolkit.get_analyst_estimates()

analyst_estimates.loc['AAPL'].iloc[:, :5]

Which returns:

  2024 2025 2026 2027 2028
Estimated Revenue Low 3.89951e+11 4.06152e+11 4.29886e+11 4.61474e+11 4.55389e+11
Estimated Revenue High 3.9221e+11 4.19587e+11 4.5212e+11 4.63255e+11 5.05369e+11
Estimated Revenue Average 3.90481e+11 4.15035e+11 4.38728e+11 4.62364e+11 4.76309e+11
Estimated EBITDA Low 1.28061e+11 1.33382e+11 1.41176e+11 1.51549e+11 1.49551e+11
Estimated EBITDA High 1.28803e+11 1.37794e+11 1.48477e+11 1.52134e+11 1.65965e+11
Estimated EBITDA Average 1.28235e+11 1.36299e+11 1.4408e+11 1.51842e+11 1.56421e+11
Estimated EBIT Low 1.15692e+11 1.20498e+11 1.2754e+11 1.36911e+11 1.35106e+11
Estimated EBIT High 1.16362e+11 1.24484e+11 1.34136e+11 1.3744e+11 1.49934e+11
Estimated EBIT Average 1.15849e+11 1.23134e+11 1.30163e+11 1.37175e+11 1.41313e+11
Estimated Net Income Low 9.45908e+10 1.11489e+11 1.18544e+11 1.22161e+11 1.38181e+11
Estimated Net Income High 1.05866e+11 1.14578e+11 1.28409e+11 1.46962e+11 1.58172e+11
Estimated Net Income Average 9.7294e+10 1.13033e+11 1.23476e+11 1.25929e+11 1.46549e+11
Estimated SGA Expense Low 2.55838e+10 2.66468e+10 2.82039e+10 3.02763e+10 2.98771e+10
Estimated SGA Expense High 2.5732e+10 2.75282e+10 2.96626e+10 3.03931e+10 3.31562e+10
Estimated SGA Expense Average 2.56186e+10 2.72295e+10 2.8784e+10 3.03347e+10 3.12496e+10
Estimated EPS Average 6.7082 7.3761 8.0086 8.7606 9.5111
Estimated EPS High 6.8708 7.4362 8.3339 9.538 10.2655
Estimated EPS Low 6.139 7.2358 7.6936 7.9284 8.9681
Number of Analysts 25 29 30 19 9

get_earnings_calendar

Obtain Earnings Calendars for any range of companies. You have the option to obtain the actual dates or to convert to the corresponding quarters.

Note that this information requires a Premium FMP subscription.

Also known as: earnings dates, earnings schedule, reporting date.

Args:

  • actual_dates (bool): Defines whether to return the actual dates or the corresponding quarters.
  • overwrite (bool): Defines whether to overwrite the existing data.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.
  • rounding (int \| None): The number of decimals to round the results to. Defaults to None, which uses the rounding set on the Toolkit.

Returns:

pd.DataFrame: The earnings calendar for the specified tickers.

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 Last Updated
2022-10-27 00:00:00 0.2 0.22 1.27101e+11 1.27308e+11 2025-04-25
2023-02-02 00:00:00 0.21 0.15 1.49204e+11 1.45713e+11 2025-04-25
2023-04-27 00:00:00 0.31 0.21 1.27358e+11 1.24551e+11 2025-04-25
2023-08-03 00:00:00 0.65 0.35 1.34383e+11 1.19573e+11 2025-04-25
2023-10-26 00:00:00 0.94 0.58 1.43083e+11 1.33393e+11 2025-04-25
2024-02-01 00:00:00 1 0.8 1.69961e+11 1.66172e+11 2025-04-25
2024-04-30 00:00:00 0.98 0.83 1.43313e+11 1.42654e+11 2025-04-25
2024-08-01 00:00:00 1.26 1.03 1.47977e+11 1.48665e+11 2025-04-25
2024-10-31 00:00:00 1.43 1.14 1.58877e+11 1.57275e+11 2025-04-25
2025-02-06 00:00:00 1.86 1.49 1.87792e+11 1.87337e+11 2025-05-06
2025-05-01 00:00:00 1.59 1.37 1.55667e+11 1.55148e+11 2025-08-01
2025-07-31 00:00:00 1.68 1.31 1.67702e+11 1.61776e+11 2025-09-30

get_stock_news

Obtain the latest stock market news articles for the tickers of this Toolkit instance. Qualitative companion to the toolkit’s quantitative data. Automatically filtered to this Toolkit instance’s start_date and end_date.

Also known as: ticker news, company news feed.

Args:

  • pages (int, optional): The number of pages to collect, each page is a separate API call, e.g. pages=5 makes 5 calls. Defaults to 1.
  • limit (int, optional): The number of articles to return per page. Defaults to 100.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: The latest news articles for the specified tickers.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")

stock_news = toolkit.get_stock_news(limit=5)

stock_news[["Symbol", "Publisher", "Title"]]

Which returns:

Published Date Symbol Publisher Title
2026-07-07 10:46:52 AAPL Benzinga Walmart, Apple And Nike May Be Agentic AI’s First Winners. Grocery May Be The First Loser
2026-07-07 10:21:00 MSFT GlobeNewsWire MSFT Investors Have Opportunity to Lead Microsoft Corporation Securities Fraud Lawsuit…
2026-07-07 10:20:11 AAPL Forbes Why Investors Fell Back In Love With Apple’s Cheap AI Strategy
2026-07-07 09:59:19 MSFT Benzinga Michael Burry’s $700 Microsoft Bet: Should You Copy His LEAP Trade?
2026-07-07 09:26:50 AAPL Benzinga Forget the iPhone. Apple’s AI Story May Belong to Macs

get_press_releases

Obtain the latest official company press releases for the tickers of this Toolkit instance, such as earnings announcements and corporate communications. Automatically filtered to this Toolkit instance’s start_date and end_date.

Also known as: corporate announcements, company press release feed.

Args:

  • pages (int, optional): The number of pages to collect, each page is a separate API call, e.g. pages=5 makes 5 calls. Defaults to 1.
  • limit (int, optional): The number of articles to return per page. Defaults to 100.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: The latest press releases for the specified tickers.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")

press_releases = toolkit.get_press_releases(limit=5)

press_releases[["Symbol", "Publisher", "Title"]]

Which returns:

Published Date Symbol Publisher Title
2026-07-07 10:21:00 MSFT GlobeNewsWire MSFT Investors Have Opportunity to Lead Microsoft Corporation Securities Fraud Lawsuit…
2026-07-07 06:36:00 MSFT PRNewsWire MSFT Investment Deadline: Microsoft Securities Fraud Class Action Focuses on Copilot…
2026-07-06 15:34:00 MSFT GlobeNewsWire MICROSOFT CLASS ACTION ALERT: Bragar Eagel & Squire, P.C. Urges Microsoft Corporation…
2026-07-06 13:24:00 MSFT GlobeNewsWire Deadline Alert: Microsoft Corporation (MSFT) Shareholders Who Lost Money Urged To Contact…
2026-07-06 10:07:00 MSFT GlobeNewsWire Levi & Korsinsky Reminds Shareholders of a Lead Plaintiff Deadline of August 11, 2026…

get_revenue_geographic_segmentation

Obtain revenue by geographic segmentation (e.g. United States, Europe, Asia).

Note that this information requires a Premium FMP subscription.

Also known as: revenue by region, geographic revenue breakdown.

Args:

  • overwrite (bool): Defines whether to overwrite the existing data.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: The revenue by geographic segmentation for the specified tickers.

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
)

geographic_segmentation = toolkit.get_revenue_geographic_segmentation()

geographic_segmentation.loc['AAPL']

Which returns:

  2020 2021 2022 2023
Americas 4.631e+10 5.1496e+10 4.9278e+10 3.5383e+10
Asia Pacific 8.225e+09 9.81e+09 9.535e+09 5.63e+09
China 2.1313e+10 2.5783e+10 2.3905e+10 1.5758e+10
Europe 2.7306e+10 2.9749e+10 2.7681e+10 2.0205e+10
Japan 8.285e+09 7.107e+09 6.755e+09 4.821e+09

get_revenue_product_segmentation

Obtain revenue by product segmentation (e.g. iPad, Advertisement, Windows).

Note that this information requires a Premium FMP subscription.

Also known as: revenue by product, product segment revenue.

Args:

  • overwrite (bool): Defines whether to overwrite the existing data.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: The revenue by product segmentation for the specified tickers.

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
)

product_segmentation = toolkit.get_revenue_product_segmentation()

product_segmentation.loc['MSFT']

Which returns:

  2022Q2 2022Q3 2022Q4 2023Q1 2023Q2
Devices 1.581e+09 1.448e+09 1.43e+09 1.282e+09 1.361e+09
Enterprise Services 1.902e+09 1.876e+09 1.862e+09 2.007e+09 1.977e+09
Gaming 3.455e+09 3.61e+09 4.758e+09 3.607e+09 3.491e+09
Linked In Corporation 3.712e+09 3.663e+09 3.876e+09 3.697e+09 3.909e+09
Office Products And Cloud Services 1.1639e+10 1.1548e+10 1.1837e+10 1.2438e+10 1.2905e+10
Other Products And Services 1.403e+09 1.348e+09 1.359e+09 1.428e+09 -3.924e+09
Search And News Advertising 2.926e+09 2.928e+09 3.223e+09 3.045e+09 3.012e+09
Server Products And Cloud Services 1.8839e+10 1.8388e+10 1.9594e+10 2.0025e+10 2.1963e+10
Windows 6.408e+09 5.313e+09 4.808e+09 5.328e+09 6.058e+09

get_historical_data

Returns historical 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. - Cumulative Return: The cumulative return for the period.

Volatility, Excess Return and Excess Volatility are not included here. These are available as dedicated calculations in the Risk module (e.g. toolkit.risk.get_volatility, toolkit.risk.get_excess_volatility) and the Performance module (e.g. toolkit.performance.get_excess_return) instead.

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 enforce_source to “YahooFinance”. If data collection fails from FinancialModelingPrep it automatically reverts back to YahooFinance.

Also known as: OHLCV, price history, open high low close volume.

Args:

  • enforce_source (str, optional): A string containing the historical source you wish to enforce. This can be either FinancialModelingPrep or YahooFinance. Defaults to no enforcement.
  • period (str): The interval at which the historical data should be returned - daily, weekly, monthly, quarterly, or yearly. Defaults to “daily”.
  • return_column (str): The column to use for the return calculation. Defaults to “Adj Close”.
  • include_dividends (bool): Defines whether to include dividends in the return calculation. Defaults to True.
  • fill_nan (bool): Defines whether to forward fill NaN values. This defaults to True to prevent holes in the dataset. This is especially relevant for technical indicators.
  • overwrite (bool): Defines whether to overwrite the existing data. If this is not enabled, the function will return the earlier retrieved data. This is done to prevent too many API calls. Defaults to False.
  • rounding (int): Defines the number of decimal places to round the data to.
  • show_ticker_seperation (bool, optional): A boolean representing whether to show which tickers acquired data from FinancialModelingPrep and which tickers acquired data from YahooFinance.
  • show_columns (list[str], optional): A list of columns to include in the output. Valid columns are Open, High, Low, Close, Adj Close, Volume, Dividends, Return and Cumulative Return. Invalid column names are logged as warnings. If all provided columns are invalid the full dataset is returned. Defaults to None (all columns).

Raises:

ValueError: If an invalid value is specified for period.

Returns:

pandas.DataFrame: The historical data for the specified tickers.

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 Cumulative Return
2013 19.7918 20.0457 19.7857 20.0364 17.5889 2.23084e+08 0.108929 0 1
2014 28.205 28.2825 27.5525 27.595 24.734 1.65614e+08 0.461429 0.406225 1.40623
2015 26.7525 26.7575 26.205 26.315 23.9886 1.63649e+08 0.5075 -0.0301373 1.36385
2016 29.1625 29.3 28.8575 28.955 26.9824 1.22345e+08 0.5575 0.124804 1.53406
2017 42.63 42.6475 42.305 42.3075 40.0593 1.04e+08 0.615 0.484644 2.27753
2018 39.6325 39.84 39.12 39.435 37.9 1.40014e+08 0.705 -0.0539019 2.15477
2019 72.4825 73.42 72.38 73.4125 71.615 1.00806e+08 0.76 0.889578 4.0716
2020 134.08 134.74 131.72 132.69 130.559 9.91166e+07 0.8075 0.823067 7.4228
2021 178.09 179.23 177.26 177.57 175.795 6.40623e+07 0.865 0.346482 9.99467
2022 128.41 129.95 127.43 129.93 129.378 7.70342e+07 0.91 -0.264042 7.35566
2023 187.84 188.51 187.68 188.108 188.108 4.72009e+06 0.71 0.453941 10.6947

get_intraday_data

Returns intraday historical 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. - Volume: The volume for the period. - Return: The return for the period. - Cumulative Return: The cumulative return for the period.

Volatility is not included here. This is available as a dedicated calculation in the Risk module instead (e.g. toolkit.risk.get_volatility).

Keep in mind that this data is available for a shorter period. This means that the start date is ignored if the difference between the start and end date is bigger than the maximum 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.

Please note that this functionality is only available through Financial Modeling Prep. Therefore, an api_key is required to use this functionality.

Also known as: tick data, minute data, intraday price history.

Args:

  • period (str, optional): The intraday interval to fetch (e.g. “1min”, “5min”, “1hour”). Defaults to “1hour”.
  • return_column (str, optional): The column to use for the return calculation. Defaults to “Close”.
  • fill_nan (bool, optional): Defines whether to forward fill NaN values. Defaults to True.
  • rounding (int \| None, optional): Defines the number of decimal places to round the data to. Defaults to None.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pandas.DataFrame: The intraday data for the specified tickers.

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 Cumulative Return
2024-01-19 15:45 397.64 397.88 397.63 397.88 49202 0.0006 1.0266
2024-01-19 15:46 397.86 397.93 397.788 397.82 68913 -0.0002 1.0264
2024-01-19 15:47 397.81 397.97 397.76 397.78 62605 -0.0001 1.0263
2024-01-19 15:48 397.78 397.85 397.675 397.845 62146 0.0002 1.0265
2024-01-19 15:49 397.85 397.97 397.8 397.94 72700 0.0002 1.0267
2024-01-19 15:50 397.92 398.27 397.9 398.04 140754 0.0003 1.027
2024-01-19 15:51 398.04 398.15 397.96 398 122208 -0.0001 1.0269
2024-01-19 15:52 397.99 398.26 397.98 398.05 83546 0.0001 1.027
2024-01-19 15:53 398.04 398.12 397.98 398.09 85098 0.0001 1.0271
2024-01-19 15:54 398.1 398.52 398.03 398.45 187358 0.0009 1.028
2024-01-19 15:55 398.45 398.62 398.25 398.335 237902 -0.0003 1.0278
2024-01-19 15:56 398.33 398.44 398.3 398.415 149157 0.0002 1.028
2024-01-19 15:57 398.42 398.5 398.29 398.43 181074 0 1.028
2024-01-19 15:58 398.46 398.47 398.29 398.35 278802 -0.0002 1.0278
2024-01-19 15:59 398.35 398.66 398.22 398.66 586344 0.0008 1.0286

get_dividend_calendar

Obtain Dividend Calendars for any range of companies. It includes the following columns: - 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.

If a company does not pay any dividend, the function will mention that it was not able to find any dividend data for that company.

Also known as: dividend dates, ex-dividend date, dividend history.

Args:

  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: The earnings calendar for the specified tickers.

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 Yield Record Date Payment Date Declaration Date
2022-08-05 0.23 0.23 0.5443 2022-08-08 2022-08-11 2022-07-28
2022-11-04 0.23 0.23 0.6576 2022-11-07 2022-11-10 2022-10-27
2023-02-10 0.23 0.23 0.6092 2023-02-13 2023-02-16 2023-02-02
2023-05-12 0.24 0.24 0.5389 2023-05-15 2023-05-18 2023-05-04
2023-08-11 0.24 0.24 0.5287 2023-08-14 2023-08-17 2023-08-03
2023-11-10 0.24 0.24 0.5097 2023-11-13 2023-11-16 2023-11-02
2024-02-09 0.24 0.24 0.5083 2024-02-12 2024-02-15 2024-02-01
2024-05-10 0.25 0.25 0.5299 2024-05-13 2024-05-16 2024-05-02
2024-08-12 0.25 0.25 0.4505 2024-08-12 2024-08-15 2024-08-01
2024-11-08 0.25 0.25 0.4362 2024-11-11 2024-11-14 2024-10-31
2025-02-10 0.25 0.25 0.4393 2025-02-10 2025-02-13 2025-01-30
2025-05-12 0.26 0.26 0.4791 2025-05-12 2025-05-15 2025-05-01
2025-08-11 0.26 0.26 0.449 2025-08-11 2025-08-14 2025-07-31

get_esg_scores

ESG scores, which stands for Environmental, Social, and Governance scores, are a crucial metric used by investors and organizations to assess a company’s sustainability and ethical practices. These scores provide valuable insights into a company’s performance in three key areas:

  • Environmental (E): The environmental component evaluates a company’s impact on the planet and its efforts to mitigate environmental risks. It includes factors like carbon emissions, energy efficiency, water management, and waste reduction. A high environmental score indicates a company’s commitment to eco-friendly practices and reducing its ecological footprint.
  • Social (S): The social component focuses on how a company interacts with its employees, customers, suppliers, and the communities in which it operates. Key factors in the social score include labor practices, diversity and inclusion, human rights, product safety, and community engagement. A strong social score reflects a company’s dedication to fostering positive relationships and contributing positively to society.
  • Governance (G): Governance examines a company’s internal structures, policies, and leadership. It assesses aspects such as board independence, executive compensation, transparency, and the presence of anti-corruption measures. A high governance score signifies strong leadership and a commitment to maintaining high ethical standards and accountability

ESG scores provide investors with a holistic view of a company’s sustainability and ethical practices, allowing them to make more informed investment decisions. These scores are increasingly used to identify socially responsible investments and guide capital towards companies that prioritize long-term sustainability and responsible business practices. As the importance of ESG considerations continues to grow, companies are motivated to improve their ESG scores, not only for ethical reasons but also to attract investors who value sustainable and responsible business practices.

Also known as: environmental social governance, sustainability, ESG rating.

Args:

  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: The ESG scores for the specified tickers.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["MSFT", "TSLA", "AMZN"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2022-08-01", quarterly=False
)

esg_scores = toolkit.get_esg_scores()

esg_scores.xs("MSFT", level=1, axis=1)

Which returns:

date Environmental Score Social Score Governance Score ESG Score
2022 73.03 58.66 61.4 64.37
2023 72.89 58.16 60.65 63.9
2024 72.53 58.08 60.7 63.77
2025 71.85 57.64 59.62 63.04

get_market_risk_premium

Obtains the equity market risk premium by country – the country default spread plus the equity risk premium, following the approach popularized by Aswath Damodaran – which is widely used to calibrate country-specific costs of equity and discount rates in a multi-country setting.

Also known as: country risk premium, Damodaran equity risk premium.

Args:

  • overwrite (bool): Defines whether to overwrite the existing data.

Raises:

ValueError: If an API key is not defined for FinancialModelingPrep.

Returns:

pd.DataFrame: The market risk premium by country, including the continent, Country Risk Premium and Total Equity Risk Premium (both in percentage points).

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["AMZN", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

market_risk_premium = toolkit.get_market_risk_premium()

market_risk_premium.loc[['United States', 'Germany', 'Brazil']]

Which returns:

Country Continent Country Risk Premium Total Equity Risk Premium
United States North America 0.23 4.46
Germany Europe 0 4.23
Brazil South America 3.24 7.47

get_commitment_of_traders

Obtains the CFTC Commitment of Traders (COT) report for the tickers the Toolkit was initialized with. Published weekly by the U.S. Commodity Futures Trading Commission, it breaks down open interest in futures markets by trader type – Non-Commercial (large speculators), Commercial (hedgers) and Non-Reportable (small traders) – and is widely used to gauge positioning and sentiment in commodity, currency, interest rate and stock index futures markets.

Note that this data is only available for CFTC-tracked futures markets. Tickers without a corresponding futures contract (e.g. most individual equities) return no data.

Also known as: COT report, CFTC positioning data, speculator/hedger positioning.

Args:

  • overwrite (bool): Defines whether to overwrite the existing data.

Raises:

ValueError: If an API key is not defined for FinancialModelingPrep.

Returns:

pd.DataFrame: The Commitment of Traders report for the specified tickers.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["NG", "GC"], api_key="FINANCIAL_MODELING_PREP_KEY")

commitment_of_traders = toolkit.get_commitment_of_traders()

commitment_of_traders.xs("NG", level=1, axis=1)[
    ["Open Interest", "Non-Commercial Long", "Non-Commercial Short", "Commercial Long", "Commercial Short"]
].tail()

Which returns:

date Open Interest Non-Commercial Long Non-Commercial Short Commercial Long Commercial Short
2024-01-30 00:00:00 1471807 279539 382722 526952 450698
2024-02-06 00:00:00 1533041 301020 415251 539246 456560
2024-02-13 00:00:00 1554063 334504 471061 552780 453300
2024-02-20 00:00:00 1592460 356334 510206 567791 452247
2024-02-27 00:00:00 1500882 326328 467881 545380 433185

get_historical_statistics

Retrieve statistics about each ticker’s historical data. This is especially useful to understand why certain tickers might fluctuate more than others as it could be due to local regulations or the currency the instrument is denoted in. It returns:

  • Currency: The currency the instrument is denoted in.
  • Symbol: The symbol of the instrument.
  • Exchange Name: The name of the exchange the instrument is listed on.
  • Instrument Type: The type of instrument.
  • First Trade Date: The date the instrument was first traded.
  • Regular Market Time: The time the instrument is traded.
  • GMT Offset: The GMT offset.
  • Timezone: The timezone the instrument is traded in.
  • Exchange Timezone Name: The name of the timezone the instrument is traded in.

Also known as: key statistics over time, historical key metrics.

Returns: pd.DataFrame: A DataFrame containing the statistics for each ticker.

from financetoolkit import Toolkit

companies = Toolkit(["AMZN", "^HSI", "IWDA.AS", "0P0000Z8RO.T"])

companies.get_historical_statistics()

Which returns:

  AMZN ^HSI IWDA.AS 0P0000Z8RO.T
Currency USD HKD EUR JPY
Symbol AMZN ^HSI IWDA.AS 0P0000Z8RO.T
Exchange Name NMS HKG AMS JPX
Instrument Type EQUITY INDEX ETF MUTUALFUND
First Trade Date 1997-05-15 1986-12-31 2009-09-25 2018-01-04
Regular Market Time 2023-09-22 2023-09-22 2023-09-22 2023-09-21
GMT Offset -14400 28800 7200 32400
Timezone EDT HKT CEST JST
Exchange Timezone Name America/New_York Asia/Hong_Kong Europe/Amsterdam Asia/Tokyo

get_treasury_data

Retrieve daily, weekly, monthly, quarterly or yearly treasury data. This can be from FinancialModelingPrep or from YahooFinance. FinancialModelingPrep is by far a more extensive dataset containing daily data from 1 month to 30 years. YahooFinance only contains daily data for 5, 10 and 30 years but is a free alternative.

Also known as: US Treasury yields, yield curve, treasury rates.

Args:

  • period (str): The interval at which the treasury data should be returned - daily, weekly, monthly, quarterly, or yearly.
  • fill_nan (bool): Defines whether to forward fill NaN values. This defaults to True to prevent holes in the dataset. This is especially relevant for technical indicators.
  • risk_free_rate (str \| None, optional): The maturity to return as the risk free rate (‘13w’, ‘5y’, ‘10y’ or ‘30y’). Defaults to None, which uses the maturity set on the Toolkit.
  • divide_ohlc_by (int \| float \| None, optional): A value to divide the yields by. Treasury yields are published in percent, so this defaults to 100 to return decimals.
  • rounding (int \| None, optional): The number of decimals to round the results to. Defaults to None, which uses the rounding set on the Toolkit.
  • show_errors (bool, optional): Whether to report retrieval errors. Defaults to False.
  • enforce_source (str \| None, optional): Forces this specific call to use a given source, either “FinancialModelingPrep” or “YahooFinance”. This takes precedence over the source set on the Toolkit itself. Defaults to None, which falls back to the Toolkit’s own enforce_source.

Returns:

pd.DataFrame: A DataFrame containing the treasury data.

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

get_exchange_rates

This functionality looks at the exchange rates between the currency of the historical data and the currency of the financial statements. Given that these can deviate from each other, e.g. the historical data is in USD but the financial statements are in EUR, it is important to adjust for this. This is especially relevant for models that use the historical data and the financial statements.

This function therefore shows the exchange rates that are used to convert the financial statements to the currency of the historical data. The historical market data is quote currency and the financial statements are base currency.

Note that you can get currency data from any currency as well by supplying the currency as a ticker. For example, if you want to get the exchange rates between USD and EUR you can use USDEUR=X as a ticker.

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 enforce_source to “YahooFinance”. If data collection fails from FinancialModelingPrep it automatically reverts back to YahooFinance.

Also known as: currency exchange, FX rates, foreign exchange rates.

Args:

  • period (str): The interval at which the historical data should be returned - daily, weekly, monthly, quarterly, or yearly. Defaults to “daily”.
  • return_column (str): The column to use for the return calculation. Defaults to “Adj Close”.
  • fill_nan (bool): Defines whether to forward fill NaN values. This defaults to True to prevent holes in the dataset. This is especially relevant for technical indicators.
  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • show_ticker_seperation (bool, optional): A boolean representing whether to show which tickers acquired data from FinancialModelingPrep and which tickers acquired data from YahooFinance.

Raises:

ValueError: If an invalid value is specified for period.

Returns:

pandas.DataFrame: The historical exchange rate data.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit("ASML", api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.get_exchange_rates(period="monthly")

Which returns:

Date Open High Low Close Adj Close Volume Return Cumulative Return
2023-03 1.0905 1.0926 1.0861 1.0905 1.0905 0 0.0277 0.7896
2023-04 1.1011 1.1037 1.0963 1.0969 1.0969 131812 0.0059 0.7943
2023-05 1.0693 1.0771 1.066 1.076 1.0733 162069 -0.0215 0.7772
2023-06 1.09 1.09 1.08 1.09 1.0868 0 0.0126 0.787
2023-07 1.0996 1.102 1.0952 1.1007 1.1024 183278 0.0144 0.7983
2023-08 1.0842 1.0882 1.077 1.0796 1.09 171695 -0.0112 0.7893
2023-09 1.06 1.06 1.06 1.06 1.06 0 -0.0275 0.7676
2023-10 1.0614 1.0674 1.0556 1.0578 1.0615 184667 0.0014 0.7686
2023-11 1.0973 1.0984 1.0878 1.0892 1.0974 173646 0.0338 0.7946
2023-12 1.088 1.0898 1.0848 1.0871 1.0871 90494 -0.0094 0.7872

get_balance_sheet_statement

Retrieves the balance sheet statement data for the specified tickers. The balance sheet statement is a financial statement that provides a snapshot of a company’s financial position at a specific point in time. It shows the company’s assets, liabilities, and shareholders’ equity. The balance sheet statement is divided into three main sections:

  • Assets: Assets are resources owned by the company that have economic value and can be used to generate revenue. Assets are typically divided into current assets and non-current assets.
  • Liabilities: Liabilities are obligations that the company owes to external parties. Liabilities are also divided into current liabilities and non-current liabilities.
  • Shareholders’ Equity: Shareholders’ equity represents the company’s net worth or book value. It is calculated as the difference between the company’s assets and liabilities.

Note that the balance sheet statement is a financial statement that provides a snapshot of a company’s financial position at a specific point in time. Therefore, trailing results are not available for this statement.

Also known as: assets, liabilities, shareholders equity, financial position.

Args:

  • enforce_source (str \| None, optional): Forces this specific call to use a given source, either “FinancialModelingPrep” or “YahooFinance”. This takes precedence over the source set on the Toolkit itself, so one instance can pull historical data from the free Yahoo Finance source while still using a FinancialModelingPrep key for the financial statements (or the other way around). Defaults to None, which falls back to the Toolkit’s own enforce_source.
  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • growth (bool): Defines whether to return the growth of the data.
  • lag (int \| str): Defines the number of periods to lag the growth data by. E.g. when selecting 4 with quarterly data, the TTM is calculated.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: A pandas DataFrame with the retrieved balance sheet statement data.

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

get_income_statement

Retrieves the income statement data for the specified tickers. The income statement is a financial statement that shows a company’s revenues and expenses over a specific period. It is used to calculate a company’s net income.

The income statement is a financial statement that shows a company’s revenues and expenses over a specific period. Therefore, trailing results are available for this statement.

Also known as: profit and loss, revenue, net income, earnings, P&L statement.

Args:

  • enforce_source (str \| None, optional): Forces this specific call to use a given source, either “FinancialModelingPrep” or “YahooFinance”. This takes precedence over the source set on the Toolkit itself, so one instance can pull historical data from the free Yahoo Finance source while still using a FinancialModelingPrep key for the financial statements (or the other way around). Defaults to None, which falls back to the Toolkit’s own enforce_source.
  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • growth (bool): Defines whether to return the growth of the data.
  • lag (int \| str): Defines the number of periods to lag the growth data by.
  • trailing (int): Defines whether to select a trailing period. E.g. when selecting 4 with quarterly data, the TTM is calculated.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: A pandas DataFrame with the retrieved income statement data.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["TSLA", "MU"], api_key="FINANCIAL_MODELING_PREP_KEY", quarterly=True, start_date='2022-05-01')

income_sheet_statements = toolkit.get_income_statement()

income_sheet_statements.loc['TSLA']

Which returns:

  2022Q2 2022Q3 2022Q4 2023Q1 2023Q2
Revenue 1.6934e+10 2.1454e+10 2.4318e+10 2.3329e+10 2.4927e+10
Cost of Goods Sold 1.27e+10 1.6072e+10 1.8541e+10 1.8818e+10 2.0394e+10
Gross Profit 4.234e+09 5.382e+09 5.777e+09 4.511e+09 4.533e+09
Gross Profit Ratio 0.25003 0.250862 0.237561 0.193364 0.181851
Research and Development Expenses 6.67e+08 7.33e+08 8.1e+08 7.71e+08 9.43e+08
General and Administrative Expenses 0 0 0 0 0
Selling and Marketing Expenses 0 0 0 0 0
Selling, General and Administrative Expenses 9.61e+08 9.61e+08 1.032e+09 1.076e+09 1.191e+09
Other Expenses 2.8e+07 -8.5e+07 -4.2e+07 -4.8e+07 3.28e+08
Operating Expenses 1.628e+09 1.694e+09 1.842e+09 1.847e+09 2.134e+09
Cost and Expenses 1.4328e+10 1.7766e+10 2.0383e+10 2.0665e+10 2.2528e+10
Interest Income 2.6e+07 8.6e+07 1.57e+08 2.13e+08 2.38e+08
Interest Expense 4.4e+07 5.3e+07 3.3e+07 2.9e+07 2.8e+07
Depreciation and Amortization 1.118e+09 9.57e+08 1.138e+09 1.211e+09 1.72e+09
EBITDA 3.582e+09 4.645e+09 5.039e+09 3.875e+09 4.119e+09
EBITDA Ratio 0.211527 0.21651 0.207213 0.166102 0.165243
Operating Income 2.464e+09 3.688e+09 3.901e+09 2.664e+09 2.399e+09
Operating Income Ratio 0.145506 0.171903 0.160416 0.114193 0.096241
Total Other Income 1e+07 -5.2e+07 8.2e+07 1.36e+08 5.38e+08
Income Before Tax 2.474e+09 3.636e+09 3.983e+09 2.8e+09 2.937e+09
Income Before Tax Ratio 0.146097 0.169479 0.163788 0.120022 0.117824
Income Tax Expense 2.05e+08 3.05e+08 2.76e+08 2.61e+08 3.23e+08
Net Income 2.259e+09 3.292e+09 3.687e+09 2.513e+09 2.703e+09
Net Income Ratio 0.1334 0.153445 0.151616 0.10772 0.108437
EPS 0.73 1.05 1.18 0.8 0.85
EPS Diluted 0.65 0.95 1.07 0.73 0.78
Weighted Average Shares 3.111e+09 3.146e+09 3.16e+09 3.166e+09 3.171e+09
Weighted Average Shares Diluted 3.465e+09 3.468e+09 3.471e+09 3.468e+09 3.478e+09

get_cash_flow_statement

Retrieves the cash flow statement data for the specified tickers. The cash flow statement is a financial statement that shows how changes in balance sheet accounts and income affect cash and cash equivalents. It breaks the analysis down to operating, investing and financing activities.

The cash flow statement is a financial statement that shows how changes in balance sheet accounts and income affect cash and cash equivalents. Therefore, trailing results are available for this statement.

Also known as: operating cash flow, investing activities, financing activities.

Args:

  • enforce_source (str \| None, optional): Forces this specific call to use a given source, either “FinancialModelingPrep” or “YahooFinance”. This takes precedence over the source set on the Toolkit itself, so one instance can pull historical data from the free Yahoo Finance source while still using a FinancialModelingPrep key for the financial statements (or the other way around). Defaults to None, which falls back to the Toolkit’s own enforce_source.
  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • growth (bool): Defines whether to return the growth of the data.
  • lag (int \| str): Defines the number of periods to lag the growth data by.
  • trailing (int): Defines whether to select a trailing period. E.g. when selecting 4 with quarterly data, the TTM is calculated.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: A pandas DataFrame with the retrieved cash flow statement data.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["MU", "AMZN"], api_key="FINANCIAL_MODELING_PREP_KEY", quarterly=True, start_date='2022-09-01')

cash_flow_statements = toolkit.get_cash_flow_statement()

cash_flow_statements.loc['AMZN']

Which returns:

  2022Q3 2022Q4 2023Q1 2023Q2
Net Income 2.872e+09 2.78e+08 3.172e+09 6.75e+09
Depreciation and Amortization 1.0204e+10 1.2685e+10 1.1123e+10 1.1589e+10
Deferred Income Tax -8.25e+08 -3.367e+09 -4.72e+08 -2.744e+09
Stock Based Compensation 5.556e+09 5.606e+09 4.748e+09 7.127e+09
Change in Working Capital -5.254e+09 1.0526e+10 -1.4317e+10 -6.293e+09
Accounts Receivables -4.794e+09 -8.788e+09 1.521e+09 -5.167e+09
Inventory 7.32e+08 3.18e+09 3.71e+08 -2.373e+09
Accounts Payables -1.226e+09 9.852e+09 -1.1264e+10 3.029e+09
Other Working Capital 3.4e+07 6.282e+09 -4.945e+09 -1.782e+09
Other Non Cash Items -1.149e+09 3.445e+09 5.34e+08 4.7e+07
Cash Flow from Operations 1.1404e+10 2.9173e+10 4.788e+09 1.6476e+10
Property, Plant and Equipment -1.6378e+10 -1.6592e+10 -1.4207e+10 -1.1455e+10
Acquisitions -8.85e+08 -8.31e+08 -3.513e+09 -3.16e+08
Purchases of Investments -2.39e+08 -2.33e+08 -3.38e+08 -4.96e+08
Sales of Investments 5.57e+08 5.683e+09 1.115e+09 1.551e+09
Other Investing Activities 1.337e+09 1.152e+09 1.137e+09 1.043e+09
Cash Flow from Investing -1.5608e+10 -1.0821e+10 -1.5806e+10 -9.673e+09
Debt Repayment -9.429e+09 -1.8756e+10 -6.369e+09 -1.0861e+10
Common Stock Issued 0 0 0 0
Common Stock Purchased 0 6e+09 0 0
Dividends Paid 0 0 0 0
Other Financing Activities 1.2445e+10 1.2842e+10 1.2723e+10 4.322e+09
Cash Flow from Financing 3.016e+09 8.6e+07 6.354e+09 -6.539e+09
Forex Changes on Cash -1.334e+09 6.37e+08 1.45e+08 6.9e+07
Net Change in Cash -2.522e+09 1.9075e+10 -4.519e+09 3.33e+08
Cash End of Period 3.5178e+10 5.4253e+10 4.9734e+10 5.0067e+10
Cash Beginning of Period 3.77e+10 3.5178e+10 5.4253e+10 4.9734e+10
Operating Cash Flow 1.1404e+10 2.9173e+10 4.788e+09 1.6476e+10
Capital Expenditure -1.6378e+10 -1.6592e+10 -1.4207e+10 -1.1455e+10
Free Cash Flow -4.974e+09 1.2581e+10 -9.419e+09 5.021e+09

get_statistics_statement

Retrieves the balance, cash and income statistics for the company(s) from the specified source.

Note that this also obtains the balance sheet statement at the same time given that it’s the same API call. This is done to reduce the number of API calls to FinancialModelingPrep.

Also known as: key stats, shares outstanding, float data.

Args:

  • enforce_source (str \| None, optional): Forces this specific call to use a given source, either “FinancialModelingPrep” or “YahooFinance”. This takes precedence over the source set on the Toolkit itself, so one instance can pull historical data from the free Yahoo Finance source while still using a FinancialModelingPrep key for the financial statements (or the other way around). Defaults to None, which falls back to the Toolkit’s own enforce_source.
  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • show_columns (list[str] \| None): A list of column names to keep in the result. Invalid names are reported and ignored. Defaults to None, which keeps every column.

Returns:

pd.DataFrame: A pandas DataFrame with the retrieved statistics statement data.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit("TSLA", api_key="FINANCIAL_MODELING_PREP_KEY", quarterly=True, start_date='2023-05-01')

toolkit.get_statistics_statement()

Which returns:

  2023Q2
Reported Currency USD
CIK ID 1318605
Filling Date 2023-07-24
Accepted Date 2023-07-21 18:08:29
Calendar Year 2023
Period Q2
SEC Link https://www.sec.gov/Archives/edgar/data/1318605/000095017023033872/0000950170-23-033872-index.htm
Document Link https://www.sec.gov/Archives/edgar/data/1318605/000095017023033872/tsla-20230630.htm

get_normalization_files

Copies the normalization files to a folder based on path. By default, this is the path of the ‘Downloads’ folder.

This function is relevant if you want to supply your own datasets. See for a proper guide the following notebook: https://www.jeroenbouma.com/projects/financetoolkit/external-datasets

Args:

  • path (str, optional): The path where to save the files to.

Returns:

Three csv files saved to the desired location.


get_cache_contents

Show what the cache currently holds, grouped by source and dataset.

The cache stores data per source, per dataset and per entity (a ticker, a country, a series identifier), which makes it possible to remove part of it rather than all of it. This method is the counterpart to clear_cache: it shows what is there so that removing something is an informed decision.

The cache is inspected regardless of whether this Toolkit was created with use_cached_data enabled, so a cache filled by an earlier session can always be reviewed.

Returns: pd.DataFrame: One row per source and dataset combination, with the number of entities, the number of stored entries and when they were written. An empty DataFrame when the cache holds nothing.

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY", use_cached_data=True)

toolkit.get_historical_data()

toolkit.get_cache_contents()

Which returns:

source dataset entities entries oldest_write newest_write
market historical 3 3 2026-08-06 14:02:11 2026-08-06 14:02:12

clear_cache

Remove cached data, either all of it or only the part you specify.

The Finance Toolkit never clears the cache on its own. A cache can represent a large amount of downloaded data and a meaningful part of an API quota, so discarding it is always an explicit action. Even a change in the cache’s own internal structure only produces a warning pointing at this method rather than removing anything.

Because the cache is stored per source, per dataset and per entity, removal can be narrowed instead of wholesale. Clearing a single stale ticker, or everything retrieved from one provider, leaves the rest of the cache intact.

Args:

  • source (str \| None): Only remove data from this source, for example “FinancialModelingPrep”, “YahooFinance”, “OECD”, “FRED” or “GlobalMacroDatabase”. These match the names used by enforce_source. Defaults to None, which matches every source.
  • dataset (str \| None): Only remove this dataset within the source, for example “historical”, “intraday” or “statements”. Defaults to None, which matches every dataset.
  • ticker (str \| None): Only remove this entity, for example “AAPL” or a country code for macroeconomic data. Defaults to None, which matches every entity.
  • confirm (bool): Required to be True when no source, dataset or ticker is given, since that removes the entire cache. Defaults to False.

Raises:

ValueError: If the whole cache would be removed without confirm being set.

Returns:

int: The number of stored entries that were removed.

As an example:

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY", use_cached_data=True)

# Remove only the price history of a single ticker
toolkit.clear_cache(source="YahooFinance", ticker="AAPL")

# Remove everything retrieved from the OECD
toolkit.clear_cache(source=policy_model.OECD)

# Remove the entire cache
toolkit.clear_cache(confirm=True)