Releases: JerBouma/FinanceToolkit
FinanceToolkit v1.6.0
I did a new release last week but for everything I've added in it made sense to do another full release. This release includes new models and ESG scores and a lot of the code has been refactored, many new tests have been added and a lot of bug fixes went in. For example, @brianrasmusson noticed in #76 that Apple's data was a bit out of whack. This has now been resolved. I've also added in a lot pretty graphs into the README to show what you can really do with the data, e.g. see this one on the Value of Risk:
It is now possible to view ESG Scores for any range of companies with get_esg_scores
:

Next to that, within the Models
module, two new models are included. These are Altman Z-Score and Piotroski F-score. The former calculates the chance of bankruptcy based on a set of criteria:

The latter scores the financial strength of the company:

Furthermore, I've added a performance measurement which shows the period growth rate that has occurred (taking out fluctuations over time as shown in the plot below):

Other than that, I've extended the examples and gave more explanation how to add in your own datasets.
FinanceToolkit v1.5.0
Introducing the power of Threading into the FinanceToolkit. Update now via pip install financetoolkit -U
.
As an example, obtaining the balance sheet statements of 345 different companies for the period 1983 to 2023 takes less than 40 seconds. This makes data collection extremely quick and makes the FinanceToolkit an invaluable tool for any financial specialist.

Next to that, given that there are rate limits, these are correctly dealt with through sleep timers. If you have a subscription from FinancialModelingPrep that limits you to 300 requests per minute, the FinanceToolkit will deal with this and will wait until it can make requests again.
Furthermore, if some of the historical data is not available from FinancialModelingPrep it will try YahooFinance instead making sure that you don't lose vital data for your calculations.

Of course, all of this extends in all functionality. E.g. see Jensen's Alpha for all 345 tickers on a quarterly basis. Given that the calculations are done by the FinanceToolkit, this takes just a few seconds.

It's time to level up. 🚀
FinanceToolkit v1.4.1
I've added in the Dividend Calendar which can be shown by get_dividend_calendar()
:
from financetoolkit import Toolkit
API_KEY = "FINANCIAL_MODELING_PREP_KEY"
# Initialize the Toolkit with company tickers
companies = Toolkit(
["AAPL", "MSFT", "GOOGL", "AMZN"], api_key=API_KEY, start_date="2005-01-01"
)
companies.get_dividend_calendar()
Which returns:

Next to that, this release introduces historical data from FinancialModelingPrep. This is enabled by default when you provide an API key but can be changed back by setting historical_source
to "YahooFinance"
when initialising the Toolkit. When you don't provide an API key it defaults to Yahoo Finance.
This is done to prevent rate limits from becoming an issue when you have purchased a FinancialModelingPrep subscription given that Yahoo Finance will rate limit at some point. It of course makes little sense that you are paying and still get rate limited!
E.g. the following will net you the same result:
from financetoolkit import Toolkit
API_KEY = "FINANCIAL_MODELING_PREP_KEY"
# Use FinancialModelingPrep to obtain Historical Data
companies = Toolkit(
["AAPL", "MSFT", "GOOGL", "AMZN"], api_key=API_KEY, start_date="2005-01-01"
)
companies.get_historical_data()
# Use Yahoo Finance to obtain Historical Data even though you set a FinancialModelingPrep API Key
companies = Toolkit(
["AAPL", "MSFT", "GOOGL", "AMZN"], api_key=API_KEY, start_date="2005-01-01", historical_source='YahooFinance'
)
companies.get_historical_data()
# Use Yahoo Finance to obtain Historical Data without needing to set an API Key
companies = Toolkit(
["AAPL", "MSFT", "GOOGL", "AMZN"], start_date="2005-01-01"
)
companies.get_historical_data()
Which returns:

