Skip to content

Option Trades ​

Streams every trade print for one option contract. Each execution delivers a Trade event to the registered callback.

The snippets below assume a connected client with streaming started; see Getting Started for the connect-and-stream ladder.

rust
use thetadatadx::streaming::{Contract, OptionLeg};
use thetadatadx::streaming::{StreamData, StreamEvent};

client.stream().start_streaming(|event: &StreamEvent| {
    if let StreamEvent::Data(StreamData::Trade { contract, price, size, .. }) = event {
        println!("{} price={price} size={size}", contract.symbol);
    }
})?;

let sub = Contract::option("SPY", OptionLeg { expiration: "20261218", strike: "570", right: "C" })?.trade();
client.stream().subscribe(sub.clone())?;

// Remove this stream; the session stays open for other subscriptions.
client.stream().unsubscribe(sub)?;

Trade event fields ​

Each update arrives as a Trade event with these fields:

FieldTypeDescription
contractcontractResolved contract identity (symbol, security type, and option fields).
ms_of_dayi32Milliseconds since midnight Eastern Time.
sequencei32Exchange-assigned trade sequence number.
conditioni32Trade condition code.
sizei32Number of contracts or shares traded.
exchangei32Exchange code where the trade executed.
pricef64Trade price.
datei32Trading date as a YYYYMMDD integer.
received_at_nsu64Local receive timestamp, nanoseconds since the Unix epoch.

The contract field carries symbol, the security type, and, for options, expiration, right, and the strike. See Handling Events for the full event catalogue and per-language field shapes.

WebSocket frame ​

The native SDK callbacks (Rust/Python/TypeScript/C++) receive every field above. Each raw WebSocket frame (the Server tab) is { "header": {…}, "contract": {…}, "trade": {…} }: header and contract are always present, while the trade payload object carries only the terminal-compatible subset: ms_of_day, sequence, size, condition, price, exchange, date. The remaining event fields are delivered to the SDK callbacks, not the trade payload object.

Released under the Apache-2.0 License.