Skip to main content
Offset the risk your traders’ accounts add up to. Your traders trade on trdrs, and their fills, balances and profit and loss stay there. A hedge is always your venue’s own order in a provider account your venue owns. You make a hedging policy once and pick it for any of your groups. Each stage of an evaluation is its own group, so each stage picks its own. A policy hedges at one provider connection, its hedge market, in one of two ways:
  • Net: trdrs nets every account the policy covers, across every group that picks it, and holds a share of what is left in your one hedge account at the hedge market.
  • Copy: each customer account has its own hedge account at the hedge market, and trdrs holds a share of the account’s position in it.
Either way trdrs sizes the hedge after every fill, on its own. A market the hedge market doesn’t list stays on your book. Use this page if you run groups on the paper book and want to carry the opposite side of their exposure at a real market. By the end you have a policy in force, picked by a group, and know how to watch, pause and stop it.
Hedging is a preview, served on the sandbox. A policy that copies picks up a group only where the hedge market states its margin for each instrument it copies in its symbol list.

See how a hedge works

  1. Your traders trade their accounts. Nothing about their orders changes, and the paper book fills them first.
  2. After each fill, trdrs reads a fresh price and sizes the hedge: the net of every account the policy covers, or the one account’s position for a copy, times the policy’s share, rounded toward zero to the instrument’s step, less what the hedge account holds and what is already on its way.
  3. If there’s a gap, trdrs saves a target and prepares one order, an intent, for the difference. A gap smaller than the policy’s smallest order waits, recorded on the target, unless the order takes the hedge to flat.
  4. trdrs sends the intent to your hedge account as a market order that fills at once or cancels, and records what the provider did with it.
A hedge places orders only in your hedge accounts, so every trader’s orders and fills stay their own. A hedge that fails changes only your hedge report.

Before you start

  • Connect a provider. Plug in a public provider, create a connection and pass its validation. The provider must be able to hold accounts and take orders.
  • Bind your hedge account. From the accounts the validation discovered, bind the one your venue owns with POST /api/venues/{venueId}/accounts/bind and "mode": "hedge". Bind it with a Venue key that carries connection:manage, hedge:manage and hedge:execute, or use the Back Office signed in with a role that grants those permissions. The account must use the net position model, and it can’t be shown or granted to a trader. A net hedges into one such account; a copy needs one for each customer account.
  • Or hedge into your company Hyperliquid account. On the sandbox, once your company Hyperliquid account is connected, an owner sets it up as a hedge account in one step in the Back Office. trdrs serves its connection itself, from the trading key it keeps for the account, so there’s no provider to plug in: the connection, its validation and the bound hedge account appear with your venue’s others, and a policy picks it by its hedgeAccountId. On production this step isn’t open yet.
  • Activate the instruments you’ll hedge, each mapped at the hedge market.
  • Give your Venue key the hedge scopes. hedge:read reads the report, hedge:manage makes, changes and picks policies, and hedge:execute resumes them, sends, reconciles and flattens.
The examples use the variables from Run a venue.
1

Make a hedging policy

Name it, and state what it does. Both ways’ settings are stated whatever its mode.Required scope: hedge:manage.
  • connectionId is the hedge market.
  • hedgeAccountId is your hedge account there that the net goes into. Send null until you bind one: the net is then worked out and never sent.
  • net.ratio is the share of the net hedged, from "0" to "1". net.minHedgeNotional is the smallest order, in US dollars. Where the hedge market’s own minimum order value is larger (Hyperliquid’s is $10), that is the smallest order instead, so no order is ever sent that the hedge market refuses as too small. net.notionalCap is the largest hedge on one market, in US dollars, or null for none.
  • What is worth less than the smallest order is carried, not dropped: each target in GET /api/venues/{venueId}/hedges shows it as leftover, such as { "quantity": "0.04", "notional": "6.12", "minimum": "10" }, and once the net adds up to minimum one order hedges it with the rest.
  • net.leverage is optional: the leverage your hedge account holds each market’s hedge at, such as [{ "instrumentId": "BTC", "leverage": 20 }], by your id for the instrument. A market you leave out is held at 10x, or the highest its hedge market allows where that is lower. See Check the net.
  • net.threshold is optional: hold the net’s orders until the hedge drifts more than an amount. See Hedge the net in steps.
  • net.cross is optional: hedge a market your hedge market doesn’t list in one it does. See Cross hedge a market.
  • net.placement is optional: send a large order in slices over time, evenly or by volume. See Send large orders in slices.
  • copy is the same for each trader, set out under Copy each trader.
  • rules hedge some trades another way: see Rules.
The response is 201 with the policy: its id, state (active), revision, its terms in force and the groups that pick it.
2

Pick it for a group

Each group picks one policy, or null to keep its trades on your book.Required scope: hedge:manage, and hedge:execute as well while the policy is active.
From here on each fill of an account in the group is hedged. A policy that copies checks the group first: see Copy each trader. A group whose copies are still held at one hedge market can’t pick a policy that copies at another until you close them.
3

Read the hedge report

Read every policy, target, intent and open incident for your venue.Required scope: hedge:read.
hedgingPolicies lists your policies. A net’s targets name their hedgingPolicyId and no group, since the net spans every group that picks it. The report also gives the number of executions, adverse slippage in basis points, fees grouped by currency and a complete flag. Missing fee data, unsettled orders and open incidents mark the report incomplete rather than reading as zero.
4

Pause, resume or change it

Pause or resume a policy for every group that picks it, at the revision you read. Pausing cancels the orders it prepared and hadn’t sent. Resuming needs hedge:execute too.
Change it with POST /api/venues/{venueId}/hedging-policies/{hedgingPolicyId}, sending the name, the whole terms and expectedRevision. The new terms are in force at once for every group that picks it. A change that moves a hedge still held is refused: a net hedge account that holds a position or has an order on its way (hedge_account_holds_position), or copies held at a hedge market the new terms leave (hedge_market_in_use). Flatten or reconcile first.Delete it with DELETE /api/venues/{venueId}/hedging-policies/{hedgingPolicyId}, sending {"expectedRevision":3}, the revision you read, once no group picks it and its hedge account holds no position and has no order on its way. Otherwise the refusal names hedging_policy_picked or hedge_account_holds_position in blockers. A deleted policy stops at once and leaves the list, its hedge account can carry another hedge, and the hedges it made stay in the report.
A net hedge that fails is sized again after a short wait that doubles each time: 1, 2, 4 and 8 seconds. Only when the fifth try in a row on the same market fails, about 15 seconds after the first, does trdrs open an incident on the policy and send hedge.failure, once while the incident stays open. The incident’s details state tries, firstFailedAt and the reasons of the tries, and hedge.failure carries tries. After that trdrs sizes it again once a minute while it is still failing. A hedge is sent while the hedge account’s view catches up with a fill it just made, and is read back filled the moment its own fill arrives. A hedge refused only because that view is catching up, such as another market’s hedge a moment before, is not a failure: it waits for the view and is sent again, and opens an incident only if the view stays stale for a minute.

A market the hedge can’t cover takes no new trades

While a group picks a hedging policy that is active or paused, its accounts open nothing the policy can’t hedge: a market its hedge market lists no symbol for, which its net hedges in no other market. A builder-deployed Hyperliquid market with no symbol at your hedge account is one.
  • An order that opens or adds to a position there is refused 422 instrument_not_hedgeable, with the error “new trades on XYZ:TSLA are closed because the venue’s hedge cannot cover it; closing and reducing still work”. Closing, reducing and cancelling still work.
  • The account’s instrument list (GET /api/venues/{venueId}/accounts/{accountId}/instruments) lists the market with instrument_not_hedgeable in blockedBy, so a picker can grey it out.
  • A paused policy refuses them too: once resumed it hedges every position its accounts hold, and it could never hedge these. A stopped policy, or a group that picks none, refuses nothing for this.
  • A market a rule keeps on your book, though the hedge market lists it, is your choice and stays open.

A failed hedge pauses new trades

So your venue never carries a position the policy should have hedged for long, a net hedge that still fails after its tries also pauses new trades on its market, for every group that picks the policy, while the policy is active:
  • An order that opens or adds to a position on that market is refused 422 hedge_failed, with the error “new trades on BTC-PERP are paused because the venue’s hedge of it failed; closing and reducing still work”. An order that would take a position past flat to the other side counts as adding.
  • Closing, reducing and cancelling still work.
  • A failure of the whole net, such as a hedge account that can’t trade (instrumentId *), pauses every market the net hedges. A market a rule keeps on your book, or copies, isn’t paused.
  • hedge.failure carries entriesPaused: true, and the incident in the hedge report (GET /api/venues/{venueId}/hedges) carries entriesPaused: true while it pauses.
The market reopens by itself once a hedge there fills whole, or a sizing finds the net in balance with nothing on its way. To reopen it at once, after you checked the net yourself, send POST /api/venues/{venueId}/hedging-policies/{hedgingPolicyId}/resume-trading with {"instrumentId":"BTC-PERP"} for one market, or {"instrumentId":null} for every market the policy paused. It needs hedge:manage and hedge:execute. A hedge still failing pauses the market again once its tries fail again. The money check’s incident (*collateral) and the script’s (*script) pause nothing; its near-liquidation incident (*liquidation, under Check the net) pauses every market. Pausing the policy lifts the pause too, since a paused policy hedges nothing: that is how you choose to carry the risk yourself.

Check the net

A policy that nets, by its mode or one of its rules, carries netChecks in the list of policies (GET /api/venues/{venueId}/hedging-policies) and in the hedge report’s hedgingPolicies: the money its hedge account needs beside what it holds, and what each group that picks it should know. A pick’s answer carries the group’s own part as netWarnings. These are warnings: none stops hedging or refuses a pick.

The money the hedge account needs

