tdbe 0.12.8

ThetaData Binary Encoding -- market data types, FIT/FIE codecs, Black-Scholes Greeks
Documentation
// @generated DO NOT EDIT -- regenerated by
// `cargo run -p thetadatadx --bin generate_sdk_surfaces`
// from `crates/thetadatadx/tick_schema.toml`.
//
// Per-tick `#[repr(C, align(N))]` struct definitions. The
// hand-written `tick.rs` `pub use`s every type from this file,
// adds the `impl_contract_id!` macro applications + custom
// `Display` / `OptionContract` impls, then re-exports through
// `tdbe::types::tick`.

/// Calendar day -- 5 fields. Market open/close schedule.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct CalendarDay {
    pub date: i32,
    pub is_open: i32,
    pub open_time: i32,
    pub close_time: i32,
    pub status: i32,
}

/// End-of-day tick -- 17 fields. Full EOD snapshot with OHLC + quote.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct EodTick {
    pub ms_of_day: i32,
    pub ms_of_day2: i32,
    pub open: f64,
    pub high: f64,
    pub low: f64,
    pub close: f64,
    pub volume: i64,
    pub count: i64,
    pub bid_size: i32,
    pub bid_exchange: i32,
    pub bid: f64,
    pub bid_condition: i32,
    pub ask_size: i32,
    pub ask_exchange: i32,
    pub ask: f64,
    pub ask_condition: i32,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Full union Greeks tick -- every Greek the v3 server publishes on the
/// `option_*_greeks_all` and `option_*_greeks_eod` endpoints.
///
/// The vendor's per-order endpoints (`option_*_greeks_first_order`,
/// `_second_order`, `_third_order`) emit strict subsets of these columns
/// and bind to `GreeksFirstOrderTick`, `GreeksSecondOrderTick`,
/// `GreeksThirdOrderTick` respectively. `option_*_greeks_implied_volatility`
/// binds to `IvTick`.
///
/// The wire-level `timestamp` -> `ms_of_day`, `underlying_timestamp` ->
/// `underlying_ms_of_day`, and `implied_vol` -> `implied_volatility`
/// mappings are applied through `HEADER_ALIASES` in
/// `crates/thetadatadx/src/decode.rs`.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct GreeksAllTick {
    pub ms_of_day: i32,
    pub bid: f64,
    pub ask: f64,
    pub implied_volatility: f64,
    pub delta: f64,
    pub gamma: f64,
    pub theta: f64,
    pub vega: f64,
    pub rho: f64,
    pub iv_error: f64,
    pub vanna: f64,
    pub charm: f64,
    pub vomma: f64,
    pub veta: f64,
    pub speed: f64,
    pub zomma: f64,
    pub color: f64,
    pub ultima: f64,
    pub d1: f64,
    pub d2: f64,
    pub dual_delta: f64,
    pub dual_gamma: f64,
    pub epsilon: f64,
    pub lambda: f64,
    pub vera: f64,
    pub underlying_ms_of_day: i32,
    pub underlying_price: f64,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// First-order Greeks tick -- the strict column subset emitted by the
/// vendor's `option_*_greeks_first_order` endpoints (delta / theta / vega
/// / rho / epsilon / lambda) plus the bid/ask quote pair, the IV pair, and
/// the underlying snapshot used to derive each Greek.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct GreeksFirstOrderTick {
    pub ms_of_day: i32,
    pub bid: f64,
    pub ask: f64,
    pub delta: f64,
    pub theta: f64,
    pub vega: f64,
    pub rho: f64,
    pub epsilon: f64,
    pub lambda: f64,
    pub implied_volatility: f64,
    pub iv_error: f64,
    pub underlying_ms_of_day: i32,
    pub underlying_price: f64,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Second-order Greeks tick -- the strict column subset emitted by the
/// vendor's `option_*_greeks_second_order` endpoints (gamma / vanna /
/// charm / vomma / veta) plus the bid/ask quote pair, the IV pair, and the
/// underlying snapshot.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct GreeksSecondOrderTick {
    pub ms_of_day: i32,
    pub bid: f64,
    pub ask: f64,
    pub gamma: f64,
    pub vanna: f64,
    pub charm: f64,
    pub vomma: f64,
    pub veta: f64,
    pub implied_volatility: f64,
    pub iv_error: f64,
    pub underlying_ms_of_day: i32,
    pub underlying_price: f64,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Third-order Greeks tick -- the strict column subset emitted by the
/// vendor's `option_*_greeks_third_order` endpoints (speed / zomma /
/// color / ultima) plus the bid/ask quote pair, the IV pair, and the
/// underlying snapshot. The vendor's third-order schema does not publish
/// `vera`.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct GreeksThirdOrderTick {
    pub ms_of_day: i32,
    pub bid: f64,
    pub ask: f64,
    pub speed: f64,
    pub zomma: f64,
    pub color: f64,
    pub ultima: f64,
    pub implied_volatility: f64,
    pub iv_error: f64,
    pub underlying_ms_of_day: i32,
    pub underlying_price: f64,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Interest rate tick -- 3 fields. End-of-day interest rate.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct InterestRateTick {
    pub ms_of_day: i32,
    pub rate: f64,
    pub date: i32,
}

/// Implied volatility tick -- 4 fields.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct IvTick {
    pub ms_of_day: i32,
    pub implied_volatility: f64,
    pub iv_error: f64,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Market value tick -- quoted bid/ask/price for a symbol.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct MarketValueTick {
    pub ms_of_day: i32,
    pub market_bid: f64,
    pub market_ask: f64,
    pub market_price: f64,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// OHLC tick -- 8 fields. Aggregated bar data.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct OhlcTick {
    pub ms_of_day: i32,
    pub open: f64,
    pub high: f64,
    pub low: f64,
    pub close: f64,
    pub volume: i64,
    pub count: i64,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Open interest tick -- 3 fields.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct OpenInterestTick {
    pub ms_of_day: i32,
    pub open_interest: i32,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Option contract -- 4 fields. Contract specification.
///
/// Cannot be `Copy` because of the `String` symbol field.
#[must_use]
#[derive(Debug, Clone)]
#[repr(C)]
pub struct OptionContract {
    pub symbol: String,
    pub expiration: i32,
    pub strike: f64,
    pub right: i32,
}

/// Price tick -- 3 fields. Generic price data point.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct PriceTick {
    pub ms_of_day: i32,
    pub price: f64,
    pub date: i32,
}

/// Quote tick -- 10 fields + midpoint. NBBO quote data.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct QuoteTick {
    pub ms_of_day: i32,
    pub bid_size: i32,
    pub bid_exchange: i32,
    pub bid: f64,
    pub bid_condition: i32,
    pub ask_size: i32,
    pub ask_exchange: i32,
    pub ask: f64,
    pub ask_condition: i32,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
    /// Pre-computed midpoint: `(bid + ask) / 2.0`.
    pub midpoint: f64,
}

/// Combined trade + quote tick -- 24 fields.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct TradeQuoteTick {
    pub ms_of_day: i32,
    pub sequence: i32,
    pub ext_condition1: i32,
    pub ext_condition2: i32,
    pub ext_condition3: i32,
    pub ext_condition4: i32,
    pub condition: i32,
    pub size: i32,
    pub exchange: i32,
    pub price: f64,
    pub condition_flags: i32,
    pub price_flags: i32,
    pub volume_type: i32,
    pub records_back: i32,
    pub quote_ms_of_day: i32,
    pub bid_size: i32,
    pub bid_exchange: i32,
    pub bid: f64,
    pub bid_condition: i32,
    pub ask_size: i32,
    pub ask_exchange: i32,
    pub ask: f64,
    pub ask_condition: i32,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}

/// Trade tick -- 15 fields. Core unit of trade data.
#[must_use]
#[derive(Debug, Clone, Copy)]
#[repr(C, align(64))]
pub struct TradeTick {
    pub ms_of_day: i32,
    pub sequence: i32,
    pub ext_condition1: i32,
    pub ext_condition2: i32,
    pub ext_condition3: i32,
    pub ext_condition4: i32,
    pub condition: i32,
    pub size: i32,
    pub exchange: i32,
    pub price: f64,
    pub condition_flags: i32,
    pub price_flags: i32,
    pub volume_type: i32,
    pub records_back: i32,
    pub date: i32,
    /// Contract expiration (`YYYYMMDD`). Populated on wildcard queries, 0 otherwise.
    pub expiration: i32,
    /// Contract strike price (decoded to `f64`).
    pub strike: f64,
    /// Contract right (`'C'` = 67, `'P'` = 80 ASCII). 0 on single-contract queries.
    pub right: i32,
}