Agara

Recovery

The state a market-maker bot reads back after a restart or disconnect, and which endpoint each piece comes from.

After a crash, restart, or stream disconnect your bot's in-memory state is suspect — you may be holding orders you've forgotten, or have missed fills that landed while you were dark. Recovery is reading the platform's authoritative state back and reconciling before you quote again.

The safe opening move is cancel-all from the fresh process, followed by reconciliation. Cancel-all returns before every cancellation is terminal, so wait for cancellation events or an empty open-orders response before treating the book as empty.

Recovery sources

What you're rebuildingRead it from
Resting orders — what's still on the book under your accountPOST /trade/v1/portfolio/open-orders/list
Positions / Inventory — your YES / NO token balances per marketPOST /trade/v1/portfolio/positions/list
Capital and commitments — wallet collateral plus open BUY collateral commitments and open SELL share commitmentsGET /trade/v1/portfolio/summary and POST /trade/v1/portfolio/open-orders/list
Fill history — fills across your account, newest-first, to rebuild realized inventory and cost basisGET /trade/v1/portfolio/trades
Account activity — terminal filled orders, position operations, automatic redemption, deposits, and withdrawalsGET /trade/v1/portfolio/activities
One order's fills — the maker / taker leg of each fill on a specific order you're unsure aboutGET /trade/v1/orders/{order_id}/trades
One order's status — current lifecycle state plus aggregate fill totalsGET /trade/v1/orders/{order_id}
An order you only have the hash for — same status lookup keyed by the order_hash you signed, for signed orders when you held the hash but lost the order_idGET /trade/v1/orders/by-hash/{order_hash}
Live state — resubscribe the account and orderbook streamsdiscard your local book and rebuild from the snapshot above when you reconnect

Putting it together

This is the re-seed step of the quote loop:

  • Clean restart. Request cancel-all, wait until the old orders are terminal, then rebuild from open orders, positions, and summary before quoting again.
  • After a disconnect. You may have missed fills while the stream was down — they are not replayed on reconnect. Pull /trade/v1/portfolio/trades (or the per-order fills for a specific order) to catch up and reconcile inventory before you resume.

Missed messages surface as a sequence_reset on the stream, not as a gap you're expected to detect yourself — when you see one, re-seed from the sources above rather than trusting your local state.

On this page