Conditional Drawdown at Risk (CDaR)
Calculate the Conditional Drawdown at Risk (CDaR) of an investment portfolio or asset’s returns.
Conditional Drawdown at Risk (CDaR) extends the concept of Value at Risk and Conditional Value at Risk to the drawdown series instead of the return series. It is calculated as the average of the worst drawdowns that exceed the Drawdown at Risk (DaR), i.e. the alpha-quantile of the drawdown distribution, giving insight into the depth of the most severe drawdowns an investment portfolio or asset could experience.
The formula is as follows (with the default alpha=0.05):
\[\operatorname{Wealth}(t) = \text{Π} (1 + \operatorname{Return}(s)) \text{for}\; s \leq t\] \[\operatorname{Drawdown}(t) = \operatorname{Wealth}(t) / \max(1,\; \max(\operatorname{Wealth}(s) \text{for}\; s \leq t)) - 1\] \[\text{DaR} = \operatorname{Quantile}(\text{Drawdown},\; \alpha)\] \[\text{CDaR} = \operatorname{Mean}(\text{Drawdown} | \text{Drawdown} \leq \text{DaR})\]Every period counts towards the drawdown distribution, including those at a high (a drawdown of 0), the quantile interpolates linearly, and Wealth starts at 1, so a decline from the start of the window counts.
Also known as: CDaR.
Conditional Drawdown at Risk (CDaR) in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_conditional_drawdown_at_risk as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["^STOXX50E", "^N225", "^GSPC"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_conditional_drawdown_at_risk(period="yearly", within_period=True)
Or, after setting up the Finance Toolkit MCP, ask:
What was the 95% conditional drawdown at risk of the Euro Stoxx 50, the Nikkei 225 and the S&P 500 in each year from 2021 to 2025?
Which returns:
| ^STOXX50E | ^N225 | ^GSPC | Benchmark | |
|---|---|---|---|---|
| 2021 | -0.0628 | -0.1001 | -0.042 | -0.0413 |
| 2022 | -0.24 | -0.1312 | -0.2422 | -0.2344 |
| 2023 | -0.0912 | -0.0813 | -0.0834 | -0.0807 |
| 2024 | -0.0818 | -0.1612 | -0.0574 | -0.0565 |
| 2025 | -0.123 | -0.1603 | -0.1469 | -0.1457 |
Parameters
get_conditional_drawdown_at_risk accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
alpha | float | The tail probability for the CDaR calculation (e.g., 0.05 for the 95% confidence level). Defaults to 0.05. | 0.01 |
within_period | bool | Whether to calculate CDaR within the specified period or for the entire period. Thus whether to look at the CDaR within a specific year (if period = ‘yearly’) or look at the entirety of all years. Defaults to False. Note that this requires intraday data when period = ‘daily’, since a single day only nests observations when intraday data was fetched. | True |
rolling | int | The rolling window size to use for the calculation. If set, CDaR is calculated over a rolling window of this many periods across the full return history instead of per period. Defaults to None. | 20 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the CDaR values over time. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |