DpExchange.Core.Types.OrderBook (DpExchangeCore v0.1.4)

Copy Markdown View Source

Normalised order book snapshot, returned by every venue package.

bids and asks are sorted by price, best price first:

  • bids descending — highest bid first
  • asks ascending — lowest ask first

Each level is a {price, quantity} tuple. The ordering is part of the contract, not a convenience: a caller reading hd(bids) as the best bid is reading it correctly, and a venue package that returns venue-order without re-sorting has broken the contract even though every value in it is true.

:timestamp is the venue's own, used as-is. :sequence is the venue's book sequence number where it publishes one, for callers reconciling snapshots against a delta stream, and nil where it does not.

Summary

Types

level()

@type level() :: {Decimal.t(), Decimal.t()}

t()

@type t() :: %DpExchange.Core.Types.OrderBook{
  asks: [level()],
  bids: [level()],
  provider: atom() | String.t(),
  sequence: integer() | nil,
  symbol: String.t(),
  timestamp: DateTime.t()
}