Skip to main content

MarketDataSnapshotRequest

MarketDataSnapshotRequest subscribes to real-time market depth updates for a specified trading symbol. Code example for subscribing to market data:
def subscribe_marketdata(ws, symbol, receiver, accountId=None, subaccountId=None):
    payload = {
        "type": "subscribe",
        "symbol": symbol,
        "reqId": str(uuid.uuid4())
    }
    if accountId is not None:
        payload["accountId"] = accountId
    if subaccountId is not None:
        payload["subaccountId"] = subaccountId

    msg = json.dumps({
        "messageType": "MarketDataSnapshotRequest",
        "timestamp": datetime.now().isoformat(),
        "payload": payload
    })
    ws.send(msg)
    while True:
        resp = json.loads(ws.recv())
        receiver(resp)
Subscription example — BTC-USD:
{
  "messageType": "MarketDataSnapshotRequest",
  "timestamp": "2023-02-08T14:19:43.901696",
  "payload": {
    "type": "subscribe",
    "symbol": "BTC-USD",
    "reqId": "e07b9683-af27-481a-b4db-1c492114e930"
  }
}
Example response:
{
  "messageType": "MarketDataSnapshot",
  "timestamp": "2023-02-08T14:19:44Z",
  "version": "1.0",
  "seqNum": 9,
  "sessionId": "fcd5d616-8208-401a-9001-d299bcc9a8c6",
  "payload": {
    "asks": [
      { "price": "23083.25076763", "size": "1" },
      { "price": "23084.28705625", "size": "4" },
      { "price": "23084.78", "size": "5" },
      { "price": "23089.14", "size": "40" },
      { "price": "23094.57", "size": "50" }
    ],
    "bids": [
      { "price": "23081.96", "size": "1" },
      { "price": "23080.96918517", "size": "4" },
      { "price": "23080.61566563", "size": "5" },
      { "price": "23074.06841953", "size": "40" },
      { "price": "23068.87", "size": "50" }
    ],
    "reqId": "e07b9683-af27-481a-b4db-1c492114e930",
    "symbol": "BTC-USD"
  }
}

Subscription parameters

ParameterTypeRequiredDescription
messageTypestringYes"MarketDataSnapshotRequest"
symbolstringYesTrading pair to subscribe to, e.g. BTC-USD
reqIdstring (UUID)YesUnique request ID for this subscription
accountIdstring (UUID)NoScopes the feed to a specific account. Use either accountId or subaccountId, not both.
subaccountIdstring (UUID)NoScopes the feed to a specific subaccount. Use either accountId or subaccountId, not both.

Response parameters

ParameterTypeRequiredDescription
messageTypestringYesIdentifies the message as a market data snapshot response
symbolstringYesTrading pair for this snapshot, e.g. BTC-USD
asksobject[]YesFull list of asks
pricestringYesLimit price of the level
sizestringYesSize of this level
bidsobject[]YesFull list of bids
pricestringYesLimit price of the level
sizestringYesSize of this level