The Sortino Ratio is a financial metric used to assess the risk-adjusted performance of an investment portfolio or asset by considering only the downside risk. It measures the excess return generated by the portfolio per unit of downside risk, specifically, the standard deviation of negative returns. The Sortino Ratio is particularly useful for investors who are primarily concerned with minimizing the downside risk of their investments.

The formula is as follows:

\[\text{Sortino Ratio} = \text{Excess Return} / \text{Downside Deviation}\] \[\text{Downside Deviation} = \sqrt{(1 / N) \cdot \operatorname{SUM}(\min(\text{Excess Return},\; 0) ^{2})}\]

Where N is the total number of observations, not just the negative ones, following Sortino & Price (1994). By default one Sortino ratio is reported per period, computed from the daily excess returns falling inside that period. For a given period, for example monthly, this translates into the following:

\[\text{Sortino Ratio} = \text{Average Daily Excess Return within the Month} / \text{Downside Deviation of the Daily Excess Returns within the Month}\]

For a rolling period, period instead sets the frequency of the returns themselves and the ratio is computed over a rolling window of rolling such returns:

\[\text{Sortino Ratio} = \text{Average Rolling Excess Return} / \text{Rolling Downside Deviation}\]

Note that the Risk Free Rate is already subtracted from these returns. It is the Toolkit’s risk_free_rate, the 10-year US Treasury yield by default; initialise the Toolkit with risk_free_rate=”13w” for a short-term Treasury bill rate instead.

A period needs at least two observations for a Sortino ratio, with a single one the ratio would only show its sign, so such periods are left out.

As with the Sharpe Ratio, the result is not annualized: it is a per-observation ratio, so multiply by SQRT(252), SQRT(52), SQRT(12) or SQRT(4) for daily, weekly, monthly or quarterly returns respectively before comparing against published annualized figures.

See definition: https://en.wikipedia.org/wiki/Sortino_ratio

Sortino Ratio in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_sortino_ratio as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["V", "MA", "AXP"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.performance.get_sortino_ratio()

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

What was the Sortino ratio of Visa, Mastercard and American Express, measured on daily returns, in each year from 2021 to 2025?

Which returns:

Date V MA AXP
2021 0.0058 0.0163 0.1221
2022 -0.0049 -0.001 -0.0138
2023 0.129 0.1007 0.0922
2024 0.0911 0.1065 0.1909
2025 0.038 0.0273 0.0726

Parameters

get_sortino_ratio accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”."quarterly"
rollingintThe rolling window size to use for the calculation. If set, the Sortino ratio is calculated over a rolling window of this many periods across the full return history instead of per period. Defaults to None.4
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 ratios. 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