# Rates ladder: 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 would this bond ladder earn over the horizon on these yields, what does a parallel shift do to it, and what shift takes the return to zero?

## Method

Flows at t_k = maturity - k / f. Dirty = sum CF_k / (1 + y / f)^(f t_k). Accrued = coupon per period * (1 - f * first t). Macaulay = sum t PV / dirty. Modified = Macaulay / (1 + y / f). Convexity = sum t (t + 1 / f) PV / dirty / (1 + y / f)^2. DV01 = modified * dirty * 0.0001. Estimate = dirty (-modified s + 0.5 convexity s^2). Horizon value = sum over flows after H of CF / (1 + y / f)^(f (t - H)).

## Conventions

- Time is in plain years, and flows are counted back from maturity. A fraction of a period at the front is a stub.
- The stub is discounted with a fractional exponent, and accrued interest is straight-line across the coupon period.
- DV01, duration and convexity are on the dirty price. Convexity includes the 1 / f term that goes with periodic compounding.
- Each bond's yield shifts by the same amount in a shock. Book totals add the bonds, so book duration and convexity are value-weighted.
- Coupon carry is the coupon earned over the horizon on an accrual basis: coupons paid plus the change in accrued.
- Pull to par is the rest of the horizon return at unchanged yield.
- Roll-down moves each bond's yield by the curve's change from maturity to shortened maturity, by straight-line interpolation, flat past the ends. The bond's own gap to the curve stays the same.
- Cash paid inside the horizon sits idle, with no reinvestment. Horizon returns aren't annualized.
- The shift that flips the horizon return is applied at the horizon date, on top of roll-down, and found by repricing every flow.

## 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
{
  "bonds": [
    {
      "name": "Bond 1.25y",
      "face": 1000000,
      "coupon_pct": 3.5,
      "maturity_years": 1.25,
      "yield_pct": 3.9,
      "freq": 2
    },
    {
      "name": "Bond 2.5y",
      "face": 1000000,
      "coupon_pct": 4,
      "maturity_years": 2.5,
      "yield_pct": 4.1,
      "freq": 2
    },
    {
      "name": "Bond 3.75y",
      "face": 1000000,
      "coupon_pct": 4,
      "maturity_years": 3.75,
      "yield_pct": 4.3,
      "freq": 4
    },
    {
      "name": "Bond 5y",
      "face": 1000000,
      "coupon_pct": 4.5,
      "maturity_years": 5,
      "yield_pct": 4.5,
      "freq": 1
    },
    {
      "name": "Bond 10y",
      "face": 1000000,
      "coupon_pct": 5,
      "maturity_years": 10,
      "yield_pct": 5.1,
      "freq": 2
    }
  ],
  "shocks_bps": [-100, -50, 50, 100, 200],
  "horizon_years": 0.5,
  "curve": [
    { "years": 0.5, "yield_pct": 3.6 },
    { "years": 1, "yield_pct": 3.8 },
    { "years": 2, "yield_pct": 4 },
    { "years": 3, "yield_pct": 4.2 },
    { "years": 5, "yield_pct": 4.5 },
    { "years": 10, "yield_pct": 5 }
  ]
}
```

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

- Dirty value: 4983423.6
- Modified duration: 3.8313 years
- DV01: 1909.2996
- Convexity: 23.9715
- Coupon carry over the horizon: 2.107 % of dirty value
- Roll-down over the horizon: 0.2404 % of dirty value
- Hypothetical horizon return: 2.4215 %
- Shift that takes it to zero: 72.0433 bps

Where the outcome flips, with the other inputs held:

- parallel_shift_bps at 72.0433: A parallel yield move of this size at the horizon takes the ladder's 0.5-year return to zero, found by repricing every flow. Past it, toward higher yields, the return is negative.

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:

- Reinvestment of coupons and of any principal paid back inside the horizon.
- Moves that aren't parallel, other than the one roll-down path.
- Default, calls, amortization, inflation links and floating coupons.
- Day counts, settlement lags and holiday calendars.
- Repo or other financing of the ladder, bid-ask, fees and taxes.

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