All Risk Metrics
Calculates and collects all risk metrics.
All Risk Metrics in Python
collect_all_metrics is part of the Risk module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call collect_all_metrics as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.risk.collect_all_metrics().xs("AAPL", level=1, axis=1)
Which returns:
| Ulcer Index | GARCH | Skewness | Kurtosis | Downside Deviation | Variance | Volatility | |
|---|---|---|---|---|---|---|---|
| 2021 | 0.0376 | 0.0616 | -0.0677 | 3.3347 | 0.0102 | 0.063 | 0.2511 |
| 2022 | 0.0672 | 0.1223 | 0.3199 | 4.012 | 0.0135 | 0.1274 | 0.357 |
| 2023 | 0.0332 | 0.1667 | -0.0672 | 4.4211 | 0.0082 | 0.0412 | 0.203 |
| 2024 | 0.0341 | 0.2181 | 0.4479 | 6.516 | 0.0091 | 0.0515 | 0.2268 |
| 2025 | 0.0492 | 0.2452 | 1.1284 | 16.8074 | 0.0149 | 0.1056 | 0.3249 |
| 2026 | 0.0391 | 0.2585 | -0.2958 | 4.5239 | 0.0119 | 0.0717 | 0.2677 |
Parameters
collect_all_metrics accepts the following parameters:
- period (str, optional): The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
- rounding (int, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the ratios. Defaults to False.
- lag (int | str, optional): The lag to use for the growth calculation. Defaults to 1.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.