Function getOrderBook

  • Fetches order book for a trading pair from the registered exchange.

    Uses current execution context to determine timing. The underlying exchange implementation receives time range parameters but may use them (backtest) or ignore them (live trading).

    Parameters

    • symbol: string

      Trading pair symbol (e.g., "BTCUSDT")

    • Optionaldepth: number

      Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)

    Returns Promise<IOrderBookData>

    Promise resolving to order book data

    Error if execution or method context is missing

    const orderBook = await getOrderBook("BTCUSDT");
    console.log(orderBook.bids); // [{ price: "50000.00", quantity: "0.5" }, ...]
    console.log(orderBook.asks); // [{ price: "50001.00", quantity: "0.3" }, ...]

    // Fetch deeper order book
    const deepBook = await getOrderBook("BTCUSDT", 100);