Financetoolkit

Latest version: v1.9.9

Safety actively analyzes 688674 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 13

1.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.

<img width="1150" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/004fdead-137b-4951-9cbf-6f2b16964903">

**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.

<img width="1150" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/53c90893-abc1-447d-b659-6abad5ffdf9a">

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.**

<img width="1150" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/73f6c321-f879-4dba-bcff-b50fe7c45410">

It's time to level up. 🚀

1.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:

<img width="511" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/47bf0d2e-7f9c-44aa-bd33-142ad62ad712">

**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](https://intelligence.financialmodelingprep.com/pricing-plans?couponCode=jeroen) 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:

<img width="686" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/71e4410d-cc3c-426b-892c-392740980112">

1.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`.

![Factor Correlations 10-Year Period Finance Toolkit](https://github.com/JerBouma/FinanceToolkit/assets/46355364/cc9fab4a-3402-4e4e-a69c-a3a0917c825f)

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):

python
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:

<img width="1414" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/b4a07c46-cbfe-438d-a19d-21f6b1cb464c">

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:

python
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:

![image](https://github.com/JerBouma/FinanceToolkit/assets/46355364/3efd84ef-825a-476a-a9c8-66e1934a5579)

1.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).

<img width="947" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/e44dcdc6-ec1b-4640-a83e-cfdfc3ed6e9b">

1.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.

<img width="1148" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/525aacd7-51b5-4550-9502-71a1f343b291">

The same can be done for a financial statement.

<img width="1149" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/97fb89e2-0033-4dad-892b-56d965435f0c">

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.

<img width="1149" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/f666e658-f47b-47b6-8e29-e2d7b9a62890">

1.3.8

A user of the Finance Toolkit reported some issues with the dividends. Noticed it was unfortunately broken. This has now been fixed. Other than that, I've updated a couple of docstrings.

![image](https://github.com/JerBouma/FinanceToolkit/assets/46355364/4e24d31d-1ed7-4ae4-a53d-dbdb904ea4de)

Page 4 of 13

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.