Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CoreOrderbookgetOrderbookSpread

getOrderbookSpread

Best prices and the gap between them.

import { getOrderbookSpread } from "@symmio/trading-core"; const spread = getOrderbookSpread(book); if (spread) { console.log(`${spread.spread} (${spread.spreadBps.toFixed(2)} bps)`); }

Parameters

orderbookOrderbookrequired

The book to measure.

Returns

OrderbookSpread | undefined

The spread, or undefined when either side is empty — a one-sided book has no spread, and reporting 0 would read as a locked market.

bestBidnumber

Highest resting bid.

bestAsknumber

Lowest resting ask.

spreadnumber

bestAsk - bestBid, in quote-asset units. Negative when the book is crossed.

spreadBpsnumber

The spread as basis points of the mid.

midPricenumber

Arithmetic mid, (bestBid + bestAsk) / 2.

Notes

  • Reads only the touch. Depth behind it does not move the result.
  • Call it on the ungrouped book: groupOrderbook moves the touch prices apart and would overstate the spread.
  • A tight major sits well under one basis point — BTC often quotes around 0.016 bps — so a single decimal reports every spread as 0.0. Scale your precision to the magnitude.
Last updated on