FinanceToolkit v1.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) 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:
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:
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 |
2024Q3 | 0.006 | 0.3185 | 0.0003 |
2024Q4 | 0.0114 | 0.6051 | 0.0006 |
2025Q1 | 0.0162 | 0.8631 | 0.0008 |
2025Q2 | 0.0206 | 1.0953 | 0.001 |
2025Q3 | 0.0245 | 1.3042 | 0.0012 |
2025Q4 | 0.0281 | 1.4923 | 0.0014 |
2026Q1 | 0.0312 | 1.6615 | 0.0015 |
2026Q2 | 0.0341 | 1.8138 | 0.0017 |
Next to that, a bug fix went in related to the currency conversions which makes it more robust when there is data missing. If you didn't know, when you have a Premium FMP plan the Finance Toolkit will now automatically convert currencies that do not match up with the historical data. For more see here: https://github.com/JerBouma/FinanceToolkit/releases/tag/v1.6.3