netChecks.money prices what the hedge account holds now, at the marks the net was last sized at:
  • initialMargin: what Hyperliquid asks to hold each market’s hedge at the leverage it is held at, added up.
  • maintenanceMargin: the level Hyperliquid closes the hedge under.
  • lossRoom: what the hedge account can lose as your traders lose down to their loss floors. In each market it holds, only the traders whose netted position points the same way as the hedge count, each at the share the policy nets. A trader on the other side gains as they lose, so it counts nothing, and the count is never more than the hedge itself loses before they reach their floors. Each trader counts once.
  • needed: the larger of initialMargin, and maintenanceMargin plus lossRoom. That is enough to hold every hedge and ride the traders’ losses down to their floors without Hyperliquid closing it.
  • held: the hedge account’s equity as its provider last stated it. shortfall is how far it falls below needed, or "0".
markets shows each market’s position, mark, notional, leverage and both margins. A figure that can’t be stated is null, and reason says why. For example, you sell a $25,000 account for $1,000, and it fails $900 below where it started. Its trader opens the largest BTC position the account allows, $36,000 at 40x, and the net hedges it whole at 40x:
  1. Initial margin: $36,000 / 40 = $900.
  2. Maintenance margin: $450, half of that at 40x.
  3. Loss room: $900, all of it still to lose.
  4. Needed: the larger of $900, and $450 + $900, so $1,350.
A hedge account that holds only the $1,000 the trader paid is $350 short. Now a second trader sells the same $36,000 of BTC. The net is flat, so the hedge account closes its BTC and holds none. It needs nothing for BTC: whatever one trader loses, the other gains. Where three traders hold the long and one the short, only the three longs’ loss room counts, and never more than the hedge loses before they reach their floors. trdrs checks it each time it sizes the net, and every minute between fills. Each time held falls below needed, it opens an incident on the policy (instrumentId *collateral, reason hedge_collateral_short, the figures in its details) and sends hedge.failure with that reason, once. The incident resolves when the account holds enough again. Hedging goes on either way: add money to the hedge account, or hedge less. Nearer the edge it stops new trades. Hyperliquid closes a hedge account whose value falls below its maintenance margin, so when held falls under twice maintenanceMargin, the check opens a second incident (instrumentId *liquidation, reason hedge_near_liquidation) that pauses new trades on every market the net hedges, and sends hedge.failure with that reason, entriesPaused: true and topUp: what moving in clears both the pause and needed. In the example, $36,000 of BTC at 40x keeps $450 of maintenance margin, so a hedge account under $900 pauses. Hedges that reduce the net still go out. A hedge that goes through and resume-trading leave it: only a money check that finds the account clear lifts it.

What each group should know

netChecks.groups lists each group that picks the policy, over the markets it trades that the policy nets:
  • notMapped: the markets the hedge market doesn’t list. Their trades stay on your book, unhedged, until you map them there. The report’s exchanges.hedgeMarkets names them too, under the policy’s hedge market, and notOnHedgeMarket turns true.
  • leverage: the markets where the group lets a trader use more leverage than the hedge is held at, each with the trader’s most (traderLeverage, from the group’s risk policies) and the hedge’s (hedgeLeverage). The hedge account then needs more margin than the traders post, which the money check counts. Raise the hedge’s leverage, lower the group’s, or hold more money in the hedge account.

The leverage the hedge is held at

Your company Hyperliquid account holds each market’s hedge in cross margin, at the policy’s net.leverage for the market or, where it names none, at 10x, or the highest the hedge market allows there where that is lower. Hyperliquid liquidates a cross account once its value falls under its maintenance margin, whatever the leverage; the leverage caps how much the account can open on what it holds. At BTC’s 40x, an account holding all it can is liquidated by a 1.25% move; at 10x by 8.75%. trdrs sets it at Hyperliquid before the first hedge order in a market, and again before the next one whenever the policy changes it. A leverage above the highest the hedge market allows is refused when you make or change the policy (hedge_leverage_above_max). A leverage that can’t be set sends no order: the hedge fails with reason hedge_leverage_not_set, opens an incident and sends hedge.failure, and trdrs sizes it again as for any failed net hedge. A policy that names a leverage for a hedge account at any other provider fails this way too, since trdrs sets leverage only on your company Hyperliquid account. Without one, such an account trades at the leverage it already holds.

Hedge the net in steps

By default the net is sized after every fill, so each fill that moves it by at least minHedgeNotional sends an order. Threshold hedging sends fewer, larger orders instead: set net.threshold to a start and a target, both in US dollars.
On each market, trdrs compares the hedge the net calls for with what your hedge account holds and has on its way in. While they differ by $250,000 or less, nothing is sent and the difference waits on the target as `unsentQuantity`. Once a fill takes them more than $250,000 apart, one order brings them back to $50,000 apart, on the side they differed, rounded to the market’s step so it is never more. A target of "0" hedges all of it. target must be below start, or the policy is refused 400 threshold_target_not_below_start at net.threshold.target. When the net calls for no hedge on a market, because the traders closed, the hedge there closes whatever the threshold. minHedgeNotional and notionalCap hold as before. Leave threshold out, or send null, to size after every fill.

