# Book risk: 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.** What does this return series say about annual vol, tail loss and drawdowns, and how much data sits behind each tail figure?

## Method

Annual vol = sample stdev x sqrt(periods). Historical VaR = -(type 7 quantile at 1 - c). Shortfall = -(mean of returns at or below that line). Normal VaR = -(mean + z x stdev), z = invPhi(1 - c). Cornish-Fisher VaR = -(mean + w x stdev), w = z + (z^2 - 1) S / 6 + (z^3 - 3 z) K / 24 - (2 z^3 - 5 z) S^2 / 36, S skew, K kurtosis less 3.

## Conventions

- All VaR and shortfall figures are for one period of the series, not a year, and are positive for a loss.
- The stdev divides by n - 1. Skew and kurtosis are plain moment ratios with no small-sample correction, and kurtosis is not excess: a normal is 3.
- The historical line interpolates between sorted returns (type 7). Observations past the line are those at or below it.
- Normal and Cornish-Fisher VaR use the sample mean. The expansion takes excess kurtosis, which is kurtosis less 3.
- Annual vol scales by the square root of periods, which treats periods as unrelated. The lag-one autocorrelation is shown so a reader can see when they aren't.
- The carry-over vol takes that autocorrelation as an AR(1) over one year of p periods: annual vol x sqrt(1 + 2 x sum for k < p of (1 - k / p) x rho^k). With one period a year, nothing is scaled, so it equals annual vol.
- Drawdowns compound the simple returns from a starting value of 1, so a loss in the first period counts. Length runs peak to trough, recovery runs trough to the first period back at the peak.
- Under water means below the running peak at the end of the period.
- Money figures are the percent figures on the nav sent.

## 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
{
  "returns_pct": [
    1.2, 0.8, 1, 0.6, 1.4, -0.4, 1, 0.8, 1.2, 0.4,
    0.6, 1, 0.8, 1.2, -0.6, 1, 0.6, 0.8, 1.4, 0.2,
    -6, -3, 1.6, 2, 1, 0.8, 0.4, 1.2, -0.8, 1,
    0.6, 1.2, 0.8, 0.4, 1, 0.6, 1.2, -1, 0.8, 1,
    0.6, 1.4, 0.8, -0.2, 1, 1.2, 0.4, 0.8, -4, 0.4,
    1, 1.2, 0.8, 0.6, 1, 0.4, 0.8, 1.2, 0.6, 1
  ],
  "periods_per_year": 12,
  "confidence_pct": 95,
  "nav": 100000000
}
```

Work them out with the method above. Yours should match these within 0.5%.

- Annual vol: 4.412063586 %
- Historical VaR, one period: 1.1 %
- Expected shortfall, one period: 4.333333333 %
- Normal VaR, one period: 1.581639505 %
- Cornish-Fisher VaR, one period: 2.207178466 %
- Max drawdown: 8.82 %
- Time under water: 38.33333333 %
- Observations past the VaR line: 3 observations

Where the outcome flips, with the other inputs held:

- observations at 181: At 95% confidence, a series of at least this many observations has 10 or more past the VaR line.

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:

- Positions. Only the return series is seen, so no factor, concentration or leverage view.
- Horizons longer than one period. VaR is not scaled up.
- Losses the series does not contain. History shows only what happened in it.
- Stale or smoothed marks, beyond the autocorrelation shown.
- The cost and time of getting out at the VaR line.
- Changes in the book over time. All periods count equally, with no decay.

## 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/book_risk/prompt.md. Terms: https://hedgefund.md/terms
