- Stream Greeks by Strike and by Expiry to a DuckDB Database (python): https://github.com/unusual-whales/api-examples/tree/main/examples/ws-stream-spot-greeks-by-strike-by-expiry
- Stream Flow Alerts to a SQLite Database (python): https://github.com/unusual-whales/api-examples/tree/main/examples/ws-stream-flow-alerts-to-sqlite
- Stream Periscope Greek Exposure to a Partitioned Parquet Store (python): https://github.com/unusual-whales/api-examples/tree/main/examples/ws-stream-periscope-greek-exposure
- Stream Multiple Channels to Multiple Outfiles (python): https://github.com/unusual-whales/api-examples/tree/main/examples/ws-multi-channel-multi-output
- Stream Multiple Channels to Multiple Outfiles (javascript): https://github.com/unusual-whales/api-examples/tree/main/examples/ws-multi-channel-multi-output-nodejs
Connecting
Connect to the socket with your API token on the query string, then join a channel.["<channel>", { ... }]. Send a real User-Agent on the handshake.
Scope a channel to a ticker with a colon, for example gex_strike:SPY. See Channels for every channel.
Connect with websocat
For a python example script that streams gex by ticker (gex:TICKER), flow alerts (flow-alerts), and all TSLA option trades (option_trades:TSLA), see our “examples” repo on Github: https://github.com/unusual-whales/api-examples/tree/main/examples/ws-multi-channel-multi-output We will use websocat to demonstrate how to connect to the WebSocket server.Channels
The following channels are available:
The
option_trades channel will stream all 6,000,000 option trades in real-time, option_trades:<TICKER> will stream
all option trades for the given ticker in real-time.
flow-alerts will stream from the alerts page
Using a client
If you are using Python, you can use the websocket-client library to connect to the server.Connections
Connect each API token from a single machine. The same token connected from more than one machine at a time is not supported and results in dropped connections. Use a separate token per host.Buffering
Buffer incoming messages and write them on an interval rather than once per message. A consumer that writes to storage on every payload will fall behind on high-volume channels and be dropped as a slow client. Flush on a timer, for example once per second, or after a set number of records, whichever comes first. Reference consumers:- Buffer to SQLite, flush once per second: ws-stream-flow-alerts-to-sqlite
- Buffer to DuckDB, flush every second or every 500 records, whichever comes first: ws-stream-spot-greeks-by-strike-by-expiry
Recovery
The stream has no replay, resume, or sequence numbers. Messages missed during a disconnect are not redelivered on reconnect. For delivery guaranteed across gaps, use Kafka which has a retention period of 72h. Thegex_strike data has no intraday REST backfill, so capture it live.
Historic data
To download/access historic data, use the endpoint /api/option-trades/full-tapeThe price channel
Subscribe to price with no ticker to receive live prices for all tickers on one connection. price:{TICKER} streams a single ticker. To follow many tickers, subscribe once to price rather than opening a price:{TICKER} subscription per symbol.
Periscope values
On theperiscope channels, the streamed gamma, charm, and vanna are net Market Maker greek exposure, not the dollarized *_per_one_percent_move_oi values returned by the REST spot-exposures endpoints. They are on different scales, so do not compare them directly.