# Deflated Sharpe: a prompt from hedgefund.md

Paste 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?

## Method

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.

## 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 numbers

The 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.1133893419

Where 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 numbers

Replace every input with the person's own. Ask for any number you don't have, and don't invent one.

## Step 3: report

Give 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.

## Limits

Results 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
