Skip to content

Order Book Data

The orderbook realtime stream delivers continuously updating market-depth data for subscribed instruments.

LLM guidance

Use this page when the application needs live market-depth updates keyed by ref_id. Use Market Quotes for one-time order-book snapshots instead of a streaming feed.

Basic Usage

from nubra_python_sdk.ticker import websocketdata
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv

nubra = InitNubraSdk(NubraEnv.PROD, env_creds=True)

def on_orderbook_data(msg):
    print("[ORDERBOOK]", msg)

def on_connect(msg):
    print("[status]", msg)

def on_close(reason):
    print(f"Closed: {reason}")

def on_error(err):
    print(f"Error: {err}")

socket = websocketdata.NubraDataSocket(
    client=nubra,
    on_orderbook_data=on_orderbook_data,
    on_connect=on_connect,
    on_close=on_close,
    on_error=on_error,
)

socket.connect()
socket.subscribe(["1746686"], data_type="orderbook")
socket.keep_running()

Subscription Contract

Parameter Type Required Meaning
ref_ids list[str] yes instrument reference IDs
data_type str yes must be orderbook

Response Shape

class OrderBookWrapper:
    ref_id: int
    timestamp: int
    last_traded_price: int
    last_traded_quantity: int
    volume: int
    bids: list[Orders]
    asks: list[Orders]

class Orders:
    price: int
    quantity: int
    num_orders: int

Response Contract

Field Type Meaning
ref_id int subscribed instrument identifier
timestamp int event timestamp
last_traded_price int latest traded price
last_traded_quantity int latest traded quantity
volume int traded volume
bids list[Orders] bid-side market depth
asks list[Orders] ask-side market depth
bids[].price / asks[].price int price at that level
bids[].quantity / asks[].quantity int quantity at that level
bids[].num_orders / asks[].num_orders int order count at that level

Implementation Notes

  • This stream is the realtime counterpart to snapshot Market Quotes.
  • Use ref_id values resolved from the instruments master.
  • Bid and ask prices are returned in exchange-native units where applicable.

Important Rules

  • This is a realtime stream, not a snapshot API.
  • orderbook subscriptions require valid ref_id values.
  • Do not reuse environment-specific identifiers across UAT and PROD.
  • Review Subscription Limits before opening large numbers of depth subscriptions.
  1. Realtime Data
  2. Subscription Limits
  3. Market Quotes
  4. Get Instruments
NEO Assistant