Financetoolkit

Latest version: v1.9.9

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

Scan your dependencies

Page 3 of 13

1.7.2

Added **a lot** more economic metrics (over 50) into the Finance Toolkit, find the total list [here](https://github.com/JerBouma/FinanceToolkit?tab=readme-ov-file#key-economic-indicators). For example, get insights into how the United States Government spend their income:

python

from financetoolkit import Economics

economics = Economics()

central_government_spending = economics.get_central_government_spending()

central_government_spending['United States']


Which returns:

| | General Public Services | Defence | Public Order and Safety | Economic Affairs | Environmental Protection | Housing and Community Amenities | Health | Recreation, Culture and Religion | Education | Social Protection |
|:-----|--------------------------:|----------:|--------------------------:|-------------------:|---------------------------:|----------------------------------:|---------:|-----------------------------------:|------------:|--------------------:|
| 2007 | 0.1578 | 0.186 | 0.0148 | 0.0578 | 0 | 0.0192 | 0.2486 | 0.0015 | 0.0222 | 0.2921 |
| 2008 | 0.1392 | 0.1861 | 0.0148 | 0.069 | 0 | 0.0188 | 0.2369 | 0.0014 | 0.0221 | 0.3117 |
| 2009 | 0.1198 | 0.1772 | 0.0148 | 0.0639 | 0 | 0.0406 | 0.2417 | 0.0014 | 0.028 | 0.3127 |
| 2010 | 0.1211 | 0.1759 | 0.0148 | 0.0585 | 0 | 0.0309 | 0.2416 | 0.0015 | 0.0346 | 0.3211 |
| 2011 | 0.1324 | 0.1754 | 0.0149 | 0.0562 | 0 | 0.0271 | 0.2416 | 0.0014 | 0.0337 | 0.3173 |
| 2012 | 0.1348 | 0.173 | 0.0154 | 0.056 | 0 | 0.0216 | 0.2491 | 0.0014 | 0.0296 | 0.3191 |
| 2013 | 0.1333 | 0.162 | 0.0145 | 0.055 | 0 | 0.0172 | 0.2589 | 0.0013 | 0.0281 | 0.3296 |
| 2014 | 0.135 | 0.1525 | 0.0143 | 0.0524 | 0 | 0.0168 | 0.2765 | 0.0013 | 0.0269 | 0.3244 |
| 2015 | 0.1294 | 0.1461 | 0.0141 | 0.0473 | 0 | 0.0161 | 0.2919 | 0.0012 | 0.026 | 0.3279 |
| 2016 | 0.1321 | 0.141 | 0.0141 | 0.0526 | 0 | 0.0156 | 0.2952 | 0.0013 | 0.0244 | 0.3238 |
| 2017 | 0.1325 | 0.1408 | 0.0137 | 0.0526 | 0 | 0.0171 | 0.2961 | 0.0013 | 0.0233 | 0.3226 |
| 2018 | 0.1407 | 0.1427 | 0.0135 | 0.0519 | 0 | 0.014 | 0.2967 | 0.0012 | 0.0226 | 0.3165 |
| 2019 | 0.1417 | 0.1461 | 0.013 | 0.052 | 0 | 0.0133 | 0.2971 | 0.0012 | 0.021 | 0.3147 |

Or plotted:

![image](https://github.com/JerBouma/FinanceToolkit/assets/46355364/cf262e29-b822-49df-9731-73c87106e8a1)

Or see the Income Inequality in the Netherlands:

python
from financetoolkit import Toolkit

toolkit = Toolkit("MSFT")

income_inequality = toolkit.economics.get_income_inequality()

income_inequality['Netherlands']


Which returns:

| | Gini Coefficient | P90/P10 | P90/P50 | P50/P10 | Palma Ratio | S80/S20 |
|:-----|-------------------:|----------:|----------:|----------:|--------------:|----------:|
| 2013 | 0.287 | 3.4 | 1.8 | 1.9 | 1.05 | 4.3 |
| 2014 | 0.305 | 3.4 | 1.8 | 1.9 | 1.16 | 4.6 |
| 2015 | 0.305 | 3.4 | 1.8 | 1.9 | 1.06 | 4.4 |
| 2016 | 0.292 | 3.4 | 1.8 | 1.9 | 1.07 | 4.4 |
| 2017 | 0.298 | 3.4 | 1.8 | 1.9 | 1.11 | 4.5 |
| 2018 | 0.295 | 3.3 | 1.8 | 1.9 | 1.09 | 4.4 |
| 2019 | 0.312 | 3.4 | 1.8 | 1.9 | 1.21 | 4.7 |
| 2020 | 0.295 | 3.3 | 1.8 | 1.9 | 1.09 | 4.4 |
| 2021 | 0.297 | 3.4 | 1.8 | 1.9 | 1.1 | 4.5 |

Or plotted:

![image](https://github.com/JerBouma/FinanceToolkit/assets/46355364/980aa4f3-7e9e-405a-bbe1-118b9b9aeb93)

**And so much more!**

1.7.1

In addition to the many new [Economics indicators in the previous release](https://github.com/JerBouma/FinanceToolkit/releases/tag/v1.7.0), I've added some new key economic rates.

![MarketExpectationsFinanceToolkit](https://github.com/JerBouma/FinanceToolkit/assets/46355364/319df3b6-fb4e-438f-8e50-9786481caa21)

I've added in the European Central Banks which include:

- The main refinancing operations (MRO) rate is the interest rate banks pay when they borrow money from the ECB for one week. When they do this, they have to provide collateral to guarantee that the money will be paid back.
- The marginal lending facility rate is the interest rate banks pay when they borrow from the ECB overnight. When they do this, they have to provide collateral, for example securities, to guarantee that the money will be paid back.
- The deposit facility rate which is one of the three interest rates the ECB sets every six weeks as part of its monetary policy. The rate defines the interest banks receive for depositing money with the central bank overnight.

These can be shown by using:

python
from financetoolkit import Economics

economics = Economics(start_date='2000-01-01')

economics.get_european_central_bank_rates()


Which returns (when plotted):

![image](https://github.com/JerBouma/FinanceToolkit/assets/46355364/faf9318e-ed12-4b81-a211-2982a067c0e3)

I've also added in the Federal Funds rates which include:

- The effective federal funds rate (EFFR) which is calculated as a volume-weighted median of overnight federal funds transactions reported in the FR 2420 Report of Selected Money Market Rates.
- The overnight bank funding rate (OBFR) which is calculated as a volume-weighted median of overnight federal funds transactions, Eurodollar transactions, and the domestic deposits reported as “Selected Deposits” in the FR 2420 Report.
- The TGCR which is calculated as a volume-weighted median of transaction-level tri-party repo data collected from the Bank of New York Mellon.
- The BGCR which is calculated as a volume-weighted median of transaction-level tri-party repo data collected from the Bank of New York Mellon as well as GCF Repo transaction data obtained from the U.S. Department of the Treasury’s Office of Financial Research (OFR).
- The SOFR which is calculated as a volume-weighted median of transaction-level tri-party repo data collected from the Bank of New York Mellon as well as GCF Repo transaction data and data on bilateral Treasury repo transactions cleared through FICC's DVP service, which are obtained from the U.S. Department of the Treasury’s Office of Financial Research (OFR).

These can be shown by using (and defining the rate):

python
from financetoolkit import Economics

economics = Economics(start_date='2016-01-01')

Effective Federal Funds Rate
economics.get_federal_reserve_rates(rate='EFFR')

Secured Overnight Financing Rate
economics.get_federal_reserve_rates(rate='SOFR')


Which returns (when plotted):

![image](https://github.com/JerBouma/FinanceToolkit/assets/46355364/cdac837e-89bb-4261-aac9-afa4cc617e75)

![image](https://github.com/JerBouma/FinanceToolkit/assets/46355364/0f820fcb-2f0f-40c4-a7a9-c1fa33f0ebc2)

1.7.0

This release features an entirely new module called `Economics`. This is meant to collect key economic indicators such as the Gross Domestic Product (GDP), Consumer Price Index (CPI) and Long and Short Term Interest Rates for 60+ countries. **Find a complete overview [here](https://www.jeroenbouma.com/projects/financetoolkit/docs/economics)**. This module can be called via the Toolkit:

python
from financetoolkit import Toolkit

companies = Toolkit(tickers=["AAPL", "TSLA"], api_key="FMP_KEY")

companies.economics.get_house_prices()


But also as standalone module (given that it doesn't require a company ticker):

python
from financetoolkit import Economics

economics = Economics()

economics.get_house_prices()


Both return the same dataset:

| | Australia | Austria | Belgium | Brazil | Bulgaria | Canada | Chile | China | Colombia | Croatia | Czech Republic | Denmark | EA | Estonia | Euro Area 17 | Finland | France | Germany | Greece | Hungary | Iceland | India | Indonesia | Ireland | Israel | Italy | Japan | Latvia | Lithuania | Luxembourg | Mexico | Netherlands | New Zealand | Norway | OECD - Total | Poland | Portugal | Romania | Russia | Saudi Arabia | Slovakia | Slovenia | South Africa | South Korea | Spain | Sweden | Switzerland | Turkey | United Kingdom | United States |
|:-----|------------:|----------:|----------:|---------:|-----------:|---------:|---------:|---------:|-----------:|----------:|-----------------:|----------:|--------:|----------:|---------------:|----------:|---------:|----------:|---------:|----------:|----------:|---------:|------------:|----------:|---------:|--------:|--------:|---------:|------------:|-------------:|---------:|--------------:|--------------:|---------:|---------------:|---------:|-----------:|----------:|---------:|---------------:|-----------:|-----------:|---------------:|--------------:|---------:|---------:|--------------:|---------:|-----------------:|----------------:|
| 2013 | 84.1065 | 92.1 | 98.962 | 98.269 | 95.915 | 89.9958 | 78.0367 | 96.4912 | 85.1748 | 104.627 | 93.875 | 90.0977 | 98.267 | 82.2933 | 98.4009 | 100.353 | 103.8 | 92.5982 | 113.816 | 84.87 | 85.2075 | 76.6863 | 88.5178 | 77.0045 | 88.8228 | 109.1 | 96.148 | 97.6225 | 90.645 | 90.8947 | 88.6885 | 95.7715 | 83.5338 | 91.75 | 92.1431 | 97.4165 | 93.085 | 99.26 | 95.574 | nan | 93.5868 | 106.21 | 87.4525 | 95.7696 | 96.2393 | 80.785 | 94.867 | 75.946 | 87.3505 | 90.7087 |
| 2014 | 91.7202 | 95.33 | 98.417 | 99.1345 | 97.29 | 94.828 | 88.4455 | 101.132 | 91.9212 | 102.975 | 96.175 | 93.4987 | 98.482 | 93.5795 | 98.5693 | 99.995 | 101.925 | 95.499 | 105.32 | 88.4275 | 92.3855 | 88.032 | 94.73 | 89.7232 | 94.4668 | 103.95 | 97.648 | 103.475 | 96.47 | 94.8777 | 92.4655 | 96.5565 | 88.9588 | 94.25 | 95.5783 | 98.4538 | 97.0375 | 97.22 | 97.9095 | 101.189 | 94.9068 | 99.2025 | 94.146 | 97.2716 | 96.5393 | 88.4025 | 97.4497 | 86.1545 | 94.3388 | 95.1076 |
| 2015 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| 2016 | 105.5 | 108.532 | 102.641 | 100.868 | 107.02 | 110.589 | 106.573 | 112.23 | 109.995 | 100.888 | 107.15 | 104.727 | 104.01 | 104.745 | 104.012 | 101.285 | 100.925 | 107.527 | 97.623 | 113.377 | 109.767 | 106.686 | 103.159 | 107.484 | 107.459 | 100.25 | 102.213 | 108.487 | 105.4 | 106.006 | 107.282 | 105.052 | 114.178 | 107.025 | 105.352 | 101.859 | 107.115 | 105.95 | 102.856 | 95.091 | 106.703 | 103.252 | 105.616 | 101.622 | 104.623 | 108.243 | 101.627 | 113.615 | 106.975 | 105.586 |
| 2017 | 114.308 | 114.26 | 106.373 | 101.733 | 116.295 | 123.751 | 115.275 | 126.989 | 117.332 | 104.745 | 119.7 | 109.378 | 108.513 | 110.511 | 108.454 | 102.388 | 103.975 | 114.104 | 96.6342 | 127.24 | 131.196 | 115.658 | 106.415 | 119.162 | 111.649 | 99.175 | 104.805 | 118.013 | 114.797 | 111.96 | 115.687 | 112.978 | 121.596 | 112.35 | 111.13 | 105.768 | 117.015 | 112.355 | 108.782 | 88.9675 | 112.99 | 111.785 | 110.064 | 102.854 | 111.105 | 115.427 | 103.591 | 125.392 | 111.834 | 112.078 |
| 2018 | 112.664 | 119.64 | 109.415 | 102.599 | 123.955 | 128.378 | 126.812 | 134.268 | 123.825 | 111.14 | 130 | 114.529 | 113.668 | 117.066 | 113.604 | 103.335 | 107.15 | 121.681 | 98.379 | 145.495 | 142.006 | 122.248 | 109.895 | 131.363 | 110.724 | 98.625 | 106.849 | 129.3 | 123.18 | 119.862 | 125.951 | 123.656 | 125.966 | 113.975 | 116.592 | 112.765 | 129.032 | 118.618 | 116.147 | 86.4625 | 121.32 | 121.547 | 114.246 | 104.275 | 118.58 | 114.35 | 106.728 | 134.891 | 115.496 | 118.951 |
| 2019 | 108.084 | 126.6 | 113.779 | 103.464 | 131.417 | 129.959 | 137.5 | 139.503 | 130.601 | 121.103 | 141.9 | 117.53 | 118.641 | 125.267 | 118.505 | 103.77 | 110.675 | 128.707 | 105.481 | 170.167 | 148.291 | 126.309 | 111.91 | 134.431 | 112.812 | 98.525 | 108.553 | 140.875 | 131.61 | 131.987 | 136.739 | 132.658 | 129.9 | 116.8 | 121.327 | 122.55 | 141.882 | 122.69 | 119.822 | 83.5023 | 132.395 | 129.69 | 118.273 | 103.968 | 124.715 | 117.188 | 110.572 | 141.024 | 116.592 | 124.942 |
| 2020 | 113.916 | 136.311 | 118.595 | 104.332 | 137.412 | 138.454 | 146.659 | 144.577 | 133.834 | 130.38 | 153.85 | 123.531 | 124.813 | 132.792 | 124.761 | 105.595 | 116.825 | 138.685 | 110.223 | 178.577 | 157.788 | 129.465 | 113.646 | 134.847 | 116.261 | 100.4 | 108.63 | 145.768 | 141.178 | 151.115 | 144.687 | 142.761 | 143.109 | 121.775 | 128.945 | 135.335 | 154.327 | 128.435 | 144.26 | 84.833 | 145.061 | 135.657 | 121.228 | 107.451 | 127.505 | 122.11 | 115.355 | 173.709 | 119.904 | 134.761 |
| 2021 | 133.764 | 153.262 | 127.058 | 105.198 | 149.333 | 159.222 | 164.029 | 150.101 | 141.909 | 139.912 | 184.225 | 138.01 | 134.675 | 152.778 | 134.765 | 110.448 | 124.625 | 154.739 | 118.606 | 208.037 | 177.563 | 132.749 | 115.27 | 146 | 126.076 | 102.95 | 115.102 | 161.645 | 163.84 | 172.151 | 156.073 | 164.241 | 180.981 | 134.525 | 145.113 | 147.76 | 168.84 | 134.088 | 175.268 | 85.7263 | 154.334 | 151.317 | 126.269 | 116.89 | 132.195 | 134.463 | 123.334 | 237.534 | 130.515 | 157.24 |
| 2022 | 142.65 | 170.765 | 134.194 | 106.063 | 169.917 | 177.235 | 175.906 | 151.385 | 152.542 | 160.685 | 215.275 | 137.36 | 144.219 | 186.76 | 144.178 | 111.745 | 132.5 | 162.941 | 132.69 | 254.345 | 214.848 | 136.925 | nan | 163.977 | 147.852 | 106.875 | 124.755 | 184.005 | 195.048 | 188.6 | 169.973 | 186.321 | 182.022 | 141.575 | 165.45 | 165.18 | 190.17 | 143.697 | 225.506 | 87.5558 | 175.471 | 173.648 | 130.758 | 119.32 | 141.978 | 139.25 | 132.603 | 601.714 | 143.214 | 179.097 |

It is also possible to plot things such as the Employment Rate as also found in the README:

![Economics](https://github.com/JerBouma/FinanceToolkit/assets/46355364/bb44bd4e-07a1-4ecf-a4eb-7fc09a960930)

Or the Long Term (10 year) and Short Term (3 month) Interest Rates:

![output](https://github.com/JerBouma/FinanceToolkit/assets/46355364/d1b7ef02-0b39-4e07-8ef1-f449c76d0aec)
![output2](https://github.com/JerBouma/FinanceToolkit/assets/46355364/108aa79d-6681-4934-8d7c-a2dac117b6f1)

Or any of the other metrics:

- Gross Domestic Product (GDP) including Growth and Forecasts
- Consumer Confidence Index (CCI)
- Business Confidence Index (BCI)
- Composite Leading Indicator (CLI)
- Consumer Price Index (CPI)
- Producer Price Index (PPI)
- House and Rent Prices
- Unemployment Rates
- Long Term Interest Rates (10 year)
- Short Term Interest Rates (3 month)
- Purchasing Power Parity (PPP)
- Exchange Rates

**Are you looking for any specific economic parameter? Let me know and I'll start working on it.**

1.6.6

This releases introduces the GARCH model including volatility forecasting. Next to that, it includes a bugfix for the currency conversion.

Designed by northern-64bit ([LinkedIn](https://www.linkedin.com/in/fabian-farestam/)) in #82, this release introduces GARCH (Generalized autoregressive conditional heteroskedasticity) which is stochastic model for time series, which is for instance used to model volatility clusters, stock return and inflation. It is a generalisation of the ARCH models.

It can be found inside the `risk` module and can be ran with the following code:

python
from financetoolkit import Toolkit

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

toolkit.risk.get_garch()


Which produces the following result:

| Date | AMZN | TSLA | Benchmark |
|:-------|-------:|--------:|------------:|
| 2012 | 0 | 0 | 0 |
| 2013 | 0.2038 | 5.027 | 0.024 |
| 2014 | 0.4016 | 10.2307 | 0.0537 |
| 2015 | 0.53 | 13.2345 | 0.0688 |
| 2016 | 0.7664 | 15.6152 | 0.079 |
| 2017 | 0.8181 | 17.5204 | 0.0887 |
| 2018 | 0.8896 | 19.0642 | 0.0997 |
| 2019 | 0.9235 | 20.2789 | 0.104 |
| 2020 | 0.9479 | 21.2567 | 0.1169 |
| 2021 | 1.0203 | 27.5585 | 0.1209 |
| 2022 | 1.0201 | 27.0986 | 0.129 |
| 2023 | 1.0445 | 26.7482 | 0.1305 |

You can also forecast in the future for any period and for any interval. For example, the quarterly expected volatility estimations can be shown with:

python
from financetoolkit import Toolkit

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

toolkit.risk.get_garch_forecast(period='quarterly')

Which returns:

| | AMZN | TSLA | Benchmark |
|:-------|-------:|-------:|------------:|
| 2024Q1 | 0 | 0 | 0 |
| 2024Q2 | 0 | 0 | 0 |

1.6.3

This release features currency conversions. A user noticed that the financial statements are not always in the expected currency (different from the historical data):

<img width="1476" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/4c2e64d7-be64-4204-9037-07c0223a0f69">

This could lead to confusion when comparing numbers between companies and or when calculating ratios that require both data from the financial statement and the historical market data. This has now been resolved with an automatic converter that converts the financial statements accordingly. With this, the end of quarter or end of year exchange rate is used.

<img width="1147" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/d60a9eca-f745-4c76-b5dd-78e72bdf5232">

This is also saved in a seperate function called `get_exchange_rates` as shown below:

<img width="1145" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/3feb7f7e-2145-448c-ac1e-4d0dfa7ff345">

**This is quite a major change given that there are plenty of financial statements that report their financial statements in their local currency while the listed historical prices are in USD. This ensures that those numbers can be compared.** This can be disabled by setting `convert_currency` to `False` in the `Toolkit` initialisation. Note that by default it is automatically turned off when using the Free plan of FinancialModelingPrep as it could drain the API calls for that specific day.

I've also added in a parameter that recognises if you are using a Free or Premium plan from FinancialModelingPrep. This is a dependency for the `sleep_timer` which will wait a maximum of 60 seconds before making a new request to FMP. This is only relevant for the Premium plans since there is a rate limit per minute. For the Free plan it doesn't matter given that you are limited to 250 requests _per day_. In any case, this should make the Free experience smoother since you are not waiting for no reason. This solves 80.

**Note**: this consumes 1 API call so if you don't want that, just set sleep_timer to True or False.

python
if sleep_timer is None:
This tests the API key to determine the subscription plan. This is relevant for the sleep timer
but also for other components of the Toolkit. This prevents wait timers from occurring while
it wouldn't result to any other answer than a rate limit error.
determine_plan = helpers.get_financial_data(
url=f"https://financialmodelingprep.com/api/v3/income-statement/AAPL?period=quarter&apikey={api_key}",
sleep_timer=False,
)

self._fmp_plan = "Premium"

for option in ["NOT AVAILABLE", "LIMIT REACH", "INVALID API KEY"]:
if option in determine_plan:
self._fmp_plan = "Free"
break
else:
self._fmp_plan = "Premium"

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

![Risk](https://github.com/JerBouma/FinanceToolkit/assets/46355364/a95e5b51-f7fc-4a70-bbb4-bf88b346523e)

It is now possible to view ESG Scores for any range of companies with `get_esg_scores`:

<img width="1461" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/2aff1d38-bf21-4d11-b656-f4fffa990fbc">

Next to that, within the `Models` module, two new models are included. These are [Altman Z-Score](https://en.wikipedia.org/wiki/Altman_Z-score) and [Piotroski F-score](https://en.wikipedia.org/wiki/Piotroski_F-score). The former calculates the chance of bankruptcy based on a set of criteria:

<img width="1460" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/622fddd3-1182-4f3a-8690-4ae0cc1bb6ea">

The latter scores the financial strength of the company:

<img width="1457" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/6f4b9a09-414c-416a-bea4-8c7c74eb3bc9">

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

<img width="1161" alt="image" src="https://github.com/JerBouma/FinanceToolkit/assets/46355364/2824b935-eac3-45e3-ada2-c033162006ca">

Other than that, I've extended the examples and gave more explanation how to add in your own datasets.

Page 3 of 13

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.