Skip to content

Market data

The market-data namespace exposes the raw wire feeds that sit underneath the derived analytics: top-of-book NBBO quotes and trade prints, delivered verbatim rather than rolled into a bar, Greek, or flow metric. It is reached through client.market_data(), which returns a scope with five accessors:

AccessorFeedRow
stock_quotes(...)Equity top-of-book NBBOQuoteRow
option_quotes(...)Option-chain top-of-book NBBOQuoteRow
stock_trades(...)Equity printsTradeRow
option_trades(...)Option-chain printsTradeRow
index_trades(...)Index printsTradeRow

Each accessor names its securities up front and returns the same fluent builder the analytic surface uses, so the chain terminates with .on_event, delivering each quote or print to the callback as a typed QuoteRow / TradeRow.

The feeds share the client's session. Opening one is a single subscription on the existing connection, not a second login, so a desk can run raw quotes, raw prints, and derived analytics side by side off one authenticated client.

Indices ride the trade feed exclusively; the canonical index level arrives on the print, and there is no separate index-quote stream, so the scope exposes no index_quotes accessor.

Shape

rust
// Cargo.toml:
//   kairos = "0.1"

use kairos::{Client, QuoteRow};

let client = Client::connect(("me@example.com", "secret"))?;

let sub = client
    .market_data()
    .stock_quotes(["QQQ"])            // names the universe
    .on_event(|row: &QuoteRow| {      // terminal verb; fires per quote
        // row.contract.symbol, row.bid, row.ask, ...
        println!("{} {}/{}", row.contract.symbol, row.bid, row.ask);
    })?;

// … later …
sub.unsubscribe();

The accessor argument takes any Into<Targets>: a bare symbol or a list of symbols. Bare ticker strings expand to the full chain on that symbol (option feeds) or to the underlying leg (stock feeds). Callers identify contracts by symbol, never by an engine-internal contract integer.

Row fields

Each row carries the contract-identity tuple (symbol, expiration, right, strike) on row.contract followed by the wire tick's fields; expiration, right, and strike are None on stock and index legs and carry the option's terms on option legs.

  • QuoteRow for the two quote feeds: bid / bid_size / bid_exchange / bid_condition and the matching ask side, plus date / ms_of_day.
  • TradeRow for the three trade feeds: price / size / exchange / condition plus the sequence, volume_type, records_back, price_flags, and condition_flags wire fields.

The rows mirror the engine's QuoteTick and TradeTick shapes one field at a time; see Tick types for the field-level definitions.

Live-only

The raw feeds are a live-session subscription, not a deterministic offline query, so the market-data scope has no historical or replay analogue. Consume a raw feed with .on_event exactly as a live analytic stream; it runs until you unsubscribe().

Errors (LinkError)

Market-data subscriptions surface the same LinkError taxonomy the analytic builders do — a bad symbol set, an entitlement gate, or an engine-side rejection fires before the subscription state is allocated. See Errors for the full variant list.

See also

  • Subscription builder for the derived analytic feeds off the same client.
  • Tick types for the QuoteTick / TradeTick field definitions the rows project.
  • Client for the parent client.
  • Errors for the full LinkError taxonomy.

Proprietary. All rights reserved.