Downside Deviation
Calculate the Downside Deviation of an investment portfolio or asset’s returns.
The Downside Deviation, also known as semi-deviation, is the standard deviation of only the returns that fall below a minimum acceptable return (MAR), isolating the volatility of negative outcomes from the volatility of the overall return distribution. It underlies risk-adjusted return measures such as the Sortino Ratio and the Omega Ratio.
Also known as: semi-deviation, downside risk, downside volatility.
Downside Deviation in Python
get_downside_deviation is part of the Risk module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_downside_deviation as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.risk.get_downside_deviation()
Which returns:
| AMZN | TSLA | Benchmark | |
|---|---|---|---|
| 2021 | 0.0106 | 0.0215 | 0.0058 |
| 2022 | 0.0202 | 0.0283 | 0.0095 |
| 2023 | 0.0129 | 0.0217 | 0.005 |
| 2024 | 0.0118 | 0.0227 | 0.006 |
| 2025 | 0.0146 | 0.0257 | 0.0096 |
| 2026 | 0.0123 | 0.0165 | 0.0061 |
Parameters
get_downside_deviation 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 initialized with quarterly=True, otherwise “yearly”.
- minimum_acceptable_return (float, optional): The minimum acceptable return (MAR) used as the threshold below which returns are considered downside. Defaults to 0.0.
- within_period (bool, optional): Whether to calculate the Downside Deviation within the specified period or for the entire period. Thus whether to look at the Downside Deviation within a specific year (if period = ‘yearly’) or look at the entirety of all years. Defaults to True.
- rolling (int, optional): The rolling window size to use for the calculation. If set, the Downside
Deviation is calculated over a rolling window of this many periods across the full return history
instead of per
period. Defaults to None. - rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the Downside Deviation values over time. Defaults to False.
- lag (int | list[int], 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.