CCXT.OrderBook (ccxt_client v0.6.1)

Copy Markdown View Source

Unified order book (market depth) data.

Contains sorted bid and ask price levels, each as [price, amount] pairs. Bids are sorted highest-first, asks lowest-first.

Fields

  • symbol - Unified symbol (e.g., "BTC/USDT")
  • timestamp - Exchange timestamp in milliseconds
  • datetime - ISO 8601 datetime string
  • nonce - Incremental update sequence number
  • bids - List of bid levels as [price, amount] pairs, highest first
  • asks - List of ask levels as [price, amount] pairs, lowest first
  • info - Raw exchange response

Summary

Functions

Returns the best (lowest) ask price, or nil if empty/malformed.

Returns the best (highest) bid price, or nil if empty/malformed.

JSON Schema for the OrderBook unified type.

Returns the spread (best ask price - best bid price), or nil if either side is empty/malformed.

Types

t()

@type t() :: %CCXT.OrderBook{
  asks: [[number()]],
  bids: [[number()]],
  datetime: String.t() | nil,
  info: map() | nil,
  nonce: integer() | nil,
  symbol: String.t() | nil,
  timestamp: integer() | nil
}

Functions

best_ask(order_book)

@spec best_ask(t()) :: number() | nil

Returns the best (lowest) ask price, or nil if empty/malformed.

best_bid(order_book)

@spec best_bid(t()) :: number() | nil

Returns the best (highest) bid price, or nil if empty/malformed.

schema()

@spec schema() :: map()

JSON Schema for the OrderBook unified type.

spread(ob)

@spec spread(t()) :: number() | nil

Returns the spread (best ask price - best bid price), or nil if either side is empty/malformed.