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.
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
breach87.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
watch2,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.
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.
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.
- watchThis measures selection. It can't detect lookahead, or fitting that was not counted as a trial. selection_only
- breachThe deflated Sharpe of 87.57% is below the 95% confidence. below_confidence
- watchThis 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.
The data
Trials against the deflated figure
| Trials | Expected best, annual Sharpe | Deflated Sharpe % |
|---|---|---|
| 1 | 0 | 99.99 |
| 2 | 0.259878 | 99.96 |
| 5 | 0.596297 | 99.53 |
| 10 | 0.787299 | 98.56 |
| 20 | 0.950354 | 96.66 |
| 31 | 1.0434 | 94.87 |
| 50 | 1.1382 | 92.34 |
| 100 | 1.2653 | 87.57 |
| 200 | 1.3828 | 81.61 |
| 500 | 1.5263 | 72.27 |
| 1,000 | 1.6276 | 64.51 |
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.
# 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/termsCall 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.
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}'The tool is deflated_sharpe on https://hedgefund.md/mcp.
curl -s https://hedgefund.md/mcp \ -H 'content-type: application/json' -H 'accept: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"deflated_sharpe","arguments":{"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 '.result.structuredContent | {summary, flags, flips, not_modeled, inputs_hash}'One file with no dependencies, and nothing is sent anywhere.
curl -fsSL https://hedgefund.md/hedgefund.mjs -o hedgefund.mjs # read it before you run itnode hedgefund.mjs template deflated_sharpe > mine.json # replace every number in itnode hedgefund.mjs run deflated_sharpe mine.json | jq '{summary, flags, flips, not_modeled, inputs_hash}'Made-up numbers that run as they stand. Replace every one.
{ "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}Inputs
| Input | Type | Range | Required | What it is |
|---|---|---|---|---|
| sharpe_annual | number | -10 to 20 | yes | Annual Sharpe of the chosen strategy. |
| periods_per_year | whole number | 1 to 365 | yes | Periods in a year of the returns: 252, 52 or 12. |
| observations | whole number | 2 to 1000000 | yes | Number of return periods in the sample. |
| skew | number | -50 to 50 | yes | Skew of the returns. A normal is 0. |
| kurtosis | number | 0 to 3000 | yes | Kurtosis of the returns, not excess. A normal is 3. |
| trials | whole number | 1 to 1000000000 | yes | Independent trials the strategy was picked from, including every one discarded. |
| trial_sharpe_std_annual | number | 0 to 20 | yes | Stdev across the trials' annual Sharpes. |
| benchmark_sharpe_annual | number | -10 to 20 | no | Annual Sharpe to test against in the plain probabilistic figure. |
| confidence_pct | number | 50 to 99.99 | yes | Confidence to compare with, in percent. |
Hypothetical, and on made-up numbers until you replace them. Nobody traded this, and nothing here is on offer.