HEDGEFUND.md

Models / Fund terms and risk / book_risk

Book risk

What does this return series say about annual vol, tail loss and drawdowns, and how much data sits behind each tail figure?

Takes a return series and gives annual vol, skew, kurtosis, historical VaR and expected shortfall, normal and Cornish-Fisher VaR, and the max drawdown with its length and recovery, in percent and money. All returns come from the caller. It describes the series sent. It is not a forecast of loss, and it says when too few observations sit behind a tail figure.

The paste-ready promptmodel.md

On these numbers, at 95% confidence, one period's loss line is 1.1% of NAV by history, 1.58% by a normal and 2.21% by Cornish-Fisher, with 3 of 60 observations past the historical line and a max drawdown of 8.82%.

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.

Annual vol

4.4121%

Mean of the series sent 6.16% a year, skew -3.38, kurtosis 15.65 (normal is 3).

Historical VaR, one period

watch

1.1%

1,100,000 on this NAV.

Expected shortfall, one period

watch

4.3333%

4,333,333.33 on this NAV. The mean of 3 observations.

Normal VaR, one period

1.5816%

1,581,639.50 on this NAV.

Cornish-Fisher VaR, one period

watch

2.2072%

2,207,178.47 on this NAV.

Max drawdown

8.82%

8,820,000 on this NAV. 2 periods down. Recovery: 11 periods.

Time under water

38.33%

Observations past the VaR line

watch

3observations

Of 60.

What flips it

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

  1. observations

    181

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

Flags

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

  • watch
    Only 3 of 60 observations sit past the VaR line, under 10, so the historical VaR and shortfall rest on very few points. thin_tail
  • watch
    The skew and kurtosis are outside the range where Cornish-Fisher is a proper quantile map: somewhere along the curve, a higher confidence comes with a smaller figure. Read this one as arithmetic, not as a dependable quantile. cf_out_of_range
  • watch
    What sits past the line averages 4.33%, over twice the 1.1% line. The VaR alone misses the size of the tail. shortfall_far_past_var

What this leaves out

What the formula leaves out, by name.

  • 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.
What it took as given (9)

What it took as given to get here.

  • 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.
Returns, by sizeObservations
  • Past the VaR line
  • Other observations
01020-5.5-4.5-3.5-2.5-1.5-0.50.51.5Return, %
The data
Drawdown%
-8-6-4-200102030405060Period0
The data

Tail figures, one period

Measure% of NAVMoney
Historical VaR1.11,100,000
Historical expected shortfall4.33334,333,333
Normal VaR1.58161,581,640
Normal expected shortfall2.11382,113,847
Cornish-Fisher VaR2.20722,207,178

Shape of the series

ItemValue
Observations60
Mean a period, %0.513333
Mean a year, simple, %6.16
Compound growth a year, %6.2333
Annual vol, %4.4121
Annual vol if the carry-over is real, %5.3276
Skew-3.3808
Kurtosis, normal is 315.65
Lag-one autocorrelation0.203691

Drawdown

ItemValue
Max drawdown, %8.82
Max drawdown, money8,820,000
Peak, period20
Trough, period22
Periods peak to trough2
Periods trough to recovery11
Periods under water23
Share of time under water, %38.33
Drawdown at the end, %0

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

inputs_hash e18d565433c968d9

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/book_risk.md.

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

terminal
curl -s https://hedgefund.md/api/v1/book_risk \  -H 'content-type: application/json' \  -d '{"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}' \  | jq '{summary, flags, flips, not_modeled, inputs_hash}'

Inputs

InputTypeRangeRequiredWhat it is
returns_pctarray2 to 2000 itemsyesSimple return of each period in percent, oldest first.
periods_per_yearwhole number1 to 365yesPeriods in a year: 252 for trading days, 12 for months.
confidence_pctnumber90 to 99.9yesConfidence for VaR and shortfall, in percent.
navnumberover 0 to 10000000000000yesNAV in money, for the money figures.

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.