WebSocket Market Data Feed (Beta)

The streaming API is currently in Beta and subject to change. We will strive to minimize disruption.

Overview

WebSockets are a bi-directional communication protocol for the web. City API supports the WebSocket protocol for streaming market data updates. This is an alternative to our REST API, which requires polling for simulating real-time market data.

The WebSocket feed can be access at:

wss://stream.optionscity.com/marketdata/stream

Managing Subscriptions

Much like with the REST API, the WebSocket feed supports subscriptions to individual instruments and sides. There is no limit to the number of subscription messages that can be sent to the sever, nor is there any restriction on when they can be sent. Subscription messages are additive -- subsequent subscription messages will not unsubscribe you from previous subscriptions. Instead, unsubscribing is handled through explicit 'unsubscribe' messages.

Subscribe

You may subscribe to any combination of instruments and sides with a message like the following:

{
  "type": "subscribe",
  "instrument_ids": [1565, 1323],
  "sides": ["Buy", "Sell", "Last"]
}

Unsubscribe

You may unsubscribe from any combination of instruments and sides with a message like the following:

{
  "type": "unsubscribe",
  "instrument_ids": [1565],
  "sides": ["Buy", "Sell"]
}

Unsubscribe from All Data

You may unsubscribe from all data with an 'unsubscribe_all' message:

{
  "type": "unsubscribe_all"
}

Depth Data

The streaming feed supports full depth data, although unlike the REST API, which uses the include_depth argument, special "side" designations are used, namely BuyDepth and SellDepth.

Feed Data

Market data updates will be sent as they happen. Each update will be a single piece of market data encoded as a standard market data update, the same encoding used in the REST API, minus theoretical values and greeks.

Here is some sample output from the feed, formatted for readability:

{
  "instrument_id":1565,
  "price":5522,
  "quantity":1,
  "side":"Last",
  "timestamp":"2017-11-16T12:40:15.488-06:00"
}

{
  "instrument_id":1565,
  "price":5522,
  "quantity":12,
  "side":"Buy",
  "timestamp":"2017-11-16T12:40:15.488-06:00"
}

{
  "instrument_id":1323,
  "price":5544,
  "quantity":61,
  "side":"Sell",
  "timestamp":"2017-11-16T12:40:15.488-06:00"
}

Theoretical Values and Greeks

Theoretical values and greeks are not available in the streaming API.