Skip to content

Performance

Risk-adjusted performance

Sharpe, Sortino, Treynor, Jensen's alpha, information ratio and tracking error, M², Calmar and up- and down-capture ratios from return series.

Model id
performance.risk_adjusted, version 1
Domain
Performance
Evidence
standard
Cost class
instant: A closed-form calculation; a hosted run may take up to 2 seconds.

Formula

S=eˉsemS = \frac{\bar{e}}{s_e}\sqrt{m}Sortino=rˉ−MARDDmSortino = \frac{\bar{r} - MAR}{DD}\sqrt{m}DD=1n∑min⁡(rt−MAR,0)2DD = \sqrt{\tfrac{1}{n}\sum \min(r_t - MAR, 0)^2}β=cov⁡(e,eb)var⁡(eb),T=meˉβ,α=m(eˉ−βeˉb)\beta = \frac{\operatorname{cov}(e, e^b)}{\operatorname{var}(e^b)}, \quad T = \frac{m\bar{e}}{\beta}, \quad \alpha = m(\bar{e} - \beta \bar{e}^b)TE=sam,IR=aˉsamTE = s_a \sqrt{m}, \quad IR = \frac{\bar{a}}{s_a}\sqrt{m}M2=mfˉ+S⋅sebmM^2 = m\bar{f} + S \cdot s_{e^b}\sqrt{m}Calmar=(∏(1+rt))m/n−1MDD,UC=rˉb>0Gbˉb>0GCalmar = \frac{(\prod (1 + r_t))^{m/n} - 1}{MDD}, \quad UC = \frac{\bar{r}^{G}_{b > 0}}{\bar{b}^{G}_{b > 0}}

Where

SS
Sharpe ratio, for a year sharpe_ratio
eˉ\bar{e}
Mean excess return over the risk-free return
ses_e
Standard deviation of the excess returns
mm
Periods in a year periods_per_year
SortinoSortino
Sortino ratio, for a year sortino_ratio
rˉ\bar{r}
Mean return
MARMAR
Minimum acceptable return per period minimum_acceptable_return
DDDD
Downside deviation below the minimum acceptable return downside_deviation
rtr_t
The return in period t returns
nn
Number of returns observations
β\beta
Beta to the benchmark beta
ebe^b
The benchmark's excess returns
TT
Treynor ratio, for a year treynor_ratio
α\alpha
Jensen's alpha, for a year jensen_alpha
TETE
Tracking error, for a year tracking_error
sas_a
Standard deviation of the active returns: the portfolio's less the benchmark's
IRIR
Information ratio, for a year information_ratio
aˉ\bar{a}
Mean active return
M2M^2
Modigliani-Modigliani measure: the return at the benchmark's volatility m_squared
fˉ\bar{f}
Mean risk-free return
CalmarCalmar
Calmar ratio: the annualized return over the maximum drawdown calmar_ratio
MDDMDD
Maximum drawdown max_drawdown
UCUC
Up capture: the portfolio's return over the benchmark's, in periods the benchmark rose up_capture

Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.

Variables

Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.

Inputs

Inputs
NameDescription
Returnsreturnsreturn (array) · length min 2, max 10080; each [-1, 100]Portfolio return each period
Benchmark returnsbenchmark_returnsreturn (array) · length min 2, max 10080; each [-1, 100]Benchmark return each period, aligned with the portfolio's
Risk free returnsrisk_free_returnsreturn (array) · length max 10080; each [-1, 100]Risk-free return each period; omit for zero
Periods per yearperiods_per_yearperiods · (0, 100000]Periods in a year, such as 12 or 252
Minimum acceptable returnminimum_acceptable_returnreturn · [-1, 100]Minimum acceptable return per period, for the Sortino ratio

Outputs

