Vela, our next-generation charting platform, is live at vela.luxalgo.com.
LuxAlgo

Order book

API reference for @luxalgo/vela-pro-dom, including the order book plugin, standalone DOM widget, and settings types.

View as Markdown

This page documents @luxalgo/vela-pro-dom, the order book (DOM) module package, including the orderBook() plugin factory, createOrderBook standalone widget, and ladder display settings.

Import symbols on this page from @luxalgo/vela-pro-dom. Related guides: Order book, Quotes and market depth, Standalone widgets.

Functions

createOrderBook

The order book (book, DOM ladder, trades tape) as a widget: { el, tools, update, destroy }.

function createOrderBook(props?: OrderBookProps): OrderBookWidget

See also: OrderBookProps, OrderBookWidget.

dom

The order book (book, DOM ladder, trades tape) as a Vela Pro plugin. With trading added, the ladder trades.

function dom(opts?: EnableOrderBookOptions): VelaProPlugin<void>

See also: EnableOrderBookOptions, VelaProPlugin.

enableOrderBook

Enable the ORDER BOOK side panel on every shell built afterwards. Call ONCE. Idempotent.

function enableOrderBook(opts?: EnableOrderBookOptions): void

See also: EnableOrderBookOptions.

mergeBooks

Several venues' books as one: the sizes summed at each price, on the coarsest tick among them.

function mergeBooks(books: readonly BookSnapshot[]): BookSnapshot | null

See also: BookSnapshot.

Classes

OrderBookWidget

class OrderBookWidget {
    constructor(props?: OrderBookProps);
    readonly el: HTMLElement;
    readonly tools: HTMLElement;
    update(next: Partial<Omit<OrderBookProps, 'views' | 'rows'>>): void;
    destroy(): void;
    settings(): OrderBookSettings;
    applySettings(s: OrderBookSettings): void;
}
MemberTypeDescription
constructor(props?: OrderBookProps)
elHTMLElement
toolsHTMLElementThe compact controls (venue, grouping, settings): in the widget's top row until a host lifts them into a header of its own.
update()(next: Partial<Omit<OrderBookProps, 'views' | 'rows'>>) => void
destroy()() => void
settings()() => OrderBookSettingsWhat the user set, for a host to keep.
applySettings()(s: OrderBookSettings) => voidApply settings a host kept (a saved session's, or another order book's).

See also: OrderBookProps, OrderBookSettings.

Interfaces and types

DepthDirectory

Resolves a symbol to the provider that streams its book and trades: the chart's data, or any source with the same methods. With ready, a symbol is resolved only once it has settled; with symbols, the book can be read from the market's other listings too.

type DepthDirectory = Pick<WidgetContext['chart']['data'], 'resolve' | 'providerInstance' | 'canonicalSymbol'> & Partial<Pick<WidgetContext['chart']['data'], 'ready' | 'symbols'>>;

From @luxalgo/vela/plugin: WidgetContext.

DomColumn

A DOM column. Orders (your working orders and position) and P&L (the position's, were it closed at the price) show only with trading.

type DomColumn =
    | 'orders'
    | 'pnl'
    | 'sold'
    | 'bid'
    | 'price'
    | 'ask'
    | 'bought'
    | 'delta'
    | 'volume'
    | 'last';

EnableOrderBookOptions

Options for enableOrderBook.

interface EnableOrderBookOptions {
    views?: readonly OrderBookView[];
    clickTrading?: boolean;
    width?: number;
    order?: number;
    settings?: OrderBookSettings;
}
MemberTypeDescription
views?readonly OrderBookView[]The views and their order (default Book, DOM, Trades).
clickTrading?booleanA click on the DOM ladder trades there when trading is enabled (default true).
width?number
order?numberPlace among the panel buttons (default 3).
settings?OrderBookSettingsInitial settings: the DOM's columns, the depth mode, the combined book (the user's changes persist over them).

See also: OrderBookSettings, OrderBookView.

OrderBookProps

The order book's props. views and rows are read once; the others can change through update.

interface OrderBookProps {
    symbol?: string;
    directory?: () => DepthDirectory | null;
    views?: readonly OrderBookView[];
    rows?: number;
    host?: HTMLElement;
    active?: boolean;
    trading?: () => TradingApi | null;
    settings?: OrderBookSettings;
    onSettingsChange?: (settings: OrderBookSettings) => void;
    onPriceMenu?: (e: MouseEvent, at: { symbol: string; price: number; text: string }, actions: readonly PriceActionDescriptor[]) => { destroy(): void } | null;
}
MemberTypeDescription
symbol?stringThe market to follow.
directory?() => DepthDirectory | nullFinds the provider streaming the symbol's book and trades. Without one, the book says it is unsupported.
views?readonly OrderBookView[]The views and their order (default Book, DOM, Trades).
rows?numberRows a side in the Book view (default 14).
host?HTMLElementWhere menus mount (default: the widget's own element).
active?booleanFollow the market (default true). Off, the feeds close.
trading?() => TradingApi | nullThe trading surface DOM clicks trade through (null: the ladder is read-only).
settings?OrderBookSettingsSettings to start from (a host's saved ones).
onSettingsChange?(settings: OrderBookSettings) => voidCalled after the user changes a setting, with them all.
onPriceMenu?(e: MouseEvent, at: { symbol: string; price: number; text: string }, … (truncated; see declaration)A right-click on a price: the host opens a menu with these actions and returns it, to be closed by the next one. Without it, no menu.

See also: DepthDirectory, OrderBookSettings, OrderBookView, PriceActionDescriptor, TradingApi.

OrderBookSettings

The order book's settings a host keeps between sessions.

interface OrderBookSettings {
    domColumns?: readonly DomColumn[];
    cumulative?: boolean;
    combined?: boolean;
}
MemberTypeDescription
domColumns?readonly DomColumn[]The DOM's columns, in order; Price is always among them.
cumulative?booleanDepth bars show the running total.
combined?booleanRead every listing of the market as one book.

See also: DomColumn.

OrderBookView

type OrderBookView = 'book' | 'dom' | 'trades';

Constants

DEFAULT_DOM_COLUMNS

const DEFAULT_DOM_COLUMNS: readonly DomColumn[];

See also: DomColumn.

DOM_COLUMNS

const DOM_COLUMNS: readonly DomColumn[];

See also: DomColumn.

ORDERBOOK_PANEL_ID

const ORDERBOOK_PANEL_ID: 'vela-pro.orderbook';

On this page