Skip to content

Stock Trades

Streams every trade print for one stock. 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::fpss::protocol::Contract;
use thetadatadx::fpss::{FpssData, FpssEvent};

tdx.start_streaming(|event: &FpssEvent| {
    if let FpssEvent::Data(FpssData::Trade { contract, price, size, .. }) = event {
        println!("{} price={price} size={size}", contract.symbol);
    }
})?;

let sub = Contract::stock("AAPL").trade();
tdx.subscribe(sub.clone())?;

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

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.
ext_condition1i32Additional trade condition code.
ext_condition2i32Additional trade condition code.
ext_condition3i32Additional trade condition code.
ext_condition4i32Additional trade condition code.
conditioni32Trade condition code.
sizei32Number of contracts or shares traded.
exchangei32Exchange code where the trade executed.
pricef64Trade price.
condition_flagsi32Trade condition flags bitmap.
price_flagsi32Trade price flags bitmap.
volume_typei32Volume reporting mode: 0 = incremental, 1 = cumulative.
records_backi32Offset of this record behind the most recent record.
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.

Released under the Apache-2.0 License.