Outputs
NameDescription
Observationsobservationscount · [2, 10080]Number of periods
Annualized returnannualized_returnreturn · [-1, 1e+06]Compound annual growth rate of the portfolio
Annualized volatilityannualized_volatilityvolatility · [0, 100000]Standard deviation of the portfolio returns (n - 1) times sqrt(m)
Sharpe ratiosharpe_ratioratio · [-1e+06, 1e+06]Mean excess return over its standard deviation, times sqrt(m)
Downside deviationdownside_deviationvolatility · [0, 100000]Root mean square shortfall below the minimum acceptable return (n), times sqrt(m)
Sortino ratiosortino_ratioratio · [-1e+06, 1e+06]Mean return less the minimum acceptable return, over the downside deviation, times sqrt(m)
Betabetaratio · [-1e+06, 1e+06]Covariance of portfolio and benchmark excess returns over the benchmark's variance
Treynor ratiotreynor_ratioratio · [-1e+06, 1e+06]Annualized mean excess return over beta
Jensen alphajensen_alphareturn · [-1e+06, 1e+06]Annualized intercept: m times (mean excess return - beta * benchmark's)
Tracking errortracking_errorvolatility · [0, 100000]Standard deviation of the active returns (n - 1) times sqrt(m)
Information ratioinformation_ratioratio · [-1e+06, 1e+06]Mean active return over its standard deviation, times sqrt(m)
M squaredm_squaredreturn · [-1e+06, 1e+06]Annualized risk-free return plus the Sharpe ratio times the benchmark's annualized excess volatility
Max drawdownmax_drawdownreturn · [0, 1]Largest decline of the wealth index from a peak
Calmar ratiocalmar_ratioratio · [-1e+06, 1e+06]Compound annual growth rate over the maximum drawdown
Up captureup_captureratio · [-1e+06, 1e+06]Geometric mean portfolio return over the benchmark's, in periods the benchmark rose
Down capturedown_captureratio · [-1e+06, 1e+06]Geometric mean portfolio return over the benchmark's, in periods the benchmark fell

Calculator

Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.

Loading the calculator…

Worked example

Example twelve_months. Inputs:

{
  "benchmark_returns": [
    0.018, -0.01, 0.029, 0.011,
    -0.025, 0.012, 0.022, -0.002,
    0.01, 0.016, -0.028, 0.02
  ],
  "minimum_acceptable_return": 0,
  "periods_per_year": 12,
  "returns": [
    0.021, -0.013, 0.034, 0.008,
    -0.022, 0.015, 0.027, -0.005,
    0.012, 0.019, -0.031, 0.024
  ],
  "risk_free_returns": [
    0.002, 0.002, 0.002, 0.002,
    0.002, 0.002, 0.002, 0.002,
    0.002, 0.002, 0.002, 0.002
  ]
}

Outputs:

{
  "annualized_return": 0.09018654376882035,
  "annualized_volatility": 0.07141364779164477,
  "beta": 1.109033365279604,
  "calmar_ratio": 2.909243347381299,
  "down_capture": 1.0913819902595654,
  "downside_deviation": 0.040484564959994314,
  "information_ratio": 1.3945434310968845,
  "jensen_alpha": 0.010657365101299405,
  "m_squared": 0.08212986476775608,
  "max_drawdown": 0.031000000000000028,
  "observations": 12,
  "sharpe_ratio": 0.9101901668661834,
  "sortino_ratio": 2.198368689102804,
  "tracking_error": 0.011473289137660728,
  "treynor_ratio": 0.058609598263630706,
  "up_capture": 1.1588524775120463
}

Assumptions

  • Returns are decimals over equal periods, aligned in time; periods_per_year is explicit and never inferred.
  • Means and the annualized excess, active and alpha figures are arithmetic (times m); deviations divide by n - 1, except the downside deviation below a given minimum acceptable return, which divides by n; the annualized return and Calmar use compound growth.
  • Capture ratios are geometric mean returns per period, not annualized, over the periods when the benchmark's return was above (below) zero.

Limitations

  • A ratio over a zero denominator (a flat excess, benchmark or active series, no drawdown, no up or down periods) or past its bounds is null, with a warning.
  • Ex post ratios from short samples are noisy; none corrects for autocorrelation, fat tails or the smoothing of illiquid returns.

Evidence

Status: standard. Textbook consensus, such as bond duration or the CAPM formula.

Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).

