Risk
The Risk module calculates important risk metrics such as Value at Risk (VaR), Conditional Value at Risk (CVaR), Maximum Drawdown, Correlations, GARCH, EWMA and more.
Every function of the Risk module has its own page with an example and its parameters. Pick one from the sidebar on the left.Every function of the Risk module has its own page with an example and its parameters. Pick one from the .
To install the FinanceToolkit it simply requires the following:
pip install financetoolkit -U
Getting Started
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.
The Risk module is reached through a Toolkit instance, as shown below.
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 |
The sidebar gives access to every metric in the Risk module, each on its own page with a description, an example and its parameters. Pick one there to open it.The sidebar gives access to every metric in the Risk module, each on its own page with a description, an example and its parameters. On a phone, open the to pick one.