walkOrderbook
Fill a hypothetical market order against resting depth. A buy consumes asks from the best price outward; a sell consumes bids.
import { walkOrderbook } from "@symmio/trading-core";
const walk = walkOrderbook(book, "buy", 5);
if (walk.partial) console.warn("not enough resting depth");
console.log(walk.averagePrice, `${walk.slippageBps.toFixed(2)} bps`);Parameters
orderbookOrderbookrequiredThe book to walk.
side"buy" | "sell"requiredbuy consumes asks, sell consumes bids.
sizenumberrequiredBase-asset quantity to fill.
Returns
OrderbookWalkThe fill, or a zero-filled result when size is not positive or the side is empty.
filledSizenumberBase-asset size actually fillable — less than requested when depth ran out.
filledQuotenumberQuote-asset cost (buy) or proceeds (sell).
averagePricenumberoptionalSize-weighted average fill price. Absent when nothing filled.
bestPricenumberoptionalBest price on the side walked. Absent when that side is empty.
worstPricenumberoptionalPrice of the deepest level touched.
slippageBpsnumberCost of crossing the book, in basis points of bestPrice. Always >= 0 — a buy averages above the touch and a sell below it, and both are reported as a positive cost.
partialbooleantrue when the book held less depth than requested.
levelsConsumednumberNumber of price levels consumed.
Nothing but the book is considered — no fees, no funding, no solver spread. Treat the result as the cost of liquidity,
not a quote. When the source’s priceBasis is reference-exchange this is a third-party venue’s depth, not what a
SYMMIO trade executes against.
Interpreting partial
A partial: true result may mean the venue is genuinely thin, or merely that the subscription is tracking fewer levels than the order needs. If you price large orders, raise levels on the subscription (or limit on the snapshot) before treating it as a liquidity signal.
Related
getOrderbookDepthWithin— resting liquidity without naming a size.getOrderbookSpread— the touch the slippage is measured from.