# Basis carry: 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 long spot, short derivative position net after costs, and how far can the price rise before the short is liquidated?

## Method

Q = notional / F. Annualized basis: perp = funding * 3 * 365, dated = (F/S - 1) * 365 / days. Gross carry: perp = notional * funding * 3 * days, dated = Q (F - S) * days / days to expiry. Net = gross - fees - Q S * financed share * rate * days / 365. Collateral C = notional / leverage * (1 - haircut). Liquidation where C - Q (P - F) = m Q P, so P = (C/Q + F) / (1 + m).

## Conventions

- The position is long Q of spot and short Q of the derivative, where Q = notional / F, so the two legs match in quantity, not in money.
- Funding is the caller's number, held flat for the whole period, paid three times a day on the entry notional. It can turn negative.
- A perp has no expiry, so its entry premium isn't counted as carry. It only pays if it closes by exit, and it's shown as a note.
- A dated future converges at expiry. A shorter stay takes a straight-line share of the basis.
- Fees are charged once, in full, whatever the holding period. Financing is simple interest on Q S * financed share over a 365-day year.
- Collateral keeps its value as the price moves: a haircut is taken once, and the collateral doesn't rise with the underlying. Maintenance margin is measured at the current price.
- Extra margin at a rise is the cash top-up that restores equity to maintenance: max(0, m Q P + Q (P - F) - C). Cash takes no haircut. The spot leg's gain isn't counted, because it's not margin until it's sold or pledged.
- Capital used is the unfinanced spot cost plus the collateral's face value. Annualized net carry on capital is net * 365 / days over that.

## 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
{
  "instrument": "perp",
  "spot_price": 1000,
  "derivative_price": 1002,
  "funding_bps_per_8h": 1,
  "notional": 1000000,
  "short_leverage": 4,
  "maintenance_margin_pct": 2,
  "fees_bps_round_trip": 12,
  "borrow_rate_pct": 8,
  "financed_share_pct": 50,
  "collateral_haircut_pct": 15,
  "holding_days": 90
}
```

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

- Annualized basis: 10.95 %
- Gross carry: 27000
- Fees and financing: 11043.32704
- Hypothetical net carry: 15956.67296
- Hypothetical net carry on capital, annualized: 8.639920053 %
- Liquidation price: 1191.102941
- Rise to liquidation: 18.87254902 %

Where the outcome flips, with the other inputs held:

- funding_bps_per_8h at 0.4090121128: Net carry is zero at this funding, held flat. Below it, including anywhere negative, the position loses after costs.
- holding_days at 6.294926777: It takes this many days of carry to earn back the fees. A shorter stay loses after costs.
- collateral_haircut_pct at 53.5: At this haircut the rise to liquidation is half of the 18.87% it is now.
- short_leverage at 42.5: At this leverage the short starts at maintenance, with no room for any rise.

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:

- Funding paths. A flat number stands in for one that resets every 8 hours.
- Liquidation mechanics: auctions, slippage, partial closes and insurance funds. After a liquidation the spot leg would be unhedged, and that's not priced.
- A margin call on the financed spot when the price falls.
- Basis moves before exit, on the marks of both legs.
- Collateral that moves with the price, and haircuts that change in stress.
- Counterparty, custody, venue and transfer delays between legs.
- Whether this person may trade this derivative or use this venue. That is a legal question for counsel.
- 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/basis_carry/prompt.md. Terms: https://hedgefund.md/terms
