Calculate the Maximum Drawdown (MDD) of an investment portfolio or asset’s returns.

Maximum Drawdown (MDD) is a risk management metric that quantifies the largest historical loss of an investment portfolio or asset experienced over a specified time horizon. It provides insights into the downside risk associated with an investment and helps investors make informed decisions about risk tolerance.

The Maximum Drawdown is a single-path statistic: it depends entirely on the window chosen, so a figure over a window that includes a market crash and one over a window that starts after it are not comparable. It says how deep the worst fall was, not how long it lasted, which is why it is usually read together with the drawdown duration and recovery time (see get_maximum_drawdown_duration and get_maximum_drawdown_recovery_time), and it underlies return-to-risk ratios such as the Calmar ratio.

The formula is as follows:

\[\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{Maximum Drawdown} = \min(\operatorname{Drawdown}(t))\]

Wealth starts at 1, so a decline from the start of the window counts as well, and the result is a negative decimal (0 when the value never fell below a previous high).

Also known as: max drawdown, peak-to-trough decline.

Maximum Drawdown (MDD) in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_maximum_drawdown as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["META", "NFLX", "AMZN"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.risk.get_maximum_drawdown(period="yearly", within_period=True)

Or, after setting up the Finance Toolkit MCP, ask:

What was the maximum drawdown of Meta, Netflix, Amazon and the S&P 500 in each year from 2021 to 2025?

Which returns:

  META NFLX AMZN Benchmark
2021 -0.1972 -0.173 -0.1456 -0.051
2022 -0.7372 -0.7237 -0.5197 -0.245
2023 -0.1298 -0.2752 -0.1965 -0.0999
2024 -0.1842 -0.1345 -0.1949 -0.0841
2025 -0.3416 -0.3073 -0.3088 -0.1877

Parameters

get_maximum_drawdown accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”."weekly"
within_periodboolWhether to calculate the Maximum Drawdown within the specified period or for the entire period. Thus whether to look at the Maximum Drawdown 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
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the Maximum Drawdown values over time. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
Share