Skip to content

Order Book

Real-time market depth (bids and asks) for the active chart symbol. Opens from the right sidebar when enabled.

Configuration

typescript
new ChartSpire({
  orderBookEnabled: true,
  orderBookMaxRows: 10,
  orderBookDepthVisualization: 'cumulative',
  defaultOpenComponents: ['orderbook'],
  dataFeed: dataFeed,
  // ...
})
OptionTypeDefaultDescription
orderBookEnabledbooleanfalseShow order book in the right sidebar
orderBookMaxRowsnumber10Max rows per side (bids / asks)
orderBookDepthVisualization'amount' | 'cumulative''cumulative'Initial bar width mode: per-level quantity (amount) or running total (cumulative). Changeable in the UI.
defaultOpenComponentsstring[]Include 'orderbook' to open the panel on load (max 3 panels; panel must be enabled)

Requires rightBarEnabled (default true). Without a data feed that implements order book methods, leave orderBookEnabled off.

View Modes

Selected in the panel UI:

  • Combined (default): Asks above, spread, bids below
  • Bids Only / Asks Only: Single side
  • Split: Side-by-side; best bid and ask aligned at the top

Tick Size Aggregation

Group levels by price. Tick sizes: 0.01, 0.1, 1, 10, 100. Selected in the panel UI (0.01 = no aggregation).

Data Feed Requirements

Optional methods on a custom DataFeed:

typescript
subscribeOrderBookData(symbol: Symbol, callback: OrderDataCallback, uuid?: string): void
unsubscribeOrderBookData(symbol: Symbol, uuid?: string): void

ChartSpire always passes a subscriber uuid. Track handlers by that ID, share one backend channel per symbol, and unsubscribe from the provider only when the last local subscriber is removed. See Data Access.

Payload (OrderBookData):

typescript
interface OrderBookData {
  bids: Array<[string, string]>  // [price, quantity]
  asks: Array<[string, string]>  // [price, quantity]
  timestamp: number              // ms
}

Example:

typescript
{
  bids: [["119361.91", "0.15"], ["119361.90", "0.08"]],
  asks: [["119362.46", "0.12"], ["119362.47", "0.18"]],
  timestamp: 1640995200000
}

Send full snapshots on each update. The UI sorts and aggregates for display. Full types: Type Reference.