Models / Digital assets / basis_carry
Basis carry
What does this long spot, short derivative position net after costs, and how far can the price rise before the short is liquidated?
Computes a long spot, short derivative position: annualized basis, net carry after fees and financing, the price rise that liquidates the short, extra margin needed at larger rises, and the funding where net carry is zero. Prices, funding and rates come from the caller. Funding can turn negative. Not a quote, a forecast or advice.
On these numbers, the perp position shows an annualized basis of 10.95%, a hypothetical net of 15,956.67 over 90 days after fees and financing, and a price rise of 18.87% from entry liquidates the short.
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.
Annualized basis
10.95%
Funding * 3 * 365. Entry premium of 0.2% isn't counted as carry.
Gross carry
27,000
Over 90 days.
Fees and financing
11,043.33
Fees 1,200, financing 9,843.33.
Hypothetical net carry
15,956.67
Hypothetical net carry on capital, annualized
8.6399%
On capital used of 749,002.
Liquidation price
1,191.1
Rise to liquidation
watch18.87%
From the derivative price at entry.
What flips it
The value of one input where the outcome changes, with the others held.
funding_bps_per_8h
0.409012bpsnow 1
Net carry is zero at this funding, held flat. Below it, including anywhere negative, the position loses after costs.
holding_days
6.2949daysnow 90
It takes this many days of carry to earn back the fees. A shorter stay loses after costs.
collateral_haircut_pct
53.5%now 15
At this haircut the rise to liquidation is half of the 18.87% it is now.
short_leverage
42.5timesnow 4
At this leverage the short starts at maintenance, with no room for any rise.
Flags
What went past a line, and what to read before you trust the rest.
- watchFunding can turn negative. The 1 bps per 8 hours is the caller's number, held flat, and not a forecast. funding_is_the_callers_number
- watchA rise of 18.87% liquidates the short unless more margin arrives. The long spot gains the same move, but it's not margin until it's sold or pledged. thin_liquidation_distance
What this leaves out
What the formula leaves out, by name.
- 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.
What it took as given (8)
What it took as given to get here.
- 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.
The data
The data
The position
| item | value |
|---|---|
| quantity_q | 998 |
| spot_cost | 998,004 |
| financed_spot | 499,002 |
| collateral_face | 250,000 |
| collateral_after_haircut | 212,500 |
| capital_used | 749,002 |
Extra margin needed as the price rises
| rise_pct | price | short_leg_loss | spot_leg_gain | maintenance_required | equity_before_top_up | extra_margin_needed | extra_as_pct_of_capital |
|---|---|---|---|---|---|---|---|
| 10 | 1,102.2 | 100,000 | 101,996 | 22,000 | 112,500 | 0 | 0 |
| 25 | 1,252.5 | 250,000 | 251,996 | 25,000 | -37,500 | 62,500 | 8.3444 |
| 50 | 1,503 | 500,000 | 501,996 | 30,000 | -287,500 | 317,500 | 42.39 |
| 100 | 2,004 | 1,000,000 | 1,001,996 | 40,000 | -787,500 | 827,500 | 110.48 |
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/basis_carry.md.
# Basis carry: 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 long spot, short derivative position net after costs, and how far can the price rise before the short is liquidated?## MethodQ = 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 numbersThe 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 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:- 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.## 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/basis_carry/prompt.md. Terms: https://hedgefund.md/termsCall 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/basis_carry.
curl -s https://hedgefund.md/api/v1/basis_carry \ -H 'content-type: application/json' \ -d '{"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}' \ | jq '{summary, flags, flips, not_modeled, inputs_hash}'The tool is basis_carry on https://hedgefund.md/mcp.
curl -s https://hedgefund.md/mcp \ -H 'content-type: application/json' -H 'accept: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"basis_carry","arguments":{"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}}}' \ | jq '.result.structuredContent | {summary, flags, flips, not_modeled, inputs_hash}'One file with no dependencies, and nothing is sent anywhere.
curl -fsSL https://hedgefund.md/hedgefund.mjs -o hedgefund.mjs # read it before you run itnode hedgefund.mjs template basis_carry > mine.json # replace every number in itnode hedgefund.mjs run basis_carry mine.json | jq '{summary, flags, flips, not_modeled, inputs_hash}'Made-up numbers that run as they stand. Replace every one.
{ "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}Inputs
| Input | Type | Range | Required | What it is |
|---|---|---|---|---|
| instrument | string | perp | dated | yes | The short leg: a perpetual with funding, or a future with an expiry. |
| spot_price | number | 0.000001 to 1000000000 | yes | Spot price. |
| derivative_price | number | 0.000001 to 1000000000 | yes | Price of the short leg at entry. |
| funding_bps_per_8h | number | -1000 to 1000 | no | Perp only, and required for it. Funding a short receives per 8 hours, in basis points. Negative means the short pays. |
| days_to_expiry | number | 0.01 to 3650 | no | Dated only, and required for it. Calendar days to expiry. |
| notional | number | 0.01 to 10000000000000 | yes | Size of the short leg at the derivative price. |
| short_leverage | number | 0.01 to 200 | yes | Notional over posted collateral on the short leg. 4 means 4 times. |
| maintenance_margin_pct | number | 0 to 100 | yes | Maintenance margin as a share of the short's value at the current price. |
| fees_bps_round_trip | number | 0 to 1000 | yes | All entry and exit costs on both legs, in basis points of notional, charged once. |
| borrow_rate_pct | number | 0 to 200 | no | Yearly rate on any financed spot. 8 means 8%. Default 0. |
| financed_share_pct | number | 0 to 100 | no | Share of the spot cost that is borrowed. Default 0. |
| collateral_haircut_pct | number | 0 to 100 | no | Haircut on the posted collateral. Default 0. |
| holding_days | number | 0.01 to 3650 | yes | Calendar days the position stays on. |
Hypothetical, and on made-up numbers until you replace them. Nobody traded this, and nothing here is on offer.