Syllabus

The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.

Citations

  1. Sharpe, W. F. (1966). Mutual fund performance. The Journal of Business, 39(1), 119-138. doi:10.1086/294846 (The reward-to-variability ratio)
  2. Sharpe, W. F. (1994). The Sharpe ratio. The Journal of Portfolio Management, 21(1), 49-58. doi:10.3905/jpm.1994.409501 (Eqs. (3)-(6), the ex post Sharpe ratio; eqs. (7)-(10), its annualization)
  3. Sortino, F. A. and Price, L. N. (1994). Performance measurement in a downside risk framework. The Journal of Investing, 3(3), 59-64. doi:10.3905/joi.3.3.59 (The downside deviation below a minimum acceptable return)
  4. Treynor, J. L. (1965). How to rate management of investment funds. Harvard Business Review, 43(1), 63-75. Reprinted in Treynor on Institutional Investing (2008), Wiley, ch. 10, 69-87. doi:10.1002/9781119196679.ch10 (The characteristic line and the reward to volatility)
  5. Jensen, M. C. (1968). The performance of mutual funds in the period 1945-1964. The Journal of Finance, 23(2), 389-416. doi:10.1111/j.1540-6261.1968.tb00815.x (Eq. (8), p. 393, alpha as the intercept of the excess-return regression)
  6. Modigliani, F. and Modigliani, L. (1997). Risk-adjusted performance. The Journal of Portfolio Management, 23(2), 45-54. doi:10.3905/jpm.23.2.45 (The risk-adjusted performance (RAP) measure)
  7. Bacon, C. R. (2008). Practical Portfolio Performance Measurement and Attribution, 2nd ed. Wiley. doi:10.1002/9781119206309.ch4 (Chapter 4, pp. 61-115: tracking error, information ratio, M2, Calmar and capture ratios). ISBN 9780470059289

Changelog

  • Version 1: First version.

Use it elsewhere

Documentation
The model's reference page
REST API
GET or POST /v1/models/performance.risk_adjusted/run
MCP tool
performance_risk_adjusted, or run_model with the model's id; both give the same result. Connect an assistant
Command line
pyeconomics models run performance.risk_adjusted --help

The worked example, from Python and from the command line:

Python
import pyeconomics

inputs = {
    "benchmark_returns": [
        0.018, -0.01, 0.029, 0.011,
        -0.025, 0.012, 0.022,
        -0.002, 0.01, 0.016, -0.028,
        0.02,
    ],
    "minimum_acceptable_return": 0,
    "periods_per_year": 12,
    "returns": [
        0.021, -0.013, 0.034, 0.008,
        -0.022, 0.015, 0.027,
        -0.005, 0.012, 0.019,
        -0.031, 0.024,
    ],
    "risk_free_returns": [
        0.002, 0.002, 0.002, 0.002,
        0.002, 0.002, 0.002, 0.002,
        0.002, 0.002, 0.002, 0.002,
    ],
}
result = pyeconomics.run("performance.risk_adjusted", inputs)
print(result.to_json())
Command line
pyeconomics models run performance.risk_adjusted --inputs - <<'JSON'
{
  "benchmark_returns": [
    0.018, -0.01, 0.029, 0.011,
    -0.025, 0.012, 0.022, -0.002,
    0.01, 0.016, -0.028, 0.02
  ],
  "minimum_acceptable_return": 0,
  "periods_per_year": 12,
  "returns": [
    0.021, -0.013, 0.034, 0.008,
    -0.022, 0.015, 0.027, -0.005,
    0.012, 0.019, -0.031, 0.024
  ],
  "risk_free_returns": [
    0.002, 0.002, 0.002, 0.002,
    0.002, 0.002, 0.002, 0.002,
    0.002, 0.002, 0.002, 0.002
  ]
}
JSON