API Reference
ThetaDataDx provides a unified client for accessing ThetaData market data across three public surfaces: historical request/response (MDDS over gRPC), real-time streaming (FPSS over TCP), and whole-universe daily blobs (FLATFILES over the legacy MDDS port). The SDK ships native bindings for Rust, Python, TypeScript/Node.js, and C++, all backed by the same compiled Rust core.
Complete typed historical surface + 4 streaming variants + the FLATFILES daily-blob surface (Rust today; cross-language bindings tracked under the FLATFILES roadmap section) + 23 Greeks functions + IV solver.
Client Construction
use thetadatadx::{ThetaDataDxClient, Credentials, DirectConfig};
let creds = Credentials::from_file("creds.txt")?;
let client = ThetaDataDxClient::connect(&creds, DirectConfig::production()).await?;from thetadatadx import Credentials, Config, ThetaDataDxClient
creds = Credentials.from_file("creds.txt")
client = ThetaDataDxClient(creds, Config.production())import { ThetaDataDxClient } from 'thetadatadx';
const client = await ThetaDataDxClient.connectFromFile('creds.txt');auto creds = tdx::Credentials::from_file("creds.txt");
auto client = tdx::UnifiedClient::connect(creds, tdx::Config::production());Stock Endpoints
stock_list_symbols
List all available stock ticker symbols.
let symbols = tdx.stock_list_symbols().await?;symbols = tdx.stock_list_symbols()const symbols = tdx.stockListSymbols();auto symbols = client.stock_list_symbols();Parameters: None
Returns: List of ticker symbol strings.
stock_list_dates
List available dates for a stock by request type.
let dates = tdx.stock_list_dates("TRADE", "AAPL").await?;dates = tdx.stock_list_dates("TRADE", "AAPL")const dates = tdx.stockListDates('TRADE', 'AAPL');auto dates = client.stock_list_dates("TRADE", "AAPL");| Parameter | Type | Required | Description |
|---|---|---|---|
request_type | string | Yes | Data type: "TRADE", "QUOTE", "OHLC" |
symbol | string | Yes | Ticker symbol |
Returns: List of date strings (YYYYMMDD).
stock_snapshot_ohlc
Latest OHLC snapshot for one or more stocks.
let bars = tdx.stock_snapshot_ohlc(&["AAPL", "MSFT"]).await?;bars = tdx.stock_snapshot_ohlc(["AAPL", "MSFT"])const bars = tdx.stockSnapshotOhlc(['AAPL', 'MSFT']);auto bars = client.stock_snapshot_ohlc({"AAPL", "MSFT"});| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | Yes | One or more ticker symbols |
venue | string | No | Data venue filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: List of OhlcTick.
stock_snapshot_trade
Latest trade snapshot for one or more stocks.
let trades = tdx.stock_snapshot_trade(&["AAPL"]).await?;trades = tdx.stock_snapshot_trade(["AAPL"])const trades = tdx.stockSnapshotTrade(['AAPL']);auto trades = client.stock_snapshot_trade({"AAPL"});| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | Yes | One or more ticker symbols |
venue | string | No | Data venue filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: List of TradeTick.
stock_snapshot_quote
Latest NBBO quote snapshot for one or more stocks.
let quotes = tdx.stock_snapshot_quote(&["AAPL"]).await?;quotes = tdx.stock_snapshot_quote(["AAPL"])const quotes = tdx.stockSnapshotQuote(['AAPL']);auto quotes = client.stock_snapshot_quote({"AAPL"});| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | Yes | One or more ticker symbols |
venue | string | No | Data venue filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: List of QuoteTick.
stock_snapshot_market_value
Latest market value snapshot for one or more stocks.
let mv = tdx.stock_snapshot_market_value(&["AAPL"]).await?;mv = tdx.stock_snapshot_market_value(["AAPL"])const mv = tdx.stockSnapshotMarketValue(['AAPL']);auto mv = client.stock_snapshot_market_value({"AAPL"});| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | Yes | One or more ticker symbols |
venue | string | No | Data venue filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: Array of MarketValueTick records with market cap, shares outstanding, enterprise value, book value, free float.
stock_history_eod
End-of-day stock data across a date range.
let eod = tdx.stock_history_eod("AAPL", "20240101", "20240301").await?;eod = tdx.stock_history_eod("AAPL", "20240101", "20240301")const eod = tdx.stockHistoryEOD('AAPL', '20240101', '20240301');auto eod = client.stock_history_eod("AAPL", "20240101", "20240301");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
Returns: List of EodTick.
stock_history_ohlc
Intraday OHLC bars for a single date.
let bars = tdx.stock_history_ohlc("AAPL", "20240315", "60000").await?;bars = tdx.stock_history_ohlc("AAPL", "20240315", "60000")const bars = tdx.stockHistoryOHLC('AAPL', '20240315', '60000');auto bars = client.stock_history_ohlc("AAPL", "20240315", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
date | string | Yes | Date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
venue | string | No | Data venue filter |
Returns: List of OhlcTick.
stock_history_ohlc_range
Intraday OHLC bars across a date range.
let bars = tdx.stock_history_ohlc_range("AAPL", "20240101", "20240301", "60000").await?;bars = tdx.stock_history_ohlc_range("AAPL", "20240101", "20240301", "60000")const bars = tdx.stockHistoryOHLCRange('AAPL', '20240101', '20240301', '60000');auto bars = client.stock_history_ohlc_range("AAPL", "20240101", "20240301", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. |
Returns: List of OhlcTick.
stock_history_trade
All trades for a stock on a given date.
let trades = tdx.stock_history_trade("AAPL", "20240315").await?;trades = tdx.stock_history_trade("AAPL", "20240315")const trades = tdx.stockHistoryTrade('AAPL', '20240315');auto trades = client.stock_history_trade("AAPL", "20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
date | string | Yes | Date (YYYYMMDD) |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
venue | string | No | Data venue filter |
Returns: List of TradeTick.
Tier: Standard+
stock_history_quote
NBBO quotes for a stock at a given interval.
let quotes = tdx.stock_history_quote("AAPL", "20240315", "60000").await?;quotes = tdx.stock_history_quote("AAPL", "20240315", "60000")const quotes = tdx.stockHistoryQuote('AAPL', '20240315', '60000');auto quotes = client.stock_history_quote("AAPL", "20240315", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
date | string | Yes | Date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. Use "0" for every change. |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
venue | string | No | Data venue filter |
Returns: List of QuoteTick.
Tier: Standard+
stock_history_trade_quote
Combined trade + quote ticks for a stock on a given date.
let tq = tdx.stock_history_trade_quote("AAPL", "20240315").await?;tq = tdx.stock_history_trade_quote("AAPL", "20240315")const tq = tdx.stockHistoryTradeQuote('AAPL', '20240315');auto tq = client.stock_history_trade_quote("AAPL", "20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
date | string | Yes | Date (YYYYMMDD) |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
exclusive | bool | No | Exclusive time bounds |
venue | string | No | Data venue filter |
Returns: Array of TradeQuoteTick records with combined trade + quote fields.
Tier: Pro
stock_at_time_trade
Trade at a specific time of day across a date range.
let trades = tdx.stock_at_time_trade("AAPL", "20240101", "20240301", "09:30:00.000").await?;trades = tdx.stock_at_time_trade("AAPL", "20240101", "20240301", "09:30:00.000")const trades = tdx.stockAtTimeTrade('AAPL', '20240101', '20240301', '09:30:00.000');auto trades = client.stock_at_time_trade("AAPL", "20240101", "20240301", "09:30:00.000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
time_of_day | string | Yes | ET wall-clock time in HH:MM:SS.SSS (e.g. "09:30:00.000"; legacy "34200000" also accepted) |
venue | string | No | Data venue filter |
Returns: List of TradeTick, one per date.
stock_at_time_quote
Quote at a specific time of day across a date range.
let quotes = tdx.stock_at_time_quote("AAPL", "20240101", "20240301", "09:30:00.000").await?;quotes = tdx.stock_at_time_quote("AAPL", "20240101", "20240301", "09:30:00.000")const quotes = tdx.stockAtTimeQuote('AAPL', '20240101', '20240301', '09:30:00.000');auto quotes = client.stock_at_time_quote("AAPL", "20240101", "20240301", "09:30:00.000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Ticker symbol |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
time_of_day | string | Yes | ET wall-clock time in HH:MM:SS.SSS |
venue | string | No | Data venue filter |
Returns: List of QuoteTick, one per date.
Option Endpoints
All option endpoints that operate on a specific contract require the contract spec parameters: symbol, expiration, strike, and right.
symbol- Underlying ticker (e.g."SPY")expiration- Expiration date asYYYYMMDDstringstrike- Strike price in dollars as a string (e.g."500"or"17.5")right-"C"for call,"P"for put
option_list_symbols
List all available option underlying symbols.
let symbols = tdx.option_list_symbols().await?;symbols = tdx.option_list_symbols()const symbols = tdx.optionListSymbols();auto symbols = client.option_list_symbols();Parameters: None
Returns: List of underlying symbol strings.
option_list_dates
List available dates for an option contract by request type.
let dates = tdx.option_list_dates("TRADE", "SPY", "20241220", "500", "C").await?;dates = tdx.option_list_dates("TRADE", "SPY", "20241220", "500", "C")const dates = tdx.optionListDates('TRADE', 'SPY', '20241220', '500', 'C');auto dates = client.option_list_dates("TRADE", "SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
request_type | string | Yes | Data type: "TRADE", "QUOTE", etc. |
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date (YYYYMMDD) |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
Returns: List of date strings (YYYYMMDD).
option_list_expirations
List all expiration dates for an underlying.
let exps = tdx.option_list_expirations("SPY").await?;exps = tdx.option_list_expirations("SPY")const exps = tdx.optionListExpirations('SPY');auto exps = client.option_list_expirations("SPY");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
Returns: List of expiration date strings (YYYYMMDD).
option_list_strikes
List strike prices for a given expiration.
let strikes = tdx.option_list_strikes("SPY", "20241220").await?;strikes = tdx.option_list_strikes("SPY", "20241220")const strikes = tdx.optionListStrikes('SPY', '20241220');auto strikes = client.option_list_strikes("SPY", "20241220");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date (YYYYMMDD) |
Returns: List of strike price strings in dollars.
option_list_contracts
List all option contracts for a symbol on a given date.
let contracts = tdx.option_list_contracts("TRADE", "SPY", "20240315").await?;contracts = tdx.option_list_contracts("TRADE", "SPY", "20240315")const contracts = tdx.optionListContracts('TRADE', 'SPY', '20240315');auto contracts = client.option_list_contracts("TRADE", "SPY", "20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
request_type | string | Yes | Data type |
symbol | string | Yes | Underlying symbol |
date | string | Yes | Date (YYYYMMDD) |
max_dte | int | No | Maximum days to expiration filter |
Returns: Array of OptionContract records with symbol, expiration, strike, right.
option_snapshot_ohlc
Latest OHLC snapshot for an option contract.
let bars = tdx.option_snapshot_ohlc("SPY", "20241220", "500", "C").await?;bars = tdx.option_snapshot_ohlc("SPY", "20241220", "500", "C")const bars = tdx.optionSnapshotOhlc('SPY', '20241220', '500', 'C');auto bars = client.option_snapshot_ohlc("SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date (YYYYMMDD) |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: List of OhlcTick.
option_snapshot_trade
Latest trade snapshot for an option contract.
let trades = tdx.option_snapshot_trade("SPY", "20241220", "500", "C").await?;trades = tdx.option_snapshot_trade("SPY", "20241220", "500", "C")const trades = tdx.optionSnapshotTrade('SPY', '20241220', '500', 'C');auto trades = client.option_snapshot_trade("SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
strike_range | int | No | Strike range filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: List of TradeTick.
option_snapshot_quote
Latest NBBO quote snapshot for an option contract.
let quotes = tdx.option_snapshot_quote("SPY", "20241220", "500", "C").await?;quotes = tdx.option_snapshot_quote("SPY", "20241220", "500", "C")const quotes = tdx.optionSnapshotQuote('SPY', '20241220', '500', 'C');auto quotes = client.option_snapshot_quote("SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: List of QuoteTick.
option_snapshot_open_interest
Latest open interest snapshot for an option contract.
let oi = tdx.option_snapshot_open_interest("SPY", "20241220", "500", "C").await?;oi = tdx.option_snapshot_open_interest("SPY", "20241220", "500", "C")const oi = tdx.optionSnapshotOpenInterest('SPY', '20241220', '500', 'C');auto oi = client.option_snapshot_open_interest("SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: Array of OpenInterestTick records with ms_of_day, open_interest, date.
option_snapshot_market_value
Latest market value snapshot for an option contract.
let mv = tdx.option_snapshot_market_value("SPY", "20241220", "500", "C").await?;mv = tdx.option_snapshot_market_value("SPY", "20241220", "500", "C")const mv = tdx.optionSnapshotMarketValue('SPY', '20241220', '500', 'C');auto mv = client.option_snapshot_market_value("SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: Array of MarketValueTick records with market cap, shares outstanding, enterprise value, book value, free float.
option_snapshot_greeks_implied_volatility
Implied volatility snapshot for an option contract.
let iv = tdx.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500", "C").await?;iv = tdx.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500", "C")const iv = tdx.optionSnapshotGreeksImpliedVolatility('SPY', '20241220', '500', 'C');auto iv = client.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
annual_dividend | float | No | Override annual dividend |
rate_type | string | No | Interest rate type (e.g. "SOFR") |
rate_value | float | No | Override interest rate value |
stock_price | float | No | Override underlying price |
version | string | No | Greeks calculation version |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
min_time | string | No | Minimum time of day (ms from midnight) |
use_market_value | bool | No | Use market value instead of last trade |
Returns: Array of IvTick records with implied_volatility, iv_error.
Tier: Pro
option_snapshot_greeks_all
Snapshot of all Greeks for an option contract.
let greeks = tdx.option_snapshot_greeks_all("SPY", "20241220", "500", "C").await?;greeks = tdx.option_snapshot_greeks_all("SPY", "20241220", "500", "C")const greeks = tdx.optionSnapshotGreeksAll('SPY', '20241220', '500', 'C');auto greeks = client.option_snapshot_greeks_all("SPY", "20241220", "500", "C");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
annual_dividend | float | No | Override annual dividend |
rate_type | string | No | Interest rate type |
rate_value | float | No | Override interest rate value |
stock_price | float | No | Override underlying price |
version | string | No | Greeks calculation version |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
min_time | string | No | Minimum time of day |
use_market_value | bool | No | Use market value instead of last trade |
Returns: Array of GreeksTick records with all 23 Greeks.
Tier: Pro
option_snapshot_greeks_first_order
First-order Greeks snapshot (delta, theta, vega, rho, epsilon, lambda).
let g = tdx.option_snapshot_greeks_first_order("SPY", "20241220", "500", "C").await?;g = tdx.option_snapshot_greeks_first_order("SPY", "20241220", "500", "C")const g = tdx.optionSnapshotGreeksFirstOrder('SPY', '20241220', '500', 'C');auto g = client.option_snapshot_greeks_first_order("SPY", "20241220", "500", "C");Parameters are identical to option_snapshot_greeks_all.
Returns: Array of GreeksTick records with first-order Greeks (delta, theta, vega, rho).
Tier: Pro
option_snapshot_greeks_second_order
Second-order Greeks snapshot (gamma, vanna, charm, vomma, veta).
let g = tdx.option_snapshot_greeks_second_order("SPY", "20241220", "500", "C").await?;g = tdx.option_snapshot_greeks_second_order("SPY", "20241220", "500", "C")const g = tdx.optionSnapshotGreeksSecondOrder('SPY', '20241220', '500', 'C');auto g = client.option_snapshot_greeks_second_order("SPY", "20241220", "500", "C");Parameters are identical to option_snapshot_greeks_all.
Returns: Array of GreeksTick records with second-order Greeks (gamma, vanna, charm, vomma).
Tier: Pro
option_snapshot_greeks_third_order
Third-order Greeks snapshot (speed, zomma, color, ultima).
let g = tdx.option_snapshot_greeks_third_order("SPY", "20241220", "500", "C").await?;g = tdx.option_snapshot_greeks_third_order("SPY", "20241220", "500", "C")const g = tdx.optionSnapshotGreeksThirdOrder('SPY', '20241220', '500', 'C');auto g = client.option_snapshot_greeks_third_order("SPY", "20241220", "500", "C");Parameters are identical to option_snapshot_greeks_all.
Returns: Array of GreeksTick records with third-order Greeks (speed, zomma, color, ultima).
Tier: Pro
option_history_eod
End-of-day option data across a date range.
let eod = tdx.option_history_eod(
"SPY", "20241220", "500", "C", "20240101", "20240301"
).await?;eod = tdx.option_history_eod("SPY", "20241220", "500", "C", "20240101", "20240301")const eod = tdx.optionHistoryEOD('SPY', '20241220', '500', 'C', '20240101', '20240301');auto eod = client.option_history_eod("SPY", "20241220", "500", "C", "20240101", "20240301");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: List of EodTick.
option_history_ohlc
Intraday OHLC bars for an option contract.
let bars = tdx.option_history_ohlc(
"SPY", "20241220", "500", "C", "20240315", "60000"
).await?;bars = tdx.option_history_ohlc("SPY", "20241220", "500", "C", "20240315", "60000")const bars = tdx.optionHistoryOHLC('SPY', '20241220', '500', 'C', '20240315', '60000');auto bars = client.option_history_ohlc("SPY", "20241220", "500", "C", "20240315", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
date | string | Yes | Date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
strike_range | int | No | Strike range filter |
Returns: List of OhlcTick.
option_history_trade
All trades for an option contract on a given date.
let trades = tdx.option_history_trade("SPY", "20241220", "500", "C", "20240315").await?;trades = tdx.option_history_trade("SPY", "20241220", "500", "C", "20240315")const trades = tdx.optionHistoryTrade('SPY', '20241220', '500', 'C', '20240315');auto trades = client.option_history_trade("SPY", "20241220", "500", "C", "20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
date | string | Yes | Date (YYYYMMDD) |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: List of TradeTick.
Tier: Standard+
option_history_quote
NBBO quotes for an option contract.
let quotes = tdx.option_history_quote(
"SPY", "20241220", "500", "C", "20240315", "60000"
).await?;quotes = tdx.option_history_quote("SPY", "20241220", "500", "C", "20240315", "60000")const quotes = tdx.optionHistoryQuote('SPY', '20241220', '500', 'C', '20240315', '60000');auto quotes = client.option_history_quote("SPY", "20241220", "500", "C", "20240315", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
date | string | Yes | Date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: List of QuoteTick.
Tier: Standard+
option_history_trade_quote
Combined trade + quote ticks for an option contract.
let tq = tdx.option_history_trade_quote("SPY", "20241220", "500", "C", "20240315").await?;tq = tdx.option_history_trade_quote("SPY", "20241220", "500", "C", "20240315")const tq = tdx.optionHistoryTradeQuote('SPY', '20241220', '500', 'C', '20240315');auto tq = client.option_history_trade_quote("SPY", "20241220", "500", "C", "20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
date | string | Yes | Date (YYYYMMDD) |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
exclusive | bool | No | Exclusive time bounds |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: TradeQuoteTick data.
Tier: Pro
option_history_open_interest
Open interest history for an option contract.
let oi = tdx.option_history_open_interest("SPY", "20241220", "500", "C", "20240315").await?;oi = tdx.option_history_open_interest("SPY", "20241220", "500", "C", "20240315")const oi = tdx.optionHistoryOpenInterest('SPY', '20241220', '500', 'C', '20240315');auto oi = client.option_history_open_interest("SPY", "20241220", "500", "C", "20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
date | string | Yes | Date (YYYYMMDD) |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: Array of OpenInterestTick records with ms_of_day, open_interest, date.
option_history_greeks_eod
End-of-day Greeks history for an option contract.
let g = tdx.option_history_greeks_eod(
"SPY", "20241220", "500", "C", "20240101", "20240301"
).await?;g = tdx.option_history_greeks_eod("SPY", "20241220", "500", "C", "20240101", "20240301")const g = tdx.optionHistoryGreeksEod('SPY', '20241220', '500', 'C', '20240101', '20240301');auto g = client.option_history_greeks_eod("SPY", "20241220", "500", "C", "20240101", "20240301");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
annual_dividend | float | No | Override annual dividend |
rate_type | string | No | Interest rate type |
rate_value | float | No | Override interest rate value |
version | string | No | Greeks calculation version |
underlyer_use_nbbo | bool | No | Use NBBO for underlying price |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: Array of GreeksTick records with EOD Greeks per date.
Tier: Pro
option_history_greeks_all
All Greeks history at a given interval (intraday).
let g = tdx.option_history_greeks_all(
"SPY", "20241220", "500", "C", "20240315", "60000"
).await?;g = tdx.option_history_greeks_all("SPY", "20241220", "500", "C", "20240315", "60000")const g = tdx.optionHistoryGreeksAll('SPY', '20241220', '500', 'C', '20240315', '60000');auto g = client.option_history_greeks_all("SPY", "20241220", "500", "C", "20240315", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
date | string | Yes | Date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. |
annual_dividend | float | No | Override annual dividend |
rate_type | string | No | Interest rate type |
rate_value | float | No | Override interest rate value |
version | string | No | Greeks calculation version |
strike_range | int | No | Strike range filter |
Returns: Array of GreeksTick records with all 23 Greeks at each sampled point.
Tier: Pro
option_history_trade_greeks_all
All Greeks computed on each individual trade.
let g = tdx.option_history_trade_greeks_all("SPY", "20241220", "500", "C", "20240315").await?;g = tdx.option_history_trade_greeks_all("SPY", "20241220", "500", "C", "20240315")const g = tdx.optionHistoryTradeGreeksAll('SPY', '20241220', '500', 'C', '20240315');auto g = client.option_history_trade_greeks_all("SPY", "20241220", "500", "C", "20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
date | string | Yes | Date (YYYYMMDD) |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
annual_dividend | float | No | Override annual dividend |
rate_type | string | No | Interest rate type |
rate_value | float | No | Override interest rate value |
version | string | No | Greeks calculation version |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: Array of GreeksTick records with all 23 Greeks per trade.
Tier: Pro
option_history_greeks_first_order
First-order Greeks history at a given interval.
let g = tdx.option_history_greeks_first_order(
"SPY", "20241220", "500", "C", "20240315", "60000"
).await?;g = tdx.option_history_greeks_first_order("SPY", "20241220", "500", "C", "20240315", "60000")const g = tdx.optionHistoryGreeksFirstOrder('SPY', '20241220', '500', 'C', '20240315', '60000');auto g = client.option_history_greeks_first_order("SPY", "20241220", "500", "C", "20240315", "60000");Parameters are identical to option_history_greeks_all.
Returns: Array of GreeksTick records with first-order Greeks at each sampled point.
Tier: Pro
option_history_trade_greeks_first_order
First-order Greeks computed on each individual trade.
let g = tdx.option_history_trade_greeks_first_order(
"SPY", "20241220", "500", "C", "20240315"
).await?;g = tdx.option_history_trade_greeks_first_order("SPY", "20241220", "500", "C", "20240315")const g = tdx.optionHistoryTradeGreeksFirstOrder('SPY', '20241220', '500', 'C', '20240315');auto g = client.option_history_trade_greeks_first_order("SPY", "20241220", "500", "C", "20240315");Parameters are identical to option_history_trade_greeks_all.
Returns: Array of GreeksTick records with first-order Greeks per trade.
Tier: Pro
option_history_greeks_second_order
Second-order Greeks history at a given interval.
let g = tdx.option_history_greeks_second_order(
"SPY", "20241220", "500", "C", "20240315", "60000"
).await?;g = tdx.option_history_greeks_second_order("SPY", "20241220", "500", "C", "20240315", "60000")const g = tdx.optionHistoryGreeksSecondOrder('SPY', '20241220', '500', 'C', '20240315', '60000');auto g = client.option_history_greeks_second_order("SPY", "20241220", "500", "C", "20240315", "60000");Parameters are identical to option_history_greeks_all.
Returns: Array of GreeksTick records with second-order Greeks at each sampled point.
Tier: Pro
option_history_trade_greeks_second_order
Second-order Greeks computed on each individual trade.
let g = tdx.option_history_trade_greeks_second_order(
"SPY", "20241220", "500", "C", "20240315"
).await?;g = tdx.option_history_trade_greeks_second_order("SPY", "20241220", "500", "C", "20240315")const g = tdx.optionHistoryTradeGreeksSecondOrder('SPY', '20241220', '500', 'C', '20240315');auto g = client.option_history_trade_greeks_second_order("SPY", "20241220", "500", "C", "20240315");Parameters are identical to option_history_trade_greeks_all.
Returns: Array of GreeksTick records with second-order Greeks per trade.
Tier: Pro
option_history_greeks_third_order
Third-order Greeks history at a given interval.
let g = tdx.option_history_greeks_third_order(
"SPY", "20241220", "500", "C", "20240315", "60000"
).await?;g = tdx.option_history_greeks_third_order("SPY", "20241220", "500", "C", "20240315", "60000")const g = tdx.optionHistoryGreeksThirdOrder('SPY', '20241220', '500', 'C', '20240315', '60000');auto g = client.option_history_greeks_third_order("SPY", "20241220", "500", "C", "20240315", "60000");Parameters are identical to option_history_greeks_all.
Returns: Array of GreeksTick records with third-order Greeks at each sampled point.
Tier: Pro
option_history_trade_greeks_third_order
Third-order Greeks computed on each individual trade.
let g = tdx.option_history_trade_greeks_third_order(
"SPY", "20241220", "500", "C", "20240315"
).await?;g = tdx.option_history_trade_greeks_third_order("SPY", "20241220", "500", "C", "20240315")const g = tdx.optionHistoryTradeGreeksThirdOrder('SPY', '20241220', '500', 'C', '20240315');auto g = client.option_history_trade_greeks_third_order("SPY", "20241220", "500", "C", "20240315");Parameters are identical to option_history_trade_greeks_all.
Returns: Array of GreeksTick records with third-order Greeks per trade.
Tier: Pro
option_history_greeks_implied_volatility
Implied volatility history at a given interval.
let iv = tdx.option_history_greeks_implied_volatility(
"SPY", "20241220", "500", "C", "20240315", "60000"
).await?;iv = tdx.option_history_greeks_implied_volatility("SPY", "20241220", "500", "C", "20240315", "60000")const iv = tdx.optionHistoryGreeksImpliedVolatility('SPY', '20241220', '500', 'C', '20240315', '60000');auto iv = client.option_history_greeks_implied_volatility("SPY", "20241220", "500", "C", "20240315", "60000");Parameters are identical to option_history_greeks_all.
Returns: Array of IvTick records with implied volatility at each sampled point.
Tier: Pro
option_history_trade_greeks_implied_volatility
Implied volatility computed on each individual trade.
let iv = tdx.option_history_trade_greeks_implied_volatility(
"SPY", "20241220", "500", "C", "20240315"
).await?;iv = tdx.option_history_trade_greeks_implied_volatility("SPY", "20241220", "500", "C", "20240315")const iv = tdx.optionHistoryTradeGreeksImpliedVolatility('SPY', '20241220', '500', 'C', '20240315');auto iv = client.option_history_trade_greeks_implied_volatility("SPY", "20241220", "500", "C", "20240315");Parameters are identical to option_history_trade_greeks_all.
Returns: Array of IvTick records with IV per trade.
Tier: Pro
option_at_time_trade
Trade at a specific time of day across a date range for an option contract.
let trades = tdx.option_at_time_trade(
"SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000"
).await?;trades = tdx.option_at_time_trade("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000")const trades = tdx.optionAtTimeTrade('SPY', '20241220', '500', 'C', '20240101', '20240301', '09:30:00.000');auto trades = client.option_at_time_trade("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
time_of_day | string | Yes | ET wall-clock time in HH:MM:SS.SSS |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: List of TradeTick, one per date.
option_at_time_quote
Quote at a specific time of day across a date range for an option contract.
let quotes = tdx.option_at_time_quote(
"SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000"
).await?;quotes = tdx.option_at_time_quote("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000")const quotes = tdx.optionAtTimeQuote('SPY', '20241220', '500', 'C', '20240101', '20240301', '09:30:00.000');auto quotes = client.option_at_time_quote("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Underlying symbol |
expiration | string | Yes | Expiration date |
strike | string | Yes | Strike price in dollars as a string |
right | string | Yes | "C" or "P" |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
time_of_day | string | Yes | ET wall-clock time in HH:MM:SS.SSS |
max_dte | int | No | Maximum days to expiration |
strike_range | int | No | Strike range filter |
Returns: List of QuoteTick, one per date.
Index Endpoints
index_list_symbols
List all available index symbols.
let symbols = tdx.index_list_symbols().await?;symbols = tdx.index_list_symbols()const symbols = tdx.indexListSymbols();auto symbols = client.index_list_symbols();Parameters: None
Returns: List of index symbol strings (e.g. "SPX", "VIX", "DJI").
index_list_dates
List available dates for an index symbol.
let dates = tdx.index_list_dates("SPX").await?;dates = tdx.index_list_dates("SPX")const dates = tdx.indexListDates('SPX');auto dates = client.index_list_dates("SPX");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Index symbol |
Returns: List of date strings (YYYYMMDD).
index_snapshot_ohlc
Latest OHLC snapshot for one or more indices.
let bars = tdx.index_snapshot_ohlc(&["SPX", "VIX"]).await?;bars = tdx.index_snapshot_ohlc(["SPX", "VIX"])const bars = tdx.indexSnapshotOhlc(['SPX', 'VIX']);auto bars = client.index_snapshot_ohlc({"SPX", "VIX"});| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | Yes | One or more index symbols |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: List of OhlcTick.
index_snapshot_price
Latest price snapshot for one or more indices.
let prices = tdx.index_snapshot_price(&["SPX"]).await?;prices = tdx.index_snapshot_price(["SPX"])const prices = tdx.indexSnapshotPrice(['SPX']);auto prices = client.index_snapshot_price({"SPX"});| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | Yes | One or more index symbols |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: Array of PriceTick records with ms_of_day, price, date.
index_snapshot_market_value
Latest market value snapshot for one or more indices.
let mv = tdx.index_snapshot_market_value(&["SPX"]).await?;mv = tdx.index_snapshot_market_value(["SPX"])const mv = tdx.indexSnapshotMarketValue(['SPX']);auto mv = client.index_snapshot_market_value({"SPX"});| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | Yes | One or more index symbols |
min_time | string | No | Minimum time of day (ms from midnight) |
Returns: Array of MarketValueTick records with market cap, shares outstanding, enterprise value, book value, free float.
index_history_eod
End-of-day index data across a date range.
let eod = tdx.index_history_eod("SPX", "20240101", "20240301").await?;eod = tdx.index_history_eod("SPX", "20240101", "20240301")const eod = tdx.indexHistoryEOD('SPX', '20240101', '20240301');auto eod = client.index_history_eod("SPX", "20240101", "20240301");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Index symbol |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
Returns: List of EodTick.
index_history_ohlc
Intraday OHLC bars for an index across a date range.
let bars = tdx.index_history_ohlc("SPX", "20240101", "20240301", "60000").await?;bars = tdx.index_history_ohlc("SPX", "20240101", "20240301", "60000")const bars = tdx.indexHistoryOHLC('SPX', '20240101', '20240301', '60000');auto bars = client.index_history_ohlc("SPX", "20240101", "20240301", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Index symbol |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
Returns: List of OhlcTick.
index_history_price
Intraday price history for an index.
let prices = tdx.index_history_price("SPX", "20240315", "60000").await?;prices = tdx.index_history_price("SPX", "20240315", "60000")const prices = tdx.indexHistoryPrice('SPX', '20240315', '60000');auto prices = client.index_history_price("SPX", "20240315", "60000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Index symbol |
date | string | Yes | Date (YYYYMMDD) |
interval | string | Yes | Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h. |
start_time | string | No | Start time (ms from midnight) |
end_time | string | No | End time (ms from midnight) |
Returns: Array of PriceTick records with price at each sampled point.
index_at_time_price
Index price at a specific time of day across a date range.
let prices = tdx.index_at_time_price("SPX", "20240101", "20240301", "09:30:00.000").await?;prices = tdx.index_at_time_price("SPX", "20240101", "20240301", "09:30:00.000")const prices = tdx.indexAtTimePrice('SPX', '20240101', '20240301', '09:30:00.000');auto prices = client.index_at_time_price("SPX", "20240101", "20240301", "09:30:00.000");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Index symbol |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
time_of_day | string | Yes | ET wall-clock time in HH:MM:SS.SSS |
Returns: Array of PriceTick records with one price per date.
Calendar Endpoints
calendar_open_today
Check whether the market is open today.
let info = tdx.calendar_open_today().await?;info = tdx.calendar_open_today()const info = tdx.calendarOpenToday();auto info = client.calendar_open_today();Parameters: None
Returns: Array of CalendarDay records with is_open, open_time, close_time.
calendar_on_date
Calendar information for a specific date.
let info = tdx.calendar_on_date("20240315").await?;info = tdx.calendar_on_date("20240315")const info = tdx.calendarOnDate('20240315');auto info = client.calendar_on_date("20240315");| Parameter | Type | Required | Description |
|---|---|---|---|
date | string | Yes | Date (YYYYMMDD) |
Returns: Array of CalendarDay records with calendar info for the date.
calendar_year
Calendar information for an entire year.
let cal = tdx.calendar_year("2024").await?;cal = tdx.calendar_year("2024")const cal = tdx.calendarYear('2024');auto cal = client.calendar_year("2024");| Parameter | Type | Required | Description |
|---|---|---|---|
year | string | Yes | 4-digit year (e.g. "2024") |
Returns: Array of CalendarDay records with calendar info for every trading day.
Interest Rate Endpoints
interest_rate_history_eod
End-of-day interest rate history.
let rates = tdx.interest_rate_history_eod("SOFR", "20240101", "20240301").await?;rates = tdx.interest_rate_history_eod("SOFR", "20240101", "20240301")const rates = tdx.interestRateHistoryEOD('SOFR', '20240101', '20240301');auto rates = client.interest_rate_history_eod("SOFR", "20240101", "20240301");| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Rate symbol (e.g. "SOFR") |
start_date | string | Yes | Start date (YYYYMMDD) |
end_date | string | Yes | End date (YYYYMMDD) |
Returns: Array of InterestRateTick records with rate per date.
Greeks Calculator
Full Black-Scholes calculator with 20 individual Greek functions, an IV solver, and a combined all_greeks function. Computed locally - no server round-trip.
all_greeks
Compute all 23 Greeks at once. Solves for IV first, then computes all Greeks using the solved volatility. This is much more efficient than calling individual functions because it avoids redundant d1/d2/exp()/norm_cdf() recomputation.
use thetadatadx::all_greeks;
let g = all_greeks(
450.0, // spot
455.0, // strike
0.05, // risk-free rate
0.015, // dividend yield
30.0 / 365.0, // time to expiration (years)
8.50, // market price of option
"C", // right ("C"/"P" or "call"/"put", case-insensitive)
);
println!("IV: {:.4}, Delta: {:.4}", g.iv, g.delta);from thetadatadx import all_greeks
g = all_greeks(450.0, 455.0, 0.05, 0.015, 30.0 / 365.0, 8.50, "C")
print(f"IV: {g['iv']:.4f}, Delta: {g['delta']:.4f}")g = all_greeks(450.0, 455.0, 0.05, 0.015, 30.0 / 365.0, 8.50, 'C')auto g = tdx::all_greeks(450.0, 455.0, 0.05, 0.015, 30.0 / 365.0, 8.50, "C");
std::cout << "IV: " << g.iv << ", Delta: " << g.delta << std::endl;| Parameter | Type | Required | Description |
|---|---|---|---|
spot | float | Yes | Underlying (spot) price |
strike | float | Yes | Strike price |
rate | float | Yes | Risk-free interest rate (annualized) |
div_yield | float | Yes | Continuous dividend yield (annualized) |
tte | float | Yes | Time to expiration in years |
option_price | float | Yes | Market price of the option |
right | string | Yes | Option side: "C"/"P" or "call"/"put" (case-insensitive) |
Returns: GreeksResult containing all 23 fields.
implied_volatility
Solve for implied volatility using bisection (up to 128 iterations).
use thetadatadx::implied_volatility;
let (iv, err) = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, "C");from thetadatadx import implied_volatility
iv, err = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, "C")iv, err = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, 'C')auto [iv, err] = tdx::implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, "C");| Parameter | Type | Required | Description |
|---|---|---|---|
spot | float | Yes | Underlying price |
strike | float | Yes | Strike price |
rate | float | Yes | Risk-free interest rate |
div_yield | float | Yes | Dividend yield |
tte | float | Yes | Time to expiration in years |
option_price | float | Yes | Market price of the option |
right | string | Yes | Option side: "C"/"P" or "call"/"put" (case-insensitive) |
Returns: Tuple of (iv, error) where error is the relative difference (theoretical - market) / market.
Individual Greek Functions
All individual functions share these parameters. Not all functions take is_call - symmetric Greeks omit it.
| Parameter | Type | Description |
|---|---|---|
s | float | Spot price |
x | float | Strike price |
v | float | Volatility (sigma) |
r | float | Risk-free rate |
q | float | Dividend yield |
t | float | Time to expiration (years) |
is_call | bool | Call (true) or put (false) - only for directional Greeks |
First-Order Greeks
| Function | Signature | Description |
|---|---|---|
value | (s, x, v, r, q, t, is_call) -> f64 | Black-Scholes theoretical option value |
delta | (s, x, v, r, q, t, is_call) -> f64 | Rate of change of value w.r.t. spot price |
theta | (s, x, v, r, q, t, is_call) -> f64 | Time decay (daily, divided by 365) |
vega | (s, x, v, r, q, t) -> f64 | Sensitivity to volatility |
rho | (s, x, v, r, q, t, is_call) -> f64 | Sensitivity to interest rate |
epsilon | (s, x, v, r, q, t, is_call) -> f64 | Sensitivity to dividend yield |
lambda | (s, x, v, r, q, t, is_call) -> f64 | Leverage ratio (elasticity) |
Second-Order Greeks
| Function | Signature | Description |
|---|---|---|
gamma | (s, x, v, r, q, t) -> f64 | Rate of change of delta w.r.t. spot |
vanna | (s, x, v, r, q, t) -> f64 | Cross-sensitivity of delta to volatility |
charm | (s, x, v, r, q, t, is_call) -> f64 | Rate of change of delta w.r.t. time (delta decay) |
vomma | (s, x, v, r, q, t) -> f64 | Rate of change of vega w.r.t. volatility |
veta | (s, x, v, r, q, t) -> f64 | Rate of change of vega w.r.t. time |
Third-Order Greeks
| Function | Signature | Description |
|---|---|---|
speed | (s, x, v, r, q, t) -> f64 | Rate of change of gamma w.r.t. spot |
zomma | (s, x, v, r, q, t) -> f64 | Rate of change of gamma w.r.t. volatility |
color | (s, x, v, r, q, t) -> f64 | Rate of change of gamma w.r.t. time |
ultima | (s, x, v, r, q, t) -> f64 | Rate of change of vomma w.r.t. volatility (clamped to [-100, 100]) |
Auxiliary
| Function | Signature | Description |
|---|---|---|
dual_delta | (s, x, v, r, q, t, is_call) -> f64 | Sensitivity of value w.r.t. strike |
dual_gamma | (s, x, v, r, q, t) -> f64 | Second derivative w.r.t. strike |
d1 | (s, x, v, r, q, t) -> f64 | Black-Scholes d1 term |
d2 | (s, x, v, r, q, t) -> f64 | Black-Scholes d2 term |
Streaming (FPSS)
Real-time market data streaming via FPSS (Fast Protocol Streaming Service) over TLS/TCP. The streaming connection is established lazily and managed through the main client in Rust and Python; C++ uses a dedicated FpssClient.
Starting the Stream
client.start_streaming(|event: &FpssEvent| {
match event {
FpssEvent::Data(data) => println!("{:?}", data),
FpssEvent::Control(ctrl) => println!("{:?}", ctrl),
_ => {}
}
})?;client.start_streaming(lambda event: print(event))client.startStreaming((event) => console.log(event));client.start_streaming([](const tdx::FpssEvent& event) { /* ... */ });Subscribing
Every subscription is built from a typed Contract (or SecType for full-stream variants) by calling a topic helper — quote(), trade(), open_interest(), full_trades(), full_open_interest() — and handing the resulting subscription spec to the polymorphic subscribe() method on the unified client. The same shape works across every binding.
let req_id = client.subscribe(Contract::stock("AAPL").quote())?;
let req_id = client.subscribe(Contract::stock("AAPL").trade())?;
let req_id = client.subscribe(Contract::stock("AAPL").open_interest())?;
let req_id = client.subscribe(SecType::Stock.full_trades())?;client.subscribe(Contract.stock("AAPL").quote())
client.subscribe(Contract.stock("AAPL").trade())client.subscribe(Contract.stock('AAPL').quote());
client.subscribe(Contract.stock('AAPL').trade());int req_id = client.subscribe(tdx::Contract::stock("AAPL").quote());
int req_id = client.subscribe(tdx::Contract::stock("AAPL").trade());
int req_id = client.subscribe(tdx::Contract::stock("AAPL").open_interest());
int req_id = client.subscribe(tdx::SecType::Stock.full_trades());| Topic helper | Description |
|---|---|
contract.quote() | Real-time NBBO quote updates for the contract |
contract.trade() | Real-time trade prints for the contract |
contract.open_interest() | Open-interest updates for the contract |
sec_type.full_trades() | Every trade for a security type (full firehose) |
sec_type.full_open_interest() | Every open-interest update for a security type |
All subscribe() calls return a request ID. The server confirms via a ReqResponse control event. To unsubscribe, pass the same spec to unsubscribe().
Unsubscribing
client.unsubscribe(Contract::stock("AAPL").quote())?;
client.unsubscribe(Contract::stock("AAPL").trade())?;
client.unsubscribe(Contract::stock("AAPL").open_interest())?;client.unsubscribe(Contract.stock("AAPL").quote())client.unsubscribe(Contract.stock('AAPL').quote());client.unsubscribe(tdx::Contract::stock("AAPL").quote());
client.unsubscribe(tdx::Contract::stock("AAPL").trade());
client.unsubscribe(tdx::Contract::stock("AAPL").open_interest());Receiving Events
The unified client surfaces two equivalent delivery modes that share the same typed FpssEvent shape: a push-callback path (start_streaming(callback)) for low-latency dispatch into user code, and a pull-iter path (start_streaming_iter() in Rust/Python/C++, startStreamingIter() in TypeScript) for the iterator idiom. Pick one per session — the modes are mutually exclusive on the client.
// Push: callback-driven dispatch.
client.start_streaming(|event| {
if let FpssEvent::Data(FpssData::Trade { contract, price, size, .. }) = event {
// The typed `Arc<Contract>` field carries `symbol`, `sec_type`,
// `expiration`, etc. directly — no side-table lookup.
println!("Trade: symbol={}, price={}, size={}", contract.symbol, price, size);
}
})?;
// OR pull: typed iterator.
let iter = client.start_streaming_iter()?;
for event in iter {
println!("{event:?}");
}# Push:
client.start_streaming(lambda event: print(event))
# OR pull (context-managed):
with client.streaming_iter() as it:
for event in it:
print(event)// Push:
client.startStreaming((event) => console.log(event));
// OR pull (async iterable):
const iter = client.startStreamingIter();
for await (const event of iter) {
console.log(event);
}// Push:
client.start_streaming([](const tdx::FpssEvent& event) { /* ... */ });
// OR pull:
auto iter = client.start_streaming_iter();
while (auto event = iter.next(std::chrono::milliseconds(5000))) {
/* ... */
}Shutting Down
tdx.stop_streaming();tdx.stop_streaming()tdx.stopStreaming();fpss.shutdown();Streaming State
| Method | Returns | SDK availability | Description |
|---|---|---|---|
is_streaming | bool | Rust/Python only | Check if the unified streaming connection is live |
active_subscriptions | list/typed structs | All SDKs | Get list of active subscriptions |
subscribe(spec) / unsubscribe(spec) | void / result | All SDKs | Polymorphic subscribe / unsubscribe — spec is a typed Subscription built via Contract::stock("AAPL").quote() / Contract::option(...).trade() / SecType::Stock.full_trades() / etc. |
reconnect | void / result | All SDKs | Reconnect streaming and re-subscribe the previous subscription set |
FpssEvent Types
Events are delivered as one of three categories:
FpssData - Market data events (all variants include received_at_ns: u64 wall-clock timestamp):
Quote- NBBO quote update (bid, ask, sizes, exchanges, conditions)Trade- Trade execution (price, size, exchange, conditions)OpenInterest- Open interest updateOhlcvc- Aggregated OHLCVC bar (derived from trades via internal accumulator;volume/countarei64to avoid overflow on high-volume symbols)
FpssControl - Lifecycle events:
LoginSuccess- Authentication successful (includes permissions string)ContractAssigned- Server assigned an ID to a contractReqResponse- Server confirmed a subscription requestMarketOpen/MarketClose- Market state transitionsServerError/Error- Error conditionsDisconnected- Connection lost (includes reason code)
UnknownFrame - Unrecognised wire-frame fallback. Surfaced as the FpssControl::UnknownFrame { code, payload } typed control variant; carries the raw frame code and undecoded payload bytes.
On the C++ binding the pull-iter client.start_streaming_iter().next(timeout) returns std::optional<TdxFpssEvent>; the historical tdx::FpssEventPtr (std::unique_ptr<TdxFpssEvent, FpssEventDeleter>) alias remains for legacy code paths but is not the recommended entry point in v9.1.0.
Reconnection
The reconnect_delay function returns the appropriate wait time based on the disconnect reason:
- Returns
None(no reconnect) for permanent errors: invalid credentials, account already connected, free account - Returns
130,000 msfor rate limiting (TooManyRequests) - Returns
2,000 msfor all other transient errors
Streaming Endpoint Variants
Streaming variants (*_stream) use per-chunk callbacks and are available in the Rust SDK only. Other languages use the non-streaming equivalents which return complete result sets.
stock_history_trade_stream
tdx.stock_history_trade_stream("AAPL", "20240315")
.stream(|trades: &[TradeTick]| {
for t in trades {
println!("{}: {}", t.date, t.price);
}
}).await?;stock_history_quote_stream
tdx.stock_history_quote_stream("AAPL", "20240315", "0")
.stream(|quotes: &[QuoteTick]| {
println!("Chunk: {} quotes", quotes.len());
}).await?;option_history_trade_stream
tdx.option_history_trade_stream("SPY", "20241220", "500", "C", "20240315")
.stream(|trades: &[TradeTick]| {
println!("Chunk: {} trades", trades.len());
}).await?;option_history_quote_stream
tdx.option_history_quote_stream("SPY", "20241220", "500", "C", "20240315", "0")
.stream(|quotes: &[QuoteTick]| {
println!("Chunk: {} quotes", quotes.len());
}).await?;Types and Enums
Contract Identification Fields
10 tick types carry contract identification fields populated by the server on wildcard queries (pass 0 for expiration/strike). On single-contract queries these fields are 0/empty.
| Field | Type (Rust/FFI) | Description |
|---|---|---|
expiration | i32 | Contract expiration (YYYYMMDD). 0 if absent. |
strike | f64 | Strike price (decoded to f64). |
right | i32 | Contract right. 67=Call ('C'), 80=Put ('P'). |
Helper methods (all 10 types): is_call(), is_put(), has_contract_id().
Types with contract ID: TradeTick, QuoteTick, OhlcTick, EodTick, OpenInterestTick, TradeQuoteTick, MarketValueTick, GreeksTick, IvTick.
TradeTick
A single trade execution.
| Field | Type | Description |
|---|---|---|
ms_of_day | i32 | Milliseconds since midnight ET |
sequence | i32 | Sequence number |
ext_condition1 through ext_condition4 | i32 | Extended trade condition codes |
condition | i32 | Trade condition code |
size | i32 | Trade size (shares/contracts) |
exchange | i32 | Exchange code |
price | f64 | Trade price (decoded) |
condition_flags | i32 | Condition flags bitmap |
price_flags | i32 | Price flags bitmap |
volume_type | i32 | 0 = incremental, 1 = cumulative |
records_back | i32 | Records back count |
date | i32 | Date as YYYYMMDD integer |
expiration | i32 | Contract expiration (wildcard queries) |
strike | f64 | Contract strike (wildcard queries) |
right | i32 | Contract right. C=67/P=80. |
Helper methods: is_cancelled(), trade_condition_no_last(), price_condition_set_last(), regular_trading_hours(), is_seller(), is_incremental_volume(), is_call(), is_put(), has_contract_id()
QuoteTick
An NBBO quote.
| Field | Type | Description |
|---|---|---|
ms_of_day | i32 | Milliseconds since midnight ET |
bid_size / ask_size | i32 | Quote sizes |
bid_exchange / ask_exchange | i32 | Exchange codes |
bid / ask | f64 | Bid and ask prices (decoded) |
bid_condition / ask_condition | i32 | Condition codes |
midpoint | f64 | Pre-computed (bid + ask) / 2.0 |
date | i32 | Date as YYYYMMDD integer |
expiration / strike / right | i32/f64/i32 | Contract ID (wildcard queries) |
Helper methods: is_call(), is_put(), has_contract_id(), plus contract ID helpers
OhlcTick
An aggregated OHLC bar.
| Field | Type | Description |
|---|---|---|
ms_of_day | i32 | Bar start time (ms from midnight ET) |
open / high / low / close | f64 | OHLC prices (decoded) |
volume | i64 | Total volume in bar |
count | i64 | Number of trades in bar |
date | i32 | Date as YYYYMMDD integer |
expiration / strike / right | i32/f64/i32 | Contract ID (wildcard queries) |
Helper methods: is_call(), is_put(), has_contract_id(), plus contract ID helpers
EodTick
Full end-of-day snapshot with OHLC + closing quote data.
| Field | Type | Description |
|---|---|---|
ms_of_day / ms_of_day2 | i32 | Timestamps |
open / high / low / close | f64 | OHLC prices (decoded) |
volume | i64 | Total daily volume |
count | i64 | Total trade count |
bid_size / ask_size | i32 | Closing quote sizes |
bid_exchange / ask_exchange | i32 | Closing quote exchanges |
bid / ask | f64 | Closing bid/ask (decoded) |
bid_condition / ask_condition | i32 | Closing quote conditions |
date | i32 | Date as YYYYMMDD |
expiration / strike / right | i32/f64/i32 | Contract ID (wildcard queries) |
Helper methods: is_call(), is_put(), has_contract_id(), plus contract ID helpers
TradeQuoteTick
Combined trade + quote tick. Contains the full trade data plus the prevailing NBBO quote at the time of the trade.
Helper methods: is_call(), is_put(), has_contract_id(), plus contract ID helpers
OpenInterestTick
| Field | Type | Description |
|---|---|---|
ms_of_day | i32 | Milliseconds since midnight ET |
open_interest | i32 | Open interest count |
date | i32 | Date as YYYYMMDD |
expiration / strike / right | i32/f64/i32 | Contract ID (wildcard queries) |
GreeksResult
Result of all_greeks(). All fields are f64.
| Field | Order | Description |
|---|---|---|
value | - | Black-Scholes theoretical value |
iv | - | Implied volatility |
iv_error | - | IV solver error (relative) |
delta | 1st | dV/dS |
theta | 1st | dV/dt (daily) |
vega | 1st | dV/dv |
rho | 1st | dV/dr |
epsilon | 1st | dV/dq (dividend sensitivity) |
lambda | 1st | Elasticity (leverage ratio) |
gamma | 2nd | d2V/dS2 |
vanna | 2nd | d2V/dSdv |
charm | 2nd | d2V/dSdt (delta decay) |
vomma | 2nd | d2V/dv2 |
veta | 2nd | d2V/dvdt |
speed | 3rd | d3V/dS3 |
zomma | 3rd | d3V/dS2dv |
color | 3rd | d3V/dS2dt |
ultima | 3rd | d3V/dv3 |
d1 | Internal | Black-Scholes d1 |
d2 | Internal | Black-Scholes d2 |
dual_delta | Aux | dV/dX |
dual_gamma | Aux | d2V/dX2 |
Price
All public tick fields are f64, decoded at parse time. No price_type conversion is needed in user code.
SecType
| Variant | Code | String |
|---|---|---|
Stock | 0 | "STOCK" |
Option | 1 | "OPTION" |
Index | 2 | "INDEX" |
Rate | 3 | "RATE" |
Right
Option right: Call, Put
from_char('C')/from_char('P')- parse from characteras_char()- convert to'C'or'P'
StreamResponseType
Subscription response codes returned in ReqResponse control events.
| Variant | Code | Meaning |
|---|---|---|
Subscribed | 0 | Subscription successful |
Error | 1 | General error |
MaxStreamsReached | 2 | Subscription limit reached for your tier |
InvalidPerms | 3 | Insufficient permissions for this data |
Venue
Data venue for exchange filtering.
| Variant | Wire value |
|---|---|
Nqb | "NQB" |
UtpCta | "UTP_CTA" |
RateType
Interest rate types for server-side Greeks calculations.
Variants: Sofr, TreasuryM1, TreasuryM3, TreasuryM6, TreasuryY1, TreasuryY2, TreasuryY3, TreasuryY5, TreasuryY7, TreasuryY10, TreasuryY20, TreasuryY30
Contract
Identifies a security for streaming subscriptions.
Contract::stock("AAPL")
Contract::index("SPX")
Contract::rate("SOFR")
Contract::option("SPY", "20261218", "60", "C")? // Result<Contract, Error># Build a typed Contract and call a topic helper to drive subscribe().
client.subscribe(Contract.stock("AAPL").quote())// Build a typed Contract and call a topic helper to drive subscribe().
client.subscribe(Contract.stock('AAPL').quote());// Build a typed Contract and call a topic helper to drive subscribe().
client.subscribe(tdx::Contract::stock("AAPL").quote());| Field | Type | Description |
|---|---|---|
symbol | string | Ticker symbol |
sec_type | SecType | Security type |
expiration | int (optional) | Expiration date as YYYYMMDD (options only) |
is_call | bool (optional) | true = call, false = put (options only) |
strike | string (optional) | Strike price in dollars (options only) |
Credentials
Credentials::from_file("creds.txt")?; // line 1 = email, line 2 = password
Credentials::new("user@example.com", "password");
Credentials::parse("user@example.com\npassword")?;Credentials.from_file("creds.txt")
Credentials("user@example.com", "password")Credentials.from_file('creds.txt')
Credentials('user@example.com', 'password')auto creds = tdx::Credentials::from_file("creds.txt");
auto creds = tdx::Credentials::from_email("email@example.com", "password");Error Types
pub enum Error {
Transport(tonic::transport::Error), // gRPC channel errors
Status(Box<tonic::Status>), // gRPC status codes (enriched with ThetaData error info)
Decompress(String), // zstd decompression failure
Decode(String), // protobuf decode failure
NoData, // endpoint returned no usable data
Auth(String), // Nexus auth errors (401/404)
Fpss(String), // FPSS connection errors
FpssProtocol(String), // FPSS wire protocol errors
FpssDisconnected(String), // FPSS server rejected connection
Config(String), // configuration errors
Http(reqwest::Error), // HTTP request errors
Io(std::io::Error), // I/O errors
Tls(rustls::Error), // TLS handshake errors
}# All errors raise RuntimeError with descriptive message# All errors raise RuntimeError with descriptive message// All methods throw std::runtime_error on failurePython-Specific Features
DataFrame Support (Arrow-Backed)
Every historical endpoint returns a typed list wrapper (EodTickList, OhlcTickList, TradeTickList, QuoteTickList, StringList, ...). DataFrame conversion happens via chained terminals on the wrapper — no free functions, no client methods. The shared Rust path walks the decoder-owned Vec<Tick> directly into an arrow::RecordBatch and hands it to pyarrow.Table via the Arrow C Data Interface (zero-copy at the pyo3 boundary); pandas / polars / raw Arrow are the three terminal consumers. At 100k x 20 ticks the wall-clock is ~8ms.
Unified recipe for every historical endpoint:
df = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_pandas()
df = tdx.stock_history_ohlc("AAPL", "20240315", "60000").to_pandas()
df = tdx.stock_history_trade("AAPL", "20240315").to_pandas()
df = tdx.stock_history_quote("AAPL", "20240315", "60000").to_pandas()Historical / list-returning endpoints wrap their result in a typed <TickName>List (e.g. EodTickList, QuoteTickList); chain .to_pandas() / .to_polars() / .to_arrow() / .to_list() on that wrapper. One path, one schema, one generator (tick_schema.toml). Requires pip install thetadatadx[pandas] / [polars] / [arrow] for the matching terminal.
Snapshot-kind endpoints (*_snapshot_*) and calendar endpoints take the fast path and return a plain list[TickClass] rather than a list wrapper, so the chainable DataFrame terminals are not available on those return values. Build a DataFrame from the raw list directly if needed (e.g. pandas.DataFrame([vars(t) for t in rows])).
<TickName>List.to_pandas() -> pandas.DataFrame
Generic pandas terminal. Pandas 2.x aliases the underlying Arrow buffers in place for all numeric columns, so large result sets materialize at near-zero-copy cost:
df = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_pandas()Requires pip install thetadatadx[pandas].
<TickName>List.to_polars() -> polars.DataFrame
Same Arrow batch, routed through polars.from_arrow:
df = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_polars()Requires pip install thetadatadx[polars].
<TickName>List.to_arrow() -> pyarrow.Table
The intermediate pyarrow.Table surfaced directly -- ideal for DuckDB / Arrow-Flight / cuDF / polars-arrow pipelines that want to consume Arrow without a pandas or polars roundtrip:
import duckdb
table = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_arrow()
con = duckdb.connect()
con.register("eod", table) # DuckDB reads the same buffers
con.sql("SELECT AVG(close) FROM eod").show()Requires pip install thetadatadx[arrow] (pyarrow only; no pandas/polars dep).
<TickName>List.to_list() -> list[TickClass]
Return the wrapped rows as a plain Python list[TickClass] for callers that need a mutable container or a sequence API that insists on list rather than the frozen wrapper:
rows = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_list()No extra dependency.
Empty-result behaviour
An empty query returns an empty <TickName>List; the chainable terminals still emit a typed schema. .to_arrow() on an empty list produces a pyarrow.Table with zero rows and the full column layout for that tick type, so downstream pipelines that assert a fixed schema survive empty market-hours windows without branching on len(ticks) == 0:
empty = tdx.stock_history_eod("AAPL", "20260101", "20260101")
assert len(empty) == 0
table = empty.to_arrow() # zero rows, EodTick column schema