HEDGEFUND.md

Models / Fund terms and risk / deflated_sharpe

Deflated Sharpe

How much of this backtest's Sharpe survives the number of trials it was picked from?

Tests a reported Sharpe against what the best of many trials would show by luck, with skew, kurtosis and sample length. Gives the probabilistic and deflated Sharpe, the minimum sample length and the trial count where it falls below the confidence. All numbers come from the caller. It measures selection only. It can't detect lookahead or fitting that was not counted.

The paste-ready promptmodel.md

On these numbers, a hypothetical annual Sharpe of 1.8 over 1260 periods has a probabilistic Sharpe of 99.99% against the benchmark and a deflated Sharpe of 87.57% after 100 trials, which measures selection only, not lookahead or fitting that was not counted.

Hypothetical, and on made-up numbers until you replace them. Nobody traded this, and nothing here is on offer.

Readings

The numbers, with their units.

Deflated Sharpe

breach

87.57%

Against a confidence of 95%.

Probabilistic Sharpe against the benchmark

99.99%

No allowance for the trials.

Expected best of the trials, annual

1.2653

What the best of them would show if every true Sharpe were zero.

Annual Sharpe where the deflated figure meets the confidence

2.0316

Trials where it falls below

31trials

Minimum sample against the benchmark

227periods

0.9 years. This sample has 1260 periods.

Minimum sample against the best of the trials

watch

2,560periods

10.16 years. This sample has 1260 periods.

Sharpe a period

0.113389

Annual Sharpe / sqrt(252).

What flips it

The value of one input where the outcome changes, with the others held.

  1. trials

    31trialsnow 100

    At this many independent trials or more, the deflated Sharpe falls below 95%. Below it, the figure is at or above that confidence.

  2. sharpe_annual

    2.0316Sharpenow 1.8

    At 100 trials, an annual Sharpe above this gives a deflated figure above 95%, with the other inputs as sent.

Flags

What went past a line, and what to read before you trust the rest.

  • watch
    This measures selection. It can't detect lookahead, or fitting that was not counted as a trial. selection_only
  • breach
    The deflated Sharpe of 87.57% is below the 95% confidence. below_confidence
  • watch
    This sample has 1260 periods. Clearing the expected best of these trials at this confidence takes 2560. short_sample

What this leaves out

What the formula leaves out, by name.

  • Lookahead, survivorship and bad data. This measures selection. It can't see any of them.
  • Fitting not counted as a trial. Tweaks that never got logged make the true trial count higher than the number sent.
  • Correlation among the trials. Send the count of independent trials, which is usually lower than the raw count.
  • Costs, slippage, capacity and borrow, unless they are already in the Sharpe sent.
  • Whether anything carries over to another period. A high figure says the selection effect alone doesn't explain the sample, nothing more.
What it took as given (7)

What it took as given to get here.

  • Annual Sharpes are turned into per-period Sharpes by dividing by sqrt(periods_per_year), and that includes the trials' stdev.
  • Kurtosis is not excess. A normal is 3. If the moments can't belong to one series (kurtosis under skew squared plus 1), the model stops and says so.
  • The deflated figure tests against S0 alone, as in the published form, with no benchmark added. benchmark_sharpe_annual only feeds the plain probabilistic figure and its minimum sample.
  • The trials' true Sharpes are taken as centered on zero, and the trials as independent. The expected maximum is the usual approximation, close for many trials and rough for a few.
  • One trial means no selection, so S0 is 0.
  • The trial flip is the smallest whole number of trials at which the deflated figure is under the confidence. The Sharpe flip solves the same equation for S.
  • Minimum sample length is rounded up to a whole period. It keeps the sample's skew and kurtosis.
Deflated Sharpe as trials grow (hypothetical)%
7080901001002003004005006007008009001,000Trialslimit 9564.51
The data

Trials against the deflated figure

TrialsExpected best, annual SharpeDeflated Sharpe %
1099.99
20.25987899.96
50.59629799.53
100.78729998.56
200.95035496.66
311.043494.87
501.138292.34
1001.265387.57
2001.382881.61
5001.526372.27
1,0001.627664.51

Hypothetical, computed from the numbers sent and any stated default, with hindsight. Nobody traded it, and costs and liquidity are only as assumed. Not a forecast, a recommendation, an offer, or a record of real trading. Don't use it to market an investment.

formula S = annual / sqrt(p). V = 1 - g3 S + (g4 - 1) / 4 x S^2. PSR(S*) = Phi((S - S*) sqrt(n - 1) / sqrt(V)). S0 = sigma x ((1 - gamma) invPhi(1 - 1 / N) + gamma invPhi(1 - 1 / (N e))), sigma the trials' per-period stdev, gamma the Euler-Mascheroni constant. Deflated = PSR(S0). Minimum track = 1 + V x (invPhi(c) / (S - S*))^2.

inputs_hash 0e0d50ae360ddbdf

Paste it into your agent

No connection needed. This prompt carries the method, the conventions and what this site's engine gives on the made-up numbers, so your agent can check its own work before it touches real ones. Every prompt, with its hash, is listed at /prompts.json. A copy that stays fixed for this version, for a stack to point at: /v/1.0/models/deflated_sharpe.md.