Cross hedge a market

A market your hedge market doesn’t list stays on your book. Cross hedging hedges it in another market instead, at a ratio of its value in US dollars:
When the traders the net covers are long $100,000 of PEPE, the net hedges $80,000 of it in ETH, on top of whatever ETH it hedges for ETH trades. trdrs values the PEPE net at PEPE’s mark and converts the dollars into ETH at ETH’s mark, at each sizing.
  • ratio is above zero and at most 10; it can be above 1 for a market that moves more than the one you hedge it in.
  • hedgeInstrumentId must be listed at the hedge market, or the policy is refused 409 not_ready with cross_hedge_not_on_hedge_market. It can’t be the same market (cross_into_itself) or a market that is itself crossed (cross_chain), and each market is crossed once (duplicate).
  • A crossed market is never hedged in itself. If your hedge market does list it, the hedge held there closes and the cross takes over.
  • notionalCap, threshold and minHedgeNotional apply to the whole hedge in hedgeInstrumentId.
  • While the crossed market has no fresh mark, the hedge it is crossed into waits. One quoted in neither USD nor USDC can’t be valued in dollars: its hedge fails with reason cross_value_unknown.
  • Only the net crosses. A rule that copies a market the hedge market doesn’t list still keeps it on your book.
  • The money check prices what the hedge account holds, so it counts the ETH margin. Its loss room counts only the traders of the market the hedge is in, not those crossed into it.

Send large orders in slices

By default each order the net calls for goes to the hedge market at once. A time-weighted average price (TWAP) placement sends a large one in equal slices over time instead:
An order worth more than $250,000 goes in 5 slices, one every 60 seconds: a $1,000,000 order is five orders of $200,000, a minute apart. An order worth $250,000 or less goes at once. The order is a parent order: GET /hedging-policies/{hedgingPolicyId}/parent-orders reads each one the net placed, with how many of its slices came due, what they filled, at what average price, when the next is due, and each slice. The net works at most one on each market.
  • Each slice is the order’s share, rounded up to the market’s step, so the order never takes more than slices slices.
  • Each slice is due at its time from the start: slice k is due k times seconds / slices after the first, so the last is due inside seconds. A slot sized late is still due at its time, and a slot that passed with nothing sized is passed over.
  • When a slice is due, trdrs sizes the net again. The next slice goes, or, once what is left is no more than a slice, all of it. If the traders turned the net to the other side, the order ends and the new order is sized afresh. What waits for its slice is on the target as unsentQuantity.
  • A net that grows while its order works doesn’t add slices: after its last slice the order ends, and what the net still calls for is sized afresh, as a new order in slices where it is worth more than over.
  • Pausing, stopping or deleting the policy, an emergency stop, or publishing it with another placement ends its order cancelled; what its slices sent stands. A policy that runs again sizes its net afresh.
  • With a threshold, its start holds only the first slice; the rest go on to its target.
  • slices is from 2 to 100 and seconds from 1 to 86,400 (a day). seconds must be at least slices, so slices are a second or more apart, or the policy is refused 400 twap_interval_too_short at net.placement.seconds.
  • A slice must be worth at least minHedgeNotional: over must be at least minHedgeNotional times slices, or the policy is refused 400 twap_slice_below_min_notional at net.placement.over.
  • Only the net places in slices. A copied hedge goes at once.
  • An iceberg (an order that shows only part of its size) isn’t offered: no hedge market trdrs reaches takes one. A kind other than market or twap is refused 400 unsupported_value at net.placement.kind.
Leave placement out, or send null or { "kind": "market" }, to send each order at once.

Rules

A rule hedges some trades another way than the policy’s mode. trdrs reads the rules top to bottom, and the first that matches decides; the policy’s mode covers the rest. A rule matches one instrument, by your id for it, every instrument of one risk class (futures, crypto_derivative or fx_cfd), the orders over a size, or the accounts whose recent results are over a return. It keeps the trades on your book, nets them, or copies them, at its own ratio.
Under these rules a net policy keeps gold on your book, copies each trader’s crypto at 100% into their own hedge account, and nets the rest. A trade the rules move into the net goes into the policy’s hedge account, so name one; a trade they copy needs each customer account’s own hedge account, and holds the group to the checks a copy needs. A rule { "match": { "kind": "order_notional", "over": "1000000" }, "mode": "copy", "ratio": "1" } copies whole the part of a position each order over 1,000,000 US dollars of filled notional opened, while the rules below it and the mode decide the rest. trdrs splits each position by the orders that opened it, from its fills, and a sale or a stop closes the oldest part first. An order’s notional is its filled quantity times its price times the contract multiplier, for an instrument quoted in US dollars or USDC. An instrument quoted in another currency has no size in dollars, so a rule that needs one leaves that instrument’s hedge as it is and records the failure order_notional_unknown; place an instrument or class rule above it to decide such an instrument first.

Match accounts by their results

A rule can pick accounts by how they’ve done:
This copies whole every trader up more than 5% over the last 30 days who had a fill on at least 5 of them. returnOver is a share, from -1 to 10: 0.05 is 5%, and below zero picks accounts down more than that. days is from 1 to 365, and minTradingDays at most days.
  • The window is the days whole UTC days before today. Today’s trading counts from tomorrow.
  • The return is the trading profit and loss the account booked in the window, after commission, fees, financing and funding, over its balance when the window began, or what it opened with where it opened since. A position still open counts only what it has realized. An account that held no money matches nothing.
  • A trading day is a UTC day in the window with a fill.
  • Once a day. trdrs works out each account’s figures the first time they are read on a UTC day and keeps them for the rest of it, so every fill that day reads the same answer.
  • What it holds moves with it. When the day turns, trdrs sizes every hedge again. An account that starts matching is hedged as the rule says, its open positions included; one that stops goes back to what the rules below and the mode say, and the hedge the rule held for it closes. A rule that copies needs each account it may match to have its own hedge account.
Read where an account stands with GET /api/venues/{venueId}/accounts/{accountId}/hedging-results (scope hedge:read): for each results rule of its group’s policy, the figures and matches.

Write your hedging in code

When the settings above don’t say what you want, give a policy that hedges the net a script: a short TypeScript function that reads the net as it stands and answers the hedge it wants in each market. trdrs runs it on every sizing of the net and places its answer under every limit the policy states: notionalCap, the market’s step, minHedgeNotional, placement (each order at once or TWAP), the money check and the emergency stop. The script never sends an order itself, and closing works as always: a market it leaves out is hedged to none, which closes what the hedge account holds there. A script that is on takes the place of the policy’s rules’ shares, its cross hedges and its threshold; it can read what those would do, and do the same or something else.

What a script reads

Its default export is called with one argument, HedgeInput in @trdrs/script-sdk. Every quantity is a number, signed in the market’s own quantity (long above zero), as the hedge account holds it.
instruments lists every market the covered accounts hold, the hedge account holds or has an order on its way in, and those the policy crosses them into. accounts lists every covered account that holds a position. An account’s results are the same figures a results rule reads, worked out once a UTC day, over each window the script’s version names in resultsDays ([30] unless you say).

What a script answers

It answers HedgeAnswer: the position it wants the hedge account to hold in each market, as a quantity, not a dollar value.
A number is read to 15 significant digits, so 0.1 + 0.2 reads as 0.3; send decimal text, with at most 18 places, for more. trdrs then caps the hedge at notionalCap, rounds it toward zero to the market’s step, and sends the difference from what is held and on its way under minHedgeNotional and placement, as it sends the policy’s own sizing. An answer that names a market not in instruments, asks for a hedge other than 0 in one the hedge market doesn’t list, or isn’t this shape fails as script_answer_invalid.

Where it runs

A script runs in the same sandbox as a strategy: no network, no files, and no module but @trdrs/script-sdk. It has no clock beyond now and no randomness: Date.now(), new Date() with no argument and Math.random() throw. The same input always gives the same answer. Each run has 250 ms and 64 MB of memory. Import the types alone (import type), which costs nothing at run time.

When it breaks

A run that throws (script_error), runs past 250 ms (script_timeout) or 64 MB (script_memory), or answers no hedge (script_answer_invalid) falls back to the policy’s own terms for that sizing, and is recorded with its reason and message. The first failure in a row opens one incident on the policy, instrumentId *script with reason hedge_script_failed, listed in GET /hedges, and sends hedge.failure with that reason, scriptReason and mode. Each failure after it adds to failuresInARow on the script and on the incident, which stays open: a hedge that goes through doesn’t resolve it. The next run that answers resolves it and sets failuresInARow back to 0.

Modes, versions and runs

  • off (where a script starts): it doesn’t run.
  • watch: it runs on every sizing and its runs record what it would have hedged, while the policy’s own terms trade. Nothing more is traded.
  • on: its answer is what the net hedges. Turning it on, or saving a version while it is on, also needs hedge:execute while the policy is active.
Owners and editors save a script and change its mode, as they change the policy’s terms; members read it. Each save is compiled first, and a source that doesn’t compile is refused 400 script_compile_failed with each error’s line, col and message in diagnostics. A save is a new version, with who saved it and when, and the policy runs it from then on in the mode it has. Set the policy back to any earlier version with POST /script/version. Each run lists, for every market the hedge market lists with a fresh mark, wanted (what the script asked for), target (within notionalCap and the step), held, pending, delta (the order it calls for, before minHedgeNotional and placement) and policyTarget (what the policy’s own terms call for). A run is recorded when its input, version, mode or outcome differs from the last, and the last 200 are kept. A try answers the same shape and records nothing.

Two examples

The threshold setting, as a script. On the same book it sends the orders "threshold": { "start": "1000000", "target": "400000" } sends:
Hedging the traders who are winning, as a script. On the same book it hedges what a results rule { "kind": "results", "returnOver": "0.05", "days": 30, "minTradingDays": 5 } that nets them, with the policy’s ratio "0" for the rest, hedges:

Copy each trader

A policy with "mode": "copy" copies each fill of a customer account into that account’s own hedge account at the hedge market. A customer account has at most one hedge account at each hedge market. The copy is sized from the account’s position, so it is right after every fill, a restart or a missed fill alike.
  • Copy ratio: the share of the position the hedge account holds. With copy.basis: "fixed" it is copy.ratio. With "budget" it is what the trader paid for the account, the hedge budget you send when you issue it, over the account’s max loss, the drawdown its stage allows, and never more than copy.ratio. A trader who paid $400 for an account that fails at a $400 loss is copied whole.
  • Size: the account’s position times its copy ratio, as above. A difference whose notional is below copy.minHedgeNotional, in US dollars, waits, unless it takes the copy to flat.
  • Failures: a copy the market refuses is sized again after a short wait that doubles each time, opens an incident on the account and sends hedge.failure. Failures count for each hedge account on its own. At copy.failureLimit failures in a row, trdrs halts the account’s opening orders on the instruments that hedge market hedges, refused as entry_halted: reductions and cancels still work. Reconcile the account to lift it.
  • Close on fail: when the account fails, halts by a rule or is stopped out, trdrs flattens its hedge account and closes its binding, and sends hedge.closed. Bind a hedge account again for the account’s next attempt.
  • Checks: an active policy that copies is in force on a group only when the hedge market states its margin for each instrument it copies, and no account of the group is held to looser margin terms than the hedge market’s at the largest position it can hold. Under "budget" every bound account must also state its hedge budget. A refusal names every blocker in blockers.
  • Hedge collateral: the report states, for each binding, what its hedge account must hold: the account’s copy ratio times the initial margin the hedge market asks for the largest positions the account can hold in the instruments it hedges, under your leverage and notional limits, plus its max loss. Where the account’s stage makes margin count only the money above the loss floor (sandbox only), the account opens positions on its max loss alone, so the hedge account holds the larger of the two, not their sum: about $900 for a $25,000 account bought for $1,000 with a $900 loss limit, rather than about $25,900. Fund each hedge account with at least that. It is null, with the reason, while a figure it needs is not stated.
1

Issue accounts with their hedge budget

Send hedgeBudget, what the trader paid in US dollars and cents, when you issue the account. It is part of the issue’s referenceId, and the account list reads it back.
2

Bind each customer account to its hedge account

Bind each hedge account at the hedge market in hedge mode first, as above, then pair it with its customer account. While bound, the customer account has only that hedge account at its hedge market, and the hedge account only that customer account. The answer names its connectionId.Required scopes: hedge:manage and hedge:execute.
Each account in GET /api/venues/{venueId}/accounts lists its bound hedge accounts in hedgeAccounts, each with its hedgeAccountId and connectionId, one at each hedge market. A closed binding leaves the list.
3

Reconcile an account its failures halted

Once you have settled what failed, reconcile the account: the failures of each of its hedge accounts start again from none, its incidents resolve, its halts lift and its copies are sized again. The answer lists each binding in hedgeAccounts and says in resumed whether a halt lifted.Required scope: hedge:execute.
The report’s exchanges lists the exchanges your activated instruments list on. mixed warns that they list on more than one, and notOnHedgeMarket that some are not mapped at a hedge market that copies or nets them.

Earn a builder fee on Hyperliquid hedges

At Hyperliquid, a policy can carry your builder fee: a share of each hedge order’s notional that Hyperliquid moves from your hedge account to your builder address. Each hedge order also pays Hyperliquid its own trading fee. Your traders pay both on paper, so a hedge account never pays more than its trader’s paper account is charged.
Sandbox only for now: the only Hyperliquid provider service trdrs runs is the testnet one.
Add builder to the policy’s terms:
  • address is where the fee is paid. trdrs keeps it in lowercase. Hyperliquid requires it to hold at least 100 USDC of perpetuals account value, in the standard account abstraction mode, and you claim its fees as referral rewards.
  • feeBps is the fee per side in basis points: "5" is 0.05%, charged when a hedge opens and again when it closes. It is above zero, to a tenth of a basis point, and at most "10" (0.1%), Hyperliquid’s cap on perpetuals.
Every order the policy sends carries it: an opening or closing hedge, a net, a resize after a reconcile, and each close of a flatten of its hedge account. A flatten whose approval is short is the one exception, so a position always closes (see below). Your traders’ own orders never do. The fee is in force only when all of these hold, and trdrs checks them when you pick the policy for a group while it is active, resume it, change it while it is active, or bind a customer account to its hedge account under it:
  1. Your traders pay both fees on paper. Each group that picks the policy charges a commission of at least the policy’s minimumCommissionBps on every fill: your feeBps plus Hyperliquid’s base taker fee on a perpetual, 4.5 basis points (0.045%), the most a hedge order pays it. That is a notionalBps commission at that rate or above, or liquidityBps with both rates at it or above, with timing fill and direction both. A minAmount or an orderMinimum only adds to it. Otherwise the refusal names each group under commission_below_hedge_fees, and the least each must charge, in the same order, under minimum_commission_bps. Once the policy is in force, a change to a group’s override or to the venue’s conditions that would charge less is refused the same way. Type that one number as the group’s commission: trdrs never writes your commission for you.
  2. Each hedge account approved the builder. Only the hedge account’s main wallet can approve a builder, and trdrs trades your hedge accounts with an agent key, so you approve it yourself: sign approveBuilderFee for your builder address, at feeBps or more, with the main wallet of each hedge account, then retry. trdrs reads the approval back from Hyperliquid and names each hedge account still short under builder_fee_not_approved. Where the hedge account is your company Hyperliquid account or a trader wallet trdrs made in your Privy app, trdrs holds its main wallet, so the step that turns the builder on (making the policy active, publishing a new fee, picking it or binding a hedge account) signs the approval at feeBps first, as someone who can turn hedging on, then reads it back. Each policy you read states builderApprovals: each hedge account the builder charges, the most it approved, in basis points per side, or null where Hyperliquid’s answer couldn’t be read, and signedByTrdrs: true where trdrs signs that approval for you.
  3. Each market it hedges is one of Hyperliquid’s own perpetuals. A builder-deployed perpetual (a HIP-3 market such as xyz:TSLA) charges its deployer’s fee on top of Hyperliquid’s, set by each market’s own fee settings, so a hedge there costs more than your paper commission charges. trdrs reads each symbol your hedge market maps an instrument to against its registry of Hyperliquid’s builder-deployed perp dexes, and names each instrument the policy could hedge on one under hedge_market_builder_deployed. Map it to Hyperliquid’s own perpetual, or keep it on your book with a rule on the instrument or its class.
For example, at "feeBps": "5" the policy’s minimumCommissionBps is "9.5", and the group charges {"kind": "notionalBps", "timing": "fill", "direction": "both", "bps": "9.5", ...}.
  • Copy, at 100%. A trader who buys $40,000 of BTC and sells it again pays $38 of commission on each fill, $76 in all. The hedge account pays $20 to your builder address and $18 to Hyperliquid on each side, $76 in all: $40 to you and $36 to Hyperliquid.
  • Net, two traders who cancel out. One buys $40,000 of BTC and another sells $40,000, and both close again. The net stays flat, so no hedge order goes out, and nothing goes to your builder address or to Hyperliquid. Both pay $76 on paper, $152 that stays in the hedge account.
  • Net, part of it hedged. One buys $40,000 and another sells $10,000. The net, $30,000, is hedged in and out: $15 to your builder address and $13.50 to Hyperliquid on each side, $57. On paper they pay $95, and the $38 between them stays in the hedge account.
Hyperliquid charges an account below its base rate as its rolling 14 day volume grows and for its staking and referral discounts, and charges it the base rate again as they lapse. What it charges less stays in the hedge account. The base rate is for Hyperliquid’s own perpetuals: a market a builder deploys there adds its deployer’s fee, which minimumCommissionBps doesn’t cover, so a policy with a builder never hedges one (hedge_market_builder_deployed, above). If an approval is taken away later, Hyperliquid refuses the hedge order. trdrs then reads the approval again and records the hedge’s failure as builder_fee_not_approved, which opens its incident, counts toward the account’s failureLimit and sends hedge.failure, as any failed hedge does. trdrs never sends an opening or resizing hedge without the fee. A flatten is different, because the position has to close: an emergency stop’s flatten, your own, or the close of a failed customer account’s hedge. trdrs reads the hedge account’s approval first. Where it is below the fee or can’t be read, and trdrs holds the hedge account’s main wallet (your company Hyperliquid account or a trader wallet), it approves the builder again and reads it back. A flatten still short closes without the builder, opens an incident on what the hedge account hedges, and sends hedge.failure with reason flattened_without_builder_fee, naming the hedge account (hedgeAccountId), your builder, its feeBps and the approvedFeeBps read, or null where it couldn’t be read. Those closes pay Hyperliquid’s own fee and nothing to your builder address.

Hedge one group by hand

A group that picks no hedging policy can still be hedged by a policy of its own: POST /hedges/policies publishes one for one group, POST /hedges/activation turns it on, and POST /hedges/calculate with POST /hedges/intents/{intentId}/dispatch work out and send its net when you ask. These routes stay while venues move to hedging policies, and a group that picks a hedging policy is hedged by it alone: its calculate answers hedging_policy_in_force.

Stop hedging in an emergency

An emergency stop stops every policy, hedging policies included, cancels the prepared orders that would add exposure, and opens incidents. Each hedging policy stays stopped until you resume it. Send a reason of 1 to 300 characters. It needs hedge:manage and hedge:execute.
The response counts the policies it stopped, the orders it cancelled and the incidents it opened. It stops your trade desk too, and counts the desk orders it asked to cancel. The hedge account’s positions stay open. Flatten them with a separate call, which takes hedge:execute:
Flatten closes every position in the hedge account at the market. It works while policies are stopped and while trdrs’s view of the account is stale, and it reaches only an account your venue bound for hedging, never a trader’s account. Where the hedge account’s builder approval is short, it closes without the builder fee and sends hedge.failure saying so.

Trade desk orders

Your people can place orders by hand from the trade desk into a desk account: one of your own provider accounts bound for hedging that an owner marks for the desk. No hedge sends into a desk account, and an account a hedge sends into can’t be marked one, so hand orders never share an account with hedging.
  1. Mark the account. An owner marks it with POST /desk/accounts and { "accountId" }, under hedge:manage. POST /desk/accounts/{accountId}/release gives it back to hedging.
  2. Set its limits. An owner sets them with PUT /desk/accounts/{accountId}/limits, each a hard block on every desk order. trdrs sets none, and until both required ones are set every order is refused desk_limits_not_set.
    • maxOrderNotional: the largest order, in US dollars. A market quoted in USDC or USDT counts one for one; one quoted in any other currency is refused notional_not_usd. Required.
    • priceBandPct: how far an order’s price may be from the market’s current price, the middle of its best bid and ask. A market buy is checked at the ask, a market sell at the bid, a limit at its limit price. A stale or missing quote refuses the order. Required.
    • maxPositionNotional, maxDailyNotional (the UTC day) and duplicateWindowSeconds (the same side, quantity and market within the window): optional.
    Each change is a new revision, recorded with who made it and when. Send the revision in force as expectedRevision.
  3. Place an order. POST /desk/accounts/{accountId}/orders places a market or limit order under hedge:execute. Send "dryRun": true to run every check and place nothing: the response states each check. An order that fails one is refused desk_order_refused, with failed naming each. One that passes goes through the account’s lane with the gates a hedge order passes. The response reports the account’s free margin where the provider states it; the provider decides whether the account funds the order.
  4. Read and cancel. GET /desk/accounts/{accountId}/orders reads the account’s open and recent orders with their fills and average price. POST .../orders/{orderId}/cancel sends one cancel for what is left of a working order. Fills before it stand, and the order reads cancelled once the provider’s book shows it cancelled.
  5. Size and preview before you place. Each reads the account’s own provider, as a trader’s own account answers, and places nothing, under hedge:read:
    • POST .../order-preview answers what an order would take of the account’s margin, marginRequired, null where the provider figures none, and sufficient, whether the account can afford it by the provider’s own figures. It checks no desk limit: a dry run does.
    • POST .../order-size answers the order an amount of the account’s money opens. Every live provider sizes orders by quantity, so it’s refused size_unsupported on every live desk account.
    • GET .../symbol-settings?instrumentId= reads the account’s leverage and margin mode on the market, and whether the mode may be changed now. PUT .../symbol-settings changes the leverage or the margin mode, one at a time, under hedge:execute, as a command on the account’s lane like a desk order. The provider decides each change, and a change is refused while your desk is stopped. An emergency stop never waits on a provider, so a change already being sent when the stop commits still lands, and its record says so. Send a change again under its Idempotency-Key and you get its first answer; it’s never sent twice. A refused change holds no key, so you can send it again under the same one. Each change is recorded with its market and the value before and after.
  6. Settle an order whose outcome is unknown. An order reads unknown while the engine can’t tell whether the provider took it. It finds out from the provider’s book and its answer for the order where it can. One still unknown five minutes after it was placed holds its account: every new order is refused desk_order_unresolved, and the incident shows in your hedges report. Check the account at its provider, and an owner states what it shows with POST .../orders/{orderId}/settle: { "outcome": "working", "providerOrderId" } where the provider took it under that id, or { "outcome": "not_working" } where it never did. A statement the provider contradicts is refused provider_disagrees. Settling closes the incident with who stated what and when, and an order stated taken while a stop stands is cancelled at once.
An emergency stop stops the desk too: no desk order is placed, and each working desk order is asked to cancel. POST /desk/resume, under hedge:manage and hedge:execute, opens the desk again.

Handle errors

Treat each of these as unfinished state. Don’t record one as zero exposure or as a hedge that succeeded.

Get hedge events

Your venue’s webhooks can subscribe to the hedge events, with the same signature and retries as every other event. Receive events has the details. A hedge event always describes your venue’s own hedge, in your hedge account. Your traders’ orders stay on trdrs.

Test it end to end

In the sandbox, with a provider connection that has passed validation and a hedge account bound to it:
  1. Publish and activate a policy for a test group.
  2. Open a position in a test account in the group, then calculate with dryRun: true and check the target matches the position times your ratio.
  3. Calculate without dryRun, dispatch the intent, reconcile it, and read the report to see the hedge account’s confirmed position.
  4. Run an emergency stop, confirm a new calculation is refused, then flatten the hedge account.
For an account policy, bind a test account to its own hedge account, trade it, and read the report: the account’s target follows its position times its copy ratio after each fill.

Next steps

Provider conformance

Prove the provider your hedge account lives at.

Receive events

Get hedge targets, fills and failures pushed to your server.