Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit/llms.txt
Use this file to discover all available pages before exploring further.
getOrderBook fetches the current or historical order book for a trading pair from the registered exchange adapter. Like the candle functions, it uses AsyncLocalStorage to read the current execution context and aligns the request time to a configured offset boundary so that backtest runs see a deterministically reproducible snapshot window. In live mode the from/to parameters are passed to the adapter but most exchanges (including Binance GET /api/v3/depth) only expose the current order book, so they are typically ignored by the live implementation.
IOrderBookData
getOrderBook
Trading pair symbol (e.g.,
"BTCUSDT").Maximum number of price levels to return for both bids and asks. Defaults to
CC_ORDER_BOOK_MAX_DEPTH_LEVELS (default: 20).Time-Range Alignment
The function computes a time window by aligning the execution contextwhen to CC_ORDER_BOOK_TIME_OFFSET_MINUTES boundaries:
CC_ORDER_BOOK_TIME_OFFSET_MINUTES = 10 and when = 00:12:00 UTC:
| Field | Value |
|---|---|
alignedTo | 00:10:00 UTC |
to | 00:10:00 UTC |
from | 00:00:00 UTC |
(symbol, depth, from, to, backtest) are forwarded to the exchange adapter’s getOrderBook implementation.
Configuration Options
Minutes used as the alignment window size. Controls how
from and to are calculated for the order book request. Default: 10.Default depth levels for both bids and asks when
depth is not explicitly passed to getOrderBook. Default: 20.setConfig:
Exchange Adapter Contract
The exchange adapter receives:Start of the aligned time window. May be ignored in live implementations.
End of the aligned time window (aligned down). May be ignored in live implementations.
true during backtest execution. Use this flag to switch between a historical snapshot database and the live exchange API.Backtest vs Live
A typical adapter pattern:getOrderBook is not provided in the exchange schema, calling getOrderBook() from a strategy will throw an error.