FinanceToolkit v1.4.0
This releases includes the Fama and French 5-factor model. Something I've been wanting to add into the Finance Toolkit for some time now. This allows you to understand the explanatory power of the following factors on each ticker included in the Toolkit on any period, let it be yearly, quarterly, monthly or weekly:
- Market Risk Premium (Mkt-RF): Represents the additional return that investors expect to earn for taking
on the risk of investing in the overall market as opposed to a risk-free asset. - Size Premium (SMB): Reflects the historical excess return of small-cap stocks over large-cap stocks.
- Value Premium (HML): Captures the historical excess return of value stocks over growth stocks.
- Profitability (RMW): Measures the historical excess return of high profitability stocks over
low profitability stocks. - Investment (CMA): Quantifies the historical excess return of low investment stocks over
high investment stocks.
I've added correlation functions that help you understand how factors correlate with each other over time. For example, the following GIF is created with data from the function performance.get_factor_correlations
.
Next to that, you can perform Linear Regressions on each factor and each factor combination to discover sensitivities of individual assets to each factor (this is not only limited to companies but can also be currencies, commodities, ETFs and more):
from financetoolkit import Toolkit
# Initialize the Finance Toolkit
companies = Toolkit(
tickers=["MSFT", 'AAPL', 'TSLA', 'GOOG', "AMZN", 'MU'], api_key=FMP_KEY, quarterly=False
)
companies.performance.get_fama_and_french_model()
Which returns regression coefficients for all factors for each individual stock:

You have the option to show both the results from a simple linear regression (which is defined as Excess Return = Intercept + Slope * Factor Value + Residuals
) or a multi linear regression (which is defined as Excess Return = Intercept + Beta1 * Mkt-RF + Beta2 * SMB + Beta3 * HML + Beta4 * RMW + Beta5 * CMA + Residuals
) the latter is the default. E.g. you can show the explanatory power of each individual factor for example for Microsoft as follows:
from financetoolkit import Toolkit
# Initialize the Finance Toolkit
companies = Toolkit(
tickers=["MSFT"], api_key=FREE_FMP_KEY, quarterly=False
)
result = companies.performance.get_fama_and_french_model(period='quarterly', method='simple')
result['MSFT'].xs('R Squared', level=1, axis=1).plot(figsize=(15, 5), title=f'Factor Sensitivities of Microsoft')
Which returns the following:
FinanceToolkit v1.3.10
This releases features a couple of Quality of Life improvements and some bug fixes:
- A user noticed that for some tickers, e.g. currencies, it returned an error since the index wasn't matched up correctly. This has now been corrected by only keeping the first duplicate if any are found. The issue here was that the same index was reported twice (e.g. 2020-05-06 being reported twice in the index) which will cause an issue if you try to combine such a DataFrame with other DataFrames.
- For all functionality, if the ticker doesn't correspond to the correct type, the Toolkit will mention this to you. E.g. if you would try to obtain an Income Statement from a ticker such as "^GSPC" (which is the S&P 500 index) it will return a well-written error. This also applies to if a subset of your tickers is not marked as an Equity.
If you didn't know, any type of asset class works with the Finance Toolkit (e.g. Equities, Currencies, Cryptocurrencies, ETFs, Mutual Funds, Indices, Money Markets, Commodities and more) which also allows you to obtain detailed calculations such as the Conditional Value at Risk (cVaR).

FinanceToolkit v1.3.9
This release mainly introduces fixes to existing functionality, most importantly the calculation of trailing ratios. The timing of the trailing ratios was a bit off as it took to the sum of the periods after calculation instead of before. This has now been fixed.
If you didn't know, you can calculate trailing ratios (e.g. revenue TTM, price-to-earnings TTM) and much more by using the trailing
parameter. This parameter represents the amount of periods you wish to combine to calculate the trailing ratio, e.g. if you use quarterly=True
in the Toolkit initialisation and then set trailing=4
for any ratio, you are able to calculate any TTM ratio.

The same can be done for a financial statement.

I also noticed that the days used for calculating Efficiency Ratios was set to 365 by default. This is fine for annual calculations but for quarterly calculations it should be divided by 4. This is now done automatically.

FinanceToolkit v1.3.8
FinanceToolkit v1.3.7
FinanceToolkit v1.3.6
This version introduces ISIN support. If you submit an ISIN, it will find the relevant symbol and use that instead. It will also mention to what symbol it made the conversion so it is clear what ticker to look at. I've also added some dependencies, mostly a clean-up (I was struggling with getting SciPy to work, now this is built in with Pandas). Next to that, I've added the Finance Database as a dependency as in the future the Finance Toolkit will feature functionality from this database.

FinanceToolkit v1.3.5
This is a minor release getting some bugfixes in and making the code a bit more robust. Less errors should now occur when you do not have the correct API key set and someone noticed that if you call the Statistics functionality before anything else it returns an error. This is now fixed.
If you feel like any functionality is missing, definitely let me know and we can start adding them in!