prompt.md
# Deflated Sharpe: a prompt from hedgefund.mdPaste this into your AI agent. It needs no connection to hedgefund.md. An agent that can run code should write and run it, and shouldn't work a long series by hand.**Question.** How much of this backtest's Sharpe survives the number of trials it was picked from?## MethodS = annual / sqrt(p). V = 1 - g3 S + (g4 - 1) / 4 x S^2. PSR(S*) = Phi((S - S*) sqrt(n - 1) / sqrt(V)). S0 = sigma x ((1 - gamma) invPhi(1 - 1 / N) + gamma invPhi(1 - 1 / (N e))), sigma the trials' per-period stdev, gamma the Euler-Mascheroni constant. Deflated = PSR(S0). Minimum track = 1 + V x (invPhi(c) / (S - S*))^2.## Conventions- Annual Sharpes are turned into per-period Sharpes by dividing by sqrt(periods_per_year), and that includes the trials' stdev.- Kurtosis is not excess. A normal is 3. If the moments can't belong to one series (kurtosis under skew squared plus 1), the model stops and says so.- The deflated figure tests against S0 alone, as in the published form, with no benchmark added. benchmark_sharpe_annual only feeds the plain probabilistic figure and its minimum sample.- The trials' true Sharpes are taken as centered on zero, and the trials as independent. The expected maximum is the usual approximation, close for many trials and rough for a few.- One trial means no selection, so S0 is 0.- The trial flip is the smallest whole number of trials at which the deflated figure is under the confidence. The Sharpe flip solves the same equation for S.- Minimum sample length is rounded up to a whole period. It keeps the sample's skew and kurtosis.## Step 1: check your method on these made-up numbersThe numbers and names below are made up. They aren't market levels, typical values or anyone's real figures.```json{  "sharpe_annual": 1.8,  "periods_per_year": 252,  "observations": 1260,  "skew": -0.5,  "kurtosis": 6,  "trials": 100,  "trial_sharpe_std_annual": 0.5,  "benchmark_sharpe_annual": 0,  "confidence_pct": 95}```Work them out with the method above. Yours should match these within 0.5%.- Deflated Sharpe: 87.57299111 %- Probabilistic Sharpe against the benchmark: 99.99487248 %- Expected best of the trials, annual: 1.265301447- Annual Sharpe where the deflated figure meets the confidence: 2.031643036- Trials where it falls below: 31 trials- Minimum sample against the benchmark: 227 periods- Minimum sample against the best of the trials: 2560 periods- Sharpe a period: 0.1133893419Where the outcome flips, with the other inputs held:- trials at 31: At this many independent trials or more, the deflated Sharpe falls below 95%. Below it, the figure is at or above that confidence.- sharpe_annual at 2.031643036: At 100 trials, an annual Sharpe above this gives a deflated figure above 95%, with the other inputs as sent.If yours differ, stop and tell the person which ones and by how much. Don't go on to real numbers until they match, or until the person has seen the difference. These values come from one engine and can be wrong too.## Step 2: run it on the person's numbersReplace every input with the person's own. Ask for any number you don't have, and don't invent one.## Step 3: reportGive one sentence beginning "On these numbers,", then the values, then where the outcome flips. Always add what this leaves out:- Lookahead, survivorship and bad data. This measures selection. It can't see any of them.- Fitting not counted as a trial. Tweaks that never got logged make the true trial count higher than the number sent.- Correlation among the trials. Send the count of independent trials, which is usually lower than the raw count.- Costs, slippage, capacity and borrow, unless they are already in the Sharpe sent.- Whether anything carries over to another period. A high figure says the selection effect alone doesn't explain the sample, nothing more.## LimitsResults are hypothetical: arithmetic on the numbers given, prepared with hindsight. Nobody achieved them, and costs and liquidity are only as assumed. They aren't a forecast, a recommendation, an offer or a record of real trading. Don't say what to buy, sell or hold, and don't use them to market an investment. Whether a person may hold or trade an instrument is a legal question for counsel.Provided as is, at your own risk, by hedgefund.md, which is not a fund and isn't anyone's adviser. Version 1.0. Source: https://hedgefund.md/models/deflated_sharpe/prompt.md. Terms: https://hedgefund.md/terms

Call it

The same code answers on this page, over HTTP, over MCP and on your own machine, and the same inputs give the same bytes. No key, and nothing is stored. Send positions by POST or run the library, because a URL can land in a server log. model.md holds all of this for your agent.

POST the inputs to /api/v1/deflated_sharpe.

terminal
curl -s https://hedgefund.md/api/v1/deflated_sharpe \  -H 'content-type: application/json' \  -d '{"sharpe_annual":1.8,"periods_per_year":252,"observations":1260,"skew":-0.5,"kurtosis":6,"trials":100,"trial_sharpe_std_annual":0.5,"benchmark_sharpe_annual":0,"confidence_pct":95}' \  | jq '{summary, flags, flips, not_modeled, inputs_hash}'

Inputs

InputTypeRangeRequiredWhat it is
sharpe_annualnumber-10 to 20yesAnnual Sharpe of the chosen strategy.
periods_per_yearwhole number1 to 365yesPeriods in a year of the returns: 252, 52 or 12.
observationswhole number2 to 1000000yesNumber of return periods in the sample.
skewnumber-50 to 50yesSkew of the returns. A normal is 0.
kurtosisnumber0 to 3000yesKurtosis of the returns, not excess. A normal is 3.
trialswhole number1 to 1000000000yesIndependent trials the strategy was picked from, including every one discarded.
trial_sharpe_std_annualnumber0 to 20yesStdev across the trials' annual Sharpes.
benchmark_sharpe_annualnumber-10 to 20noAnnual Sharpe to test against in the plain probabilistic figure.
confidence_pctnumber50 to 99.99yesConfidence to compare with, in percent.

Hypothetical, and on made-up numbers until you replace them. Nobody traded this, and nothing here is on offer.

1.0Use at your own risk: hedgefund.md is not a fund, not an offer of any security, token or fund interest, and not advice. Results are hypothetical, may be wrong, and are not a record of real trading. Don't use them to market an investment. See the terms.