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
Where
- Sharpe ratio, for a year
sharpe_ratio - Mean excess return over the risk-free return
- Standard deviation of the excess returns
- Periods in a year
periods_per_year - Sortino ratio, for a year
sortino_ratio - Mean return
- Minimum acceptable return per period
minimum_acceptable_return - Downside deviation below the minimum acceptable return
downside_deviation - The return in period t
returns - Number of returns
observations - Beta to the benchmark
beta - The benchmark's excess returns
- Treynor ratio, for a year
treynor_ratio - Jensen's alpha, for a year
jensen_alpha - Tracking error, for a year
tracking_error - Standard deviation of the active returns: the portfolio's less the benchmark's
- Information ratio, for a year
information_ratio - Mean active return
- Modigliani-Modigliani measure: the return at the benchmark's volatility
m_squared - Mean risk-free return
- Calmar ratio: the annualized return over the maximum drawdown
calmar_ratio - Maximum drawdown
max_drawdown - 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
| Name | Unit | Bounds | Description |
|---|---|---|---|
Returnsreturnsreturn (array) · length min 2, max 10080; each [-1, 100] | return (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] | return (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] | return (array) | length max 10080; each [-1, 100] | Risk-free return each period; omit for zero |
Periods per yearperiods_per_yearperiods · (0, 100000] | periods | (0, 100000] | Periods in a year, such as 12 or 252 |
Minimum acceptable returnminimum_acceptable_returnreturn · [-1, 100] | return | [-1, 100] | Minimum acceptable return per period, for the Sortino ratio |
Outputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Observationsobservationscount · [2, 10080] | count | [2, 10080] | Number of periods |
Annualized returnannualized_returnreturn · [-1, 1e+06] | return | [-1, 1e+06] | Compound annual growth rate of the portfolio |
Annualized volatilityannualized_volatilityvolatility · [0, 100000] | volatility | [0, 100000] | Standard deviation of the portfolio returns (n - 1) times sqrt(m) |
Sharpe ratiosharpe_ratioratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Mean excess return over its standard deviation, times sqrt(m) |
Downside deviationdownside_deviationvolatility · [0, 100000] | volatility | [0, 100000] | Root mean square shortfall below the minimum acceptable return (n), times sqrt(m) |
Sortino ratiosortino_ratioratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Mean return less the minimum acceptable return, over the downside deviation, times sqrt(m) |
Betabetaratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Covariance of portfolio and benchmark excess returns over the benchmark's variance |
Treynor ratiotreynor_ratioratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Annualized mean excess return over beta |
Jensen alphajensen_alphareturn · [-1e+06, 1e+06] | return | [-1e+06, 1e+06] | Annualized intercept: m times (mean excess return - beta * benchmark's) |
Tracking errortracking_errorvolatility · [0, 100000] | volatility | [0, 100000] | Standard deviation of the active returns (n - 1) times sqrt(m) |
Information ratioinformation_ratioratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Mean active return over its standard deviation, times sqrt(m) |
M squaredm_squaredreturn · [-1e+06, 1e+06] | return | [-1e+06, 1e+06] | Annualized risk-free return plus the Sharpe ratio times the benchmark's annualized excess volatility |
Max drawdownmax_drawdownreturn · [0, 1] | return | [0, 1] | Largest decline of the wealth index from a peak |
Calmar ratiocalmar_ratioratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Compound annual growth rate over the maximum drawdown |
Up captureup_captureratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Geometric mean portfolio return over the benchmark's, in periods the benchmark rose |
Down capturedown_captureratio · [-1e+06, 1e+06] | ratio | [-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
- Sharpe, W. F. (1966). Mutual fund performance. The Journal of Business, 39(1), 119-138. doi:10.1086/294846 (The reward-to-variability ratio)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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, orrun_modelwith 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:
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())
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