Grid perpetuals and recenter¶
0.13.1 (unreleased)
Everything on this page is planned for 0.13.1 and is not in 0.13.0, where Grid is spot only. Names and labels follow the agreed Grid contract; details can still change before the release. Details are in the 0.13.1 release notes.
The Grid workspace adds Perpetual (linear) markets with Leverage, Margin mode and a Long, Short or Neutral direction, more stop triggers, a choice of what happens when the gate closes, and automatic recentering. Backtest, paper and live use one rule set. Live perpetual Grid is labelled Untested and stays available on every venue that can place reduce-only orders; where the venue can't, live perpetual Grid is refused and grayed out, and backtest and paper still work.
A spot Grid saved before 0.13.1 still loads and runs with the same trading figures: it is read as Spot and Long. On spot, the new report blocks are empty.
Market and direction¶
| Setting | Options |
|---|---|
| Market type | Spot, Perpetual (linear) |
| Direction | Long, Short, Neutral (long below the start price, short above) |
- Spot grids are long only. A spot grid with Short or Neutral is refused: "spot grids are long only".
- Perpetual (linear) takes linear, quote-settled perpetuals only (symbol
BASE/QUOTE:QUOTE). Inverse and dated futures are refused: "only linear quote-settled perpetuals". - Direction is required on a perpetual grid.
- Long opens with a buy at a level and closes with a sell one level up, as on spot. Short is the mirror: it opens with a sell one level up and closes with a buy at the level below. Neutral uses long cells below the start price and short cells above it. A cell that straddles the start price is not used; it is reported as
idle_straddleand never placed. - A grid never flips a position. Every close is reduce-only and exactly the quantity that cell holds; a close above what the run holds is refused.
Neutral: one side at a time¶
A Neutral grid has opening orders resting on one side only. It starts on the long side ("longs go first"). The active side changes only when the price crosses the start price by the hysteresis band (Switch sides past the start by, neutral_hysteresis_pct, 0.1–20 percent of the start price); inside the band it keeps the previous side. The band is required on Neutral, saved in the strategy definition, and refused on Long or Short. A value outside 0.1–20 is refused whole, never clamped. It switches side only when it holds nothing on the current side and every resting open of that side is cancelled and confirmed; then the other side's opens are placed. So a short open never works while a long is held, and the reverse, in backtest, paper and live. Switching costs one candle. By default every cell, long or short, gets the allocation divided by the number of cells, so each side uses only its share. That default for how a Neutral grid splits the allocation between its long and short sides is not final. The run's events show Neutral: switched to short opens or Neutral: switched to long opens.
Start¶
Start is quote only or acquire base, as on spot. On a perpetual grid, acquire base opens a long at market for the cells above the start price (Long) or a short at market for the cells below it (Short), as one taker order with margin and fee covered in full. A Short acquire costs more than those cells' share of the allocation: each short cell is sized at its own opening level, but the acquire opens it at the start price. The start plan shows what the start needs (needs), and the start is refused whole when the balance does not cover it; nothing is shrunk. A paper or backtest balance above the allocation covers it. Neutral takes quote only: "a neutral grid starts flat at the start price".
The start plan (start_plan) is worked out at the start close and listed per direction. Long lists resting buys as opens and sells above as closes. Short lists resting sells as opens and buys below as closes.
- Long: resting buys open the cells wholly below the start price. With acquire base the cells above are opened at market and their closing sells rest above the close; with quote only they wait until a close at or above their sell level arms their buy.
- Short: resting sells open the cells wholly above the start price. With acquire base the cells below are opened at market as one short and their closing buys rest below the close; with quote only they wait.
- Neutral: long cells below the start price, short cells above it, and the straddle cell unused. Only the long opens rest at the start.
The plan reports open_cells, acquire_cells, long_cells, short_cells, straddle_cells, idle_cells, open_reservation, acquire_qty, acquire_cost and needs.
Leverage and margin mode¶
Leverage, Margin mode and Maintenance margin rate apply to perpetual grids only. On spot they are refused, including Maintenance margin rate source (maintenance_margin_rate_source): "leverage, margin_mode, maintenance_margin_rate(_source) and neutral_hysteresis_pct apply to perps only". They use the same pickers as Ladder.
- Leverage is required, from 1× to 125×. When the run starts (backtest from the market, paper, or live), a leverage above the pair's cap is refused whole, never lowered.
- Margin mode is Isolated or Cross, with the venue's label. A grid with no mode set uses the venue's default (
default_margin_mode) when the run starts; a backtest on supplied candles with no venue uses isolated. The mode the run used is saved on the run. A mode the venue doesn't offer is refused (isolated on Paradex, or on dYdX for now; cross on a Hyperliquid market listed as isolated only), and so is live Cross where the venue cannot set it. See Margin mode by venue. Live perpetual Grid also needs a venue that can place reduce-only orders; see Reduce-only venues. - Maintenance margin rate (
maintenance_margin_rate) is a run-start field, prefilled from the venue. It is not in the saved definition. Its unit reads decimal (0.005 = 0.5%), set by the exchange, and a value must be at least 0 and below 0.5. The start form shows the market's own rate already filled in, with the note Filled from the market. Check it. Starting the run with that value on screen applies it. The run-start confirmation shows the maintenance margin rate it is about to use, labelled Filled from the market. - The rate is optional while you edit, and a value you enter is never overwritten. It is required by the time the run starts. If a start or an API call leaves it empty, the run start (backtest from the market, paper, or the live check) fills it from the market's own rate and records
maintenance_margin_rate_source: "market"in the run's config and report, so it is never filled without a record. If the market lists none, or the backtest runs on supplied candles, the run is refused whole: "maintenance_margin_rate is required at run start: the market lists none here; enter the venue's rate (decimal, 0.005 = 0.5%)". - The four run-start bodies (
POST /grid/paper,/grid/live,/grid/backtestand/grid/backtest/market) accept an optionalmaintenance_margin_rate_sourceofmarketorentered. The start form sendsmarketwhile the field still holds the prefilled value, andenteredonce you edit it. Describe, preview and export work without it. Sent with a rate, it is recorded as sent. A start that leaves the rate empty ignores a sent source, fills the rate from the market and recordsmarket. A start that sends a rate with no source records nothing extra; the report then readsentered. Any other value is refused whole: "maintenance_margin_rate_source must be one of market, entered". The workspace field is Maintenance margin rate source, with labels Filled from the market (market) and Entered by you (entered). - Until the rate is known, the preview shows no liquidation level and warns "maintenance_margin_rate is set at run start (prefilled from the market): liquidation levels are shown once it is known".
Sizing and funding the orders¶
Each cell is sized so that its margin plus its opening fee fits in the allocation divided by the number of cells. At 1× this is the spot sizing. So the whole ladder on either side can always be paid for from the allocation. A cell below the exchange minimum refuses the grid whole, as on spot.
A resting open reserves its margin (value divided by leverage) plus the maker fee from the run's cash; a market open reserves the same at the slipped price with the taker fee. An open that cash cannot cover in full is not sent: it waits and is logged once. A start whose plan needs more than the cash is refused whole. Nothing is ever shrunk to fit.
Preview¶
On a perpetual grid the preview adds a block with columns Side, Cells, Size if all fill, Avg entry, Value (quote), Margin + fees (quote), Liquidation and Loss at far edge (quote). Liquidation basis is isolated, cross, this run's money only, or cross, shared with the account. The cross-pool note Other cross positions on this account can move this level. sits directly under the liquidation price. If the allocation cannot cover every cell filled, it warns The allocation does not cover the worst case (X quote with every cell filled). The start will be refused. Funding reads Funding at full size: about X (plus = you pay). Rate R%., where X is the quote paid per day at full size on the larger side (minus means received). When there is no estimate it reads Funding: no estimate (reason): funding_estimate.amount is null and funding_estimate.note says why, for example "no venue" or "no public funding history on this venue"; it is never shown as 0. The estimate is funding_estimate with rate, amount and note; the interval, the rate source and the per-side figures are in funding_detail. A liquidation level inside the range is a warning, not a refusal.
When recenter is on, the preview also has a Recenter preview block (recenter; null when recenter is off). It is worked out at the last close, with the same rules as a real recenter:
- Next range (
next_range): the next range'slowerandupper, whether it comes from the ATR or from the fixed ratios (basis), and the price it was worked out at (at_price).at_priceis the last close:last_closein the preview body, or, when that is absent andexchange_idis given, the close of the last completed 1m candle, read keyless from the exchange. It falls back to the middle of the range only when there is no close. The start-plan previewpriceis not used for it. The cost and fundability are also computed atat_price. - Estimated close or carry cost (
estimated_cost): the estimated cost to close or carry. It lists the position choice, the quantity closed with its fee and slippage, the quantity carried, the excess closed, the quantity acquired with its fee, and the total. - Fundability (
fundable): the fundability result, withok, what the new grid needs, what is available, and the reason.
A fundable.ok of false means that recenter would be skipped when the run gets there. It never means the grid would stop.
Funding¶
A perpetual grid models funding the same way Standard and Ladder do. A backtest from the market reads the exchange's public funding history; a backtest on supplied candles takes optional funding rows, and without them reports funding as not modelled: no venue. Paper uses the shared funding cache from the public source. Live books an estimate the same way Ladder live does: each poll reads the public funding history for the new candles and charges it with the same timing. So equity, take profit, drawdown and recenter sizing work the same way in backtest, paper and live. The live report says Estimated from public funding history, with the note "perp funding is estimated from public funding history; the account's payments are not read".
Each settlement is charged at the open of the first candle that opens at or after it, at that open's price, on the position held at the start of that candle, before the candle's fills and the liquidation check. On Isolated it is booked to the side's margin, so the liquidation level is recomputed; on Cross it is booked to cash, which is the pool. Funding is still charged while trading is halted, because the exchange charges it too. Events show Funding paid or Funding received.
Liquidation¶
- Isolated: the level comes from the side's average entry, quantity and margin (including funding booked to it) and the maintenance margin rate. A 1× short has a level too, at about twice the entry.
- Cross, own balance: in a backtest, and in paper without a linked account, the run's own cash is the pool.
- Cross, linked paper account: the run joins the account's cross pool, shared with Standard trades, Ladder runs and Carry's perp leg. It is checked at create and before every candle, before the wallet moves; a full pool refuses the run whole with cannot join the account's cross pool: … and leaves nothing half-made. A pool liquidation seen by another member closes the grid's side on its next step.
Within a candle, the fills are applied first, then the level is checked against the candle's low (long) or high (short). Backtest and paper do the same.
A liquidated side closes at its level and its margin is lost (on cross, the pool rule applies). Every resting order is cancelled and the grid stops, with stop reason liquidation (own or pool). A liquidated grid never reopens on its own. The event reads Liquidated.
Live: the exchange is the truth. Each candle the grid reads its position. An unknown or rate-limited read waits. Only an explicit zero (or a position on the other side only) while the grid holds inventory counts: the grid cancels its resting orders, stops with "position closed on the exchange (liquidation or manual close)", and marks the run incomplete. It sends no close, and it books that side's inventory as margin lost; this is an estimate, and the exchange's statement is the truth. The event reads Position closed on the exchange. On OKX, which lists nothing when you are flat, an exactly empty read also counts as flat.
Stops¶
One Stop action covers every trigger by default, including take profit and drawdown.
| Trigger | Label |
|---|---|
| Downside price | Stop when a close is at or below |
| Upside price | Stop when a close is at or above |
| Take profit | Take profit: stop at equity +% |
| Drawdown | Drawdown stop: stop at % below peak equity |
| End time | Stop at end time |
| ATR band | ATR band stop; with recentering it follows the current range |
- The upside price must be above the downside price when both are set. A stop needs at least one trigger.
- Take profit fires when equity at a close is at or above the start equity plus the percent (up to 1000%). The drawdown stop fires when equity at a close is at or below the peak equity minus the percent (under 100%). Peak equity is the highest equity at a close since the start; a recenter does not reset it.
- Each candle, Apathia checks in this order: funding, liquidation (which stops the run), then the stops in the order band, downside price, upside price, take profit, drawdown, end time. The first hit sets the stop reason. Then recenter, then the gate, then placing orders.
- Stop action: Cancel only, or Cancel and sell on spot / Cancel and close position on perpetuals. On a perpetual grid, close position closes the whole position with one reduce-only market order. The downside stop kind is
stop_down, paired withstop_up. Its short label is Stop price (down) and its reason reads "close {close} at or below the stop price {price}". A manual stop reads Stopped by you (the stored reason is "stopped by you"). - A stopped run that still holds a position keeps being polled: funding, the modelled liquidation and, on live, the exchange position read go on every candle, and no order is sent. Once it is flat it is no longer polled. The report reads Stopped: position still open. Close position is shown only in that state. After a confirmation it places a reduce-only market close, reusing Ladder's reduce-only close path. It is blocked while the kill switch is on: the halt acts on nothing until resume. See Close position.
- Equity is cash plus base at the close on spot, and Equity (cash + margin + open profit or loss) on perpetuals.
Grid places no exchange stop orders. It places no exchange-side backstop stop in 0.13.1, because no venue is allowlisted for one; a Grid backstop is a tracked follow-up. See Safety stops. The venue's own liquidation is unaffected.
Close position¶
Close position is for a stopped perpetual run, in paper or live, that still holds a position. It sends one reduce-only market close for each held side, priced at a fresh close (the run keeps being polled after it stops, so the close uses the latest candle, not the one from when it stopped), behind the confirmation Close the open position with a reduce-only market order?. It uses the same reduce-only close path as a stop with Cancel and close position and as Ladder's closes: in paper the venue never closes more than the position, and live sends a reduce-only exit through the shared order service.
- Paper runs use
POST /grid/paper/{rid}/close_positionand live runs usePOST /grid/live/{rid}/close_position, with the body{"confirm": true}. The path must match the run's mode; otherwise it is refused with "this is a {mode} run: use POST /grid/{mode}/{rid}/close_position". - Without
"confirm": trueit is refused with "Close position sends a reduce-only market order: confirm it (confirm: true)". - A run that follows a public source first reads the source up to the latest closed candle and closes at that close. If no price can be read, it is refused and nothing is sent: "Close position needs a fresh price and none could be read (…); nothing was sent, try again". A fetch that succeeds but brings no new closed candle is not a fresh price either, on paper and live alike: the close is refused with that same fresh-price text (the reason names a missing or not-yet-new closed candle) and nothing is sent. A paper run fed by hand uses the last close it was fed.
- It is refused, with the reason, unless the run reads Stopped: position still open. A running run, a flat run and a run with orders still working are all refused.
- A spot grid has no Close position. It uses Stop with Cancel and sell.
- While the kill switch is on it is refused and nothing is sent. The workspace shows Halted by the kill switch: the position close is refused. Resume trading first. The API answers 409 with
{"detail": {"status": "halted", "reason": "halted by kill switch: the position close is refused; resume trading first"}}. - On success the answer is the run report plus
close_position, withok,status(closed,workingorpartial) andreason. The run logs aposition_closeevent.
When the gate closes¶
Outside the range keeps its setting and is labelled Pause new opens: no new opening orders while the close is outside the range.
| When the gate closes | Label | When it opens again |
|---|---|---|
| Pause (default) | Pause new opens | Opens resume. Resting opens follow Resting opens when the gate closes: Cancel (default): filled parts are kept and closed by the grid, or Keep: leave them working. Held cells keep their closes. |
| Cancel only | Cancel all orders, keep the position | Every resting order, opens and closes, is cancelled; the position is kept without grid orders. On reopen, closes are placed again for held cells, then opens resume. |
| Flatten | Close the position, restart when the gate opens | Every resting order is cancelled and confirmed, then the whole position is closed with one reduce-only market order (a sell on spot), with the taker fee and slippage charged. A cancel whose outcome stays unknown is retried each candle until the Unknown-outcome timeout (unknown_timeout_seconds) runs out; then the run is marked incomplete, opens pause and the close is not sent. The run keeps running. On reopen the cells restart from that close using the Start setting. |
Resting opens when the gate closes applies to pause only; keep with any other action is refused. The gate only holds placing orders: stops, liquidation and funding always continue. The preview notes Close and restart pays the taker fee to close, and again to reopen, each time the gate flips. Events: Gate closed: orders cancelled, Gate closed: position closed, Gate opened: grid restarted.
Kill switch¶
While the kill switch is on, a Grid sends no order of any kind: opens, closes, acquire, stop closes, flatten, and recenter closes and acquires. The kill switch cancels only working grid limit orders; a working reduce-only market close is not cancelled. An order decided as the halt landed is held and goes out once, with the same client order id, after Resume trading. A stop of any kind voids every held order, closes included. A manual stop with Cancel and sell or Cancel and close position while halted is recorded, and its close is sent only after the resume, as a new order sized from the position held then.
While halted, stop triggers, gate actions and recentering are not checked: the only stops that can happen are a manual stop, a liquidation and a position closed on the exchange. Funding, the modelled liquidation and, on live, the exchange position read go on, because the market and the exchange keep moving. The report shows the halt event halted by kill switch: Grid limit orders cancelled; nothing is placed until trading is resumed; funding still counts. Close position on a stopped run that still holds a position is shown only in that state and is blocked while the kill switch is on: the halt acts on nothing until resume. It is refused with Halted by the kill switch: the position close is refused. Resume trading first. (see Close position). While halted, a due or in-progress recenter is skipped: it is not checked, and an in-progress rebuild freezes in its step. The unknown-outcome timeout clock is frozen (time spent halted never counts). The first candle after the resume restarts both clocks — the rebuild clock and the unknown-outcome clocks of its orders — so a full unknown_timeout_seconds window from the resume is needed before a timeout, and a recenter that fell due while halted, or one already in progress, continues then. Same in backtest, paper and live (candle time only).
Auto-recenter¶
Optional auto-recenter (rebuild the grid around the price) is off by default and works on spot and perpetual grids. The control is labelled Recenter.
| Setting | Options |
|---|---|
| Recenter | Off, On a range break, Every N days, Both |
| Closes outside the range | 1–100 consecutive closes beyond the outer levels (default 1); range-break triggers only |
| Every | 1–365 days; required with Every N days and Both. Any rebuild restarts the count. |
| Recenter on breaks | Breaks up only, Breaks down only, Both ways (recenter.directions; range-break triggers only, and refused with Every N days alone). If it is absent, the meaning is Both ways. Saved in the strategy definition. |
| Wait at least | integer 1–720 hours between rebuilds (recenter.min_gap_hours). Required whenever a recenter trigger is on, saved in the strategy definition. A value outside 1–720, or one that is not a whole number, is refused whole, never clamped. A trigger that comes sooner waits, and fires at the first close after the wait if it still holds. |
| The position at a rebuild | Close the position (fees charged), Carry the position into the new grid (excess closed, fees charged) |
Directions let a grid trail the market: a Long grid set to up follows a rising price, and a Short grid set to down follows a falling one. A trigger in a direction that is not allowed does nothing: no cancel, no close and no notification. The current grid keeps running, and its stops and the liquidation check still apply. No recenter starts sooner than the minimum spacing after the previous one.
A Neutral grid takes close only: "a neutral grid restarts flat at the new start price".
- New range: an ATR range is worked out again from the current ATR. A fixed range keeps its bounds as ratios of the first start price, moved to the current close and rounded to the tick.
- Size: by default the new cells are sized from the smaller of the allocation and the equity at that close, so the grid never uses more than the allocation or money the run has lost.
- Steps: all resting orders are cancelled (live waits for each cancel to be confirmed). Then close either closes the whole position with one reduce-only market order, with taker fee and slippage charged; or carry moves the held position into the new cells at its cost, with no fee, and closes any excess at market with the taker fee. A shortfall under carry is bought at market only with acquire base; with quote only those cells wait. Then the new cells are placed following Start and, on Neutral, the one-side rule.
- The gate holds placing the new cells, but the cancel and the close still happen. A stop on the same candle wins over a recenter. The downside and upside stop prices do not move.
- Before a recenter cancels anything, it checks that the new grid can be funded. If the new grid cannot be funded, the recenter is skipped: nothing is cancelled, the grid is not stopped and the current grid keeps running. The run sends a notification, at most once an hour, and tries again at the next trigger, respecting the minimum spacing between recenters. An invalid new range is not skipped: a range that is not positive or too narrow, or cells under the venue's minimum order or step size, stop the grid as Cancel only with reason recenter refused: …. A funding shortfall or an ATR that is not ready yet is skipped and retried.
- A funding skip logs Recenter skipped: not fundable. "not fundable" is only for funding or fundability (
reason_codenot_fundable). Its notification is limited to one an hour for each run under its own key. - Each recenter is saved step by step, so a restart continues where it left off without a duplicate order or fee.
Skipped, refused and unfinished recenters¶
- After a skip the next try waits Wait at least from the close of the skip, not from the last rebuild, and a range-break count starts again from zero. A funding skip event reads "Recenter skipped: not fundable ({trigger} at {close}): {reason}; the grid keeps running", where the trigger is "range break" or "every N days". Paper and live runs send the notification, at most one an hour for each run and reason; a backtest only logs the event.
- ATR not ready: if an ATR range has no ATR yet at the rebuild close (the re-resolve returns "warming up: …"), the recenter is skipped the same way and counted under Skipped recenters. The event reads exactly Recenter skipped: ATR not ready yet (
reason_codeatr_not_ready; the resolver's words are indetail). Its notification uses its own hourly key, so an ATR skip never mutes a funding one, and it is retried at the next trigger after Wait at least. An ATR range the check refuses (it reaches zero or below, or its smallest step is below the minimum step) stops the grid with recenter refused: … (recenter_refused). - Counters: the report shows Skipped recenters (
recenter.skipped) and Refused recenters (recenter.refused). A refusal stops the run, so Refused recenters is 0 or 1. These labels, Stopped during {phase}: {reason}, and the rest of the Recentering labels are served asreport_labelson the workspace schema grouprecenterand aslabelson the descriptor blockgrid.recenter. - A stop during a recenter (any kind, a manual stop included) ends the recenter while it is cancelling, closing or placing. It is recorded as one recenter event with status incomplete and the reason Stopped during {phase}: {reason}. The stop's own action then takes over, and nothing more of the recenter is sent.
- Timeout: a cancel, close or buy-in of a recenter that is still unresolved after the Unknown-outcome timeout (
unknown_timeout_seconds, counted from the close the recenter started at) marks the run incomplete and pauses opens. The reason reads "recenter: {what} past the timeout".{what}is one of exactly four descriptions: "a cancel outcome is unknown" (while cancelling), "the recenter acquisition is unresolved" (while placing, if the acquire is still open), "the recenter close is unresolved" (while closing, if an order is still open or unknown), or "the recenter close did not finish" (while closing, if the close was refused or partial). The recenter stays in its step and is retried each candle. Inventory already closed stays closed, and nothing is resized. Time spent halted never counts toward this timeout: while a rebuild is in progress and the kill switch is on, neither the rebuild's clock nor the unknown-outcome clock of its orders runs out, and both restart at the first candle after the resume, so a fullunknown_timeout_secondswindow from the resume is needed before a timeout. Same in backtest, paper and live (candle time only). - Leftover below the exchange minimum: under carry, the excess is closed at market. What is left below the exchange's minimum order is too small to sell, so it is carried and never resized. On spot it is kept as loose base (
loose_base) and sold with the next sell it fits into. On a perpetual it joins the last carried cell and is closed, reduce-only, with that cell. - Kill switch: while halted a recenter is skipped and nothing of it is sent; it freezes in its step. The unknown-outcome timeout clock is frozen. The first candle after the resume restarts both clocks, and the rebuild continues then. An every-N-days recenter that falls due while halted also runs at that first candle.
Where recenter shows¶
- Report: the Recentering block (
recenter) is in the report only when the grid's config sets recenter. A spot grid that does not set it reports exactly as before. - Preview: a perpetual grid's preview always has
recenter, null when recenter is off; a spot grid's preview has it only when the config sets recenter. A spot grid without it previews exactly as before. With a fixed range, the Next range atat_price(the last close) is the configured range, because the fixed ratio takesat_priceas the first start close. - Range line: without recentering the range reads "set once at the start; not recentred". With it, the report reads "recentred on a range break", "recentred every {N} days" or "recentred on a range break or every {N} days".
Events: Recentered (range break), Recentered (every N days), Recenter skipped: not fundable, Recenter skipped: ATR not ready yet, and the stop Recenter refused.
Report¶
On spot these blocks are empty. The labels below follow the Grid contract's label table.
A stopped run that still holds a position keeps stepping and the report reads Stopped: position still open (position_note), with the side and size (for example Stopped: position still open: Short 0.5). Close position is shown only in that state. After a confirmation it places a reduce-only market close, reusing Ladder's reduce-only close path. It is blocked while the kill switch is on: the halt acts on nothing until resume. The endpoints and refusals are under Close position.
While halted the report shows the halt event halted by kill switch: Grid limit orders cancelled; nothing is placed until trading is resumed, and funding still counts. The run line on a perpetual reads Perpetual (linear) · the direction · leverage, plus Margin mode: ….
| Field | Label / what it shows |
|---|---|
market, bias, leverage, margin_mode, margin_mode_label, margin_mode_detail |
the run's settings and the mode it used |
maintenance_margin_rate, maintenance_margin_rate_source |
the rate the run used, and where it came from: market (filled from the market) or entered |
position |
position.long and position.short are each an object with qty, avg_entry, liquidation_price, margin, notional, unrealized, funding_margin and liquidation_basis, or null; at most one side is non-null. Shown as Position: Side (Long or Short; Flat when both are null), Size, Avg entry, Value, Margin, Funding in margin, Open profit or loss and Liquidation. The liquidation basis reads isolated, cross, this run's money only or cross, shared with the account. |
funding |
Funding: Funding paid (a negative total reads Funding received), Settlements, and where it is booked: Taken from the position's margin or Taken from the cross pool. Without funding rows it reads Funding not modelled: {note}. On live it reads Estimated from public funding history. Recent settlements lists the newest 20. |
liquidations |
Liquidations: the count and the newest 20, each reading Liquidated {side} {qty} at {level}, margin lost {margin_lost}, with the kind This run's position or The account's cross pool |
cross_pool |
Cross pool (account), on a paper run linked to an account: Pool equity (pool_equity), This run's contribution (run_contribution, its margins plus the move), Liquidation price (pool basis) (liquidation_price), and the note Other cross positions on this account can move this level. The pool view also shows Wallet balance, Cross margin, Unrealized P&L, Maintenance, Runs and trades in the pool and Last pool liquidation. |
stop |
Stopped by: plus reason, whether it closed the position, time, and kind: stop_down Stop price (down), stop_up Upside stop, band ATR band stop, end_time End time, take_profit Take profit, drawdown Drawdown stop, liquidation Liquidated, position_closed Position closed on the exchange, margin_refused Margin settings refused, recenter_refused Recenter refused, invariant Safety check, manual Stopped by you. The kind stop_down replaces price_down and is paired with stop_up. |
equity_peak, drawdown_pct |
Peak equity and Drawdown from peak, from the run's own equity |
estimated_exit_fee |
Estimated exit fee: the position size times the mark times the run's taker fee rate, with no slippage, the same in backtest, paper and live. Empty before there is a mark, and 0 when the run is flat. |
gate.closed_action |
the action and what it does |
recenter |
Recentering: Rebuilds, counted On a range break and Every N days, Recenter fees, Realized on recenter, Position carried, Excess closed, Next scheduled recenter, Skipped recenters (skipped), Refused recenters (refused), and while one runs Recentering: {phase} (cancelling orders, closing the position or placing the new grid), plus the newest 50 recenter events, each reading Recentered ({trigger}): {old lower}–{old upper} → {new lower}–{new upper} |
Each recenter event lists its number, time, trigger, position choice, old and new range, orders cancelled, quantity closed and its fee, realized P&L, quantity carried, excess closed, quantity acquired and its fee, cells, and status (done, refused or incomplete) with the reason.
Bounded history¶
Grid history stays bounded on long runs:
- Orders: every open order plus the newest 200 closed orders, as in 0.13.0.
- Cells: at most the number of intervals (200). A recenter replaces them; it never appends.
- Position:
{long, short}, each a side object or null; at most one side is non-null on Neutral. - Funding: the newest 20 settlements plus totals.
- Liquidations: the newest 20 plus the count.
- Recenter history: the newest 50 recenter events plus running totals over every recenter, and one in-progress record. However many rebuilds run, the history stays at 50 events and nothing grows.
- Peak equity: one number.
- Events: the newest 2,000, trimmed to 1,500; the report shows 500.
Backtest, paper and live¶
One controller runs backtest, paper and live with the same rules: bias, the one-side rule, margin, funding timing, liquidation order, stops, gate actions and recentering. A backtest gives the same result as paper fed the same candles in chunks.
Live (real perp orders on your exchange account) — Untested checks the perpetual market, the pair's leverage cap and margin mode, and that the free quote in the perpetual wallet covers the allocation. It changes no account setting at that check. Live places real perp orders on your exchange account (Untested on every exchange). The capability text for live futures (/grid/capability, futures.live) reads Untested: mocked contract only. Saved settings and the API keep their stored status value; only the words on screen change. The start is refused whole if the free balance does not cover the allocation or the leverage is above the pair limit. Before the first opening order it sets the margin mode and leverage, once per run. If the exchange refuses, no order is sent and the run stops with Margin settings refused (margin_refused). Opens are limit orders; closes are reduce-only. A live grid draws on the account's shared perpetual wallet, and an open on the opposite side of a pair another trade or run holds is refused.
Reduce-only venues¶
A grid never flips a position, and that rule comes first. A live perpetual Grid closes only with reduce-only orders, so on a venue that can't place reduce-only orders a close could open the opposite side. Live perpetual Grid is therefore refused there, with the same guard as Ladder. The market metadata (/grid/metadata?market=linear_perp) reports it for each venue as live_perp with available and reason, and the workspace schema carries the same reason as live_perp.unavailable_reason.
- On such a venue the venue stays listed, the workspace grays out live for a perpetual grid and shows the reason, and backtest and paper still work. The live check (preflight) refuses with the same text, before anything is sent: "This exchange can't place reduce-only orders, so a live futures grid could open the opposite side. Backtest and paper still work."
- Live futures fails closed. If the venue's
live_perpstatus is missing, live counts as unavailable: the venue stays listed, live for a perpetual grid is grayed out with "Live futures status unavailable. Backtest and paper still work.", and backtest and paper still work. A missing status is never treated as available. - On a venue that can place reduce-only orders, the live check lists "reduce-only orders supported (closes can never open the other side)".
The venue stays listed. Spot Grid, and perpetual backtest and paper, are unaffected.
Hedge mode is used only when it is detected on the account; each order then carries the cell's side. A grid never needs both sides at once, so one-way and hedge accounts behave the same. See Both and hedge mode.