Skip to content

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

rust
use thetadatadx::{ThetaDataDxClient, Credentials, DirectConfig};

let creds = Credentials::from_file("creds.txt")?;
let client = ThetaDataDxClient::connect(&creds, DirectConfig::production()).await?;
python
from thetadatadx import Credentials, Config, ThetaDataDxClient

creds = Credentials.from_file("creds.txt")
client = ThetaDataDxClient(creds, Config.production())
typescript
import { ThetaDataDxClient } from 'thetadatadx';

const client = await ThetaDataDxClient.connectFromFile('creds.txt');
cpp
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.

rust
let symbols = tdx.stock_list_symbols().await?;
python
symbols = tdx.stock_list_symbols()
typescript
const symbols = tdx.stockListSymbols();
cpp
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.

rust
let dates = tdx.stock_list_dates("TRADE", "AAPL").await?;
python
dates = tdx.stock_list_dates("TRADE", "AAPL")
typescript
const dates = tdx.stockListDates('TRADE', 'AAPL');
cpp
auto dates = client.stock_list_dates("TRADE", "AAPL");
ParameterTypeRequiredDescription
request_typestringYesData type: "TRADE", "QUOTE", "OHLC"
symbolstringYesTicker symbol

Returns: List of date strings (YYYYMMDD).


stock_snapshot_ohlc

Latest OHLC snapshot for one or more stocks.

rust
let bars = tdx.stock_snapshot_ohlc(&["AAPL", "MSFT"]).await?;
python
bars = tdx.stock_snapshot_ohlc(["AAPL", "MSFT"])
typescript
const bars = tdx.stockSnapshotOhlc(['AAPL', 'MSFT']);
cpp
auto bars = client.stock_snapshot_ohlc({"AAPL", "MSFT"});
ParameterTypeRequiredDescription
symbolsstring[]YesOne or more ticker symbols
venuestringNoData venue filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: List of OhlcTick.


stock_snapshot_trade

Latest trade snapshot for one or more stocks.

rust
let trades = tdx.stock_snapshot_trade(&["AAPL"]).await?;
python
trades = tdx.stock_snapshot_trade(["AAPL"])
typescript
const trades = tdx.stockSnapshotTrade(['AAPL']);
cpp
auto trades = client.stock_snapshot_trade({"AAPL"});
ParameterTypeRequiredDescription
symbolsstring[]YesOne or more ticker symbols
venuestringNoData venue filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: List of TradeTick.


stock_snapshot_quote

Latest NBBO quote snapshot for one or more stocks.

rust
let quotes = tdx.stock_snapshot_quote(&["AAPL"]).await?;
python
quotes = tdx.stock_snapshot_quote(["AAPL"])
typescript
const quotes = tdx.stockSnapshotQuote(['AAPL']);
cpp
auto quotes = client.stock_snapshot_quote({"AAPL"});
ParameterTypeRequiredDescription
symbolsstring[]YesOne or more ticker symbols
venuestringNoData venue filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: List of QuoteTick.


stock_snapshot_market_value

Latest market value snapshot for one or more stocks.

rust
let mv = tdx.stock_snapshot_market_value(&["AAPL"]).await?;
python
mv = tdx.stock_snapshot_market_value(["AAPL"])
typescript
const mv = tdx.stockSnapshotMarketValue(['AAPL']);
cpp
auto mv = client.stock_snapshot_market_value({"AAPL"});
ParameterTypeRequiredDescription
symbolsstring[]YesOne or more ticker symbols
venuestringNoData venue filter
min_timestringNoMinimum 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.

rust
let eod = tdx.stock_history_eod("AAPL", "20240101", "20240301").await?;
python
eod = tdx.stock_history_eod("AAPL", "20240101", "20240301")
typescript
const eod = tdx.stockHistoryEOD('AAPL', '20240101', '20240301');
cpp
auto eod = client.stock_history_eod("AAPL", "20240101", "20240301");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)

Returns: List of EodTick.


stock_history_ohlc

Intraday OHLC bars for a single date.

rust
let bars = tdx.stock_history_ohlc("AAPL", "20240315", "60000").await?;
python
bars = tdx.stock_history_ohlc("AAPL", "20240315", "60000")
typescript
const bars = tdx.stockHistoryOHLC('AAPL', '20240315', '60000');
cpp
auto bars = client.stock_history_ohlc("AAPL", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
datestringYesDate (YYYYMMDD)
intervalstringYesAccepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
venuestringNoData venue filter

Returns: List of OhlcTick.


stock_history_ohlc_range

Intraday OHLC bars across a date range.

rust
let bars = tdx.stock_history_ohlc_range("AAPL", "20240101", "20240301", "60000").await?;
python
bars = tdx.stock_history_ohlc_range("AAPL", "20240101", "20240301", "60000")
typescript
const bars = tdx.stockHistoryOHLCRange('AAPL', '20240101', '20240301', '60000');
cpp
auto bars = client.stock_history_ohlc_range("AAPL", "20240101", "20240301", "60000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
intervalstringYesAccepts 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.

rust
let trades = tdx.stock_history_trade("AAPL", "20240315").await?;
python
trades = tdx.stock_history_trade("AAPL", "20240315")
typescript
const trades = tdx.stockHistoryTrade('AAPL', '20240315');
cpp
auto trades = client.stock_history_trade("AAPL", "20240315");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
datestringYesDate (YYYYMMDD)
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
venuestringNoData venue filter

Returns: List of TradeTick.

Tier: Standard+


stock_history_quote

NBBO quotes for a stock at a given interval.

rust
let quotes = tdx.stock_history_quote("AAPL", "20240315", "60000").await?;
python
quotes = tdx.stock_history_quote("AAPL", "20240315", "60000")
typescript
const quotes = tdx.stockHistoryQuote('AAPL', '20240315', '60000');
cpp
auto quotes = client.stock_history_quote("AAPL", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
datestringYesDate (YYYYMMDD)
intervalstringYesAccepts 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_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
venuestringNoData venue filter

Returns: List of QuoteTick.

Tier: Standard+


stock_history_trade_quote

Combined trade + quote ticks for a stock on a given date.

rust
let tq = tdx.stock_history_trade_quote("AAPL", "20240315").await?;
python
tq = tdx.stock_history_trade_quote("AAPL", "20240315")
typescript
const tq = tdx.stockHistoryTradeQuote('AAPL', '20240315');
cpp
auto tq = client.stock_history_trade_quote("AAPL", "20240315");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
datestringYesDate (YYYYMMDD)
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
exclusiveboolNoExclusive time bounds
venuestringNoData 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.

rust
let trades = tdx.stock_at_time_trade("AAPL", "20240101", "20240301", "09:30:00.000").await?;
python
trades = tdx.stock_at_time_trade("AAPL", "20240101", "20240301", "09:30:00.000")
typescript
const trades = tdx.stockAtTimeTrade('AAPL', '20240101', '20240301', '09:30:00.000');
cpp
auto trades = client.stock_at_time_trade("AAPL", "20240101", "20240301", "09:30:00.000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesET wall-clock time in HH:MM:SS.SSS (e.g. "09:30:00.000"; legacy "34200000" also accepted)
venuestringNoData venue filter

Returns: List of TradeTick, one per date.


stock_at_time_quote

Quote at a specific time of day across a date range.

rust
let quotes = tdx.stock_at_time_quote("AAPL", "20240101", "20240301", "09:30:00.000").await?;
python
quotes = tdx.stock_at_time_quote("AAPL", "20240101", "20240301", "09:30:00.000")
typescript
const quotes = tdx.stockAtTimeQuote('AAPL', '20240101', '20240301', '09:30:00.000');
cpp
auto quotes = client.stock_at_time_quote("AAPL", "20240101", "20240301", "09:30:00.000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesET wall-clock time in HH:MM:SS.SSS
venuestringNoData 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 as YYYYMMDD string
  • strike - 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.

rust
let symbols = tdx.option_list_symbols().await?;
python
symbols = tdx.option_list_symbols()
typescript
const symbols = tdx.optionListSymbols();
cpp
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.

rust
let dates = tdx.option_list_dates("TRADE", "SPY", "20241220", "500", "C").await?;
python
dates = tdx.option_list_dates("TRADE", "SPY", "20241220", "500", "C")
typescript
const dates = tdx.optionListDates('TRADE', 'SPY', '20241220', '500', 'C');
cpp
auto dates = client.option_list_dates("TRADE", "SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
request_typestringYesData type: "TRADE", "QUOTE", etc.
symbolstringYesUnderlying symbol
expirationstringYesExpiration date (YYYYMMDD)
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"

Returns: List of date strings (YYYYMMDD).


option_list_expirations

List all expiration dates for an underlying.

rust
let exps = tdx.option_list_expirations("SPY").await?;
python
exps = tdx.option_list_expirations("SPY")
typescript
const exps = tdx.optionListExpirations('SPY');
cpp
auto exps = client.option_list_expirations("SPY");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol

Returns: List of expiration date strings (YYYYMMDD).


option_list_strikes

List strike prices for a given expiration.

rust
let strikes = tdx.option_list_strikes("SPY", "20241220").await?;
python
strikes = tdx.option_list_strikes("SPY", "20241220")
typescript
const strikes = tdx.optionListStrikes('SPY', '20241220');
cpp
auto strikes = client.option_list_strikes("SPY", "20241220");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date (YYYYMMDD)

Returns: List of strike price strings in dollars.


option_list_contracts

List all option contracts for a symbol on a given date.

rust
let contracts = tdx.option_list_contracts("TRADE", "SPY", "20240315").await?;
python
contracts = tdx.option_list_contracts("TRADE", "SPY", "20240315")
typescript
const contracts = tdx.optionListContracts('TRADE', 'SPY', '20240315');
cpp
auto contracts = client.option_list_contracts("TRADE", "SPY", "20240315");
ParameterTypeRequiredDescription
request_typestringYesData type
symbolstringYesUnderlying symbol
datestringYesDate (YYYYMMDD)
max_dteintNoMaximum days to expiration filter

Returns: Array of OptionContract records with symbol, expiration, strike, right.


option_snapshot_ohlc

Latest OHLC snapshot for an option contract.

rust
let bars = tdx.option_snapshot_ohlc("SPY", "20241220", "500", "C").await?;
python
bars = tdx.option_snapshot_ohlc("SPY", "20241220", "500", "C")
typescript
const bars = tdx.optionSnapshotOhlc('SPY', '20241220', '500', 'C');
cpp
auto bars = client.option_snapshot_ohlc("SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date (YYYYMMDD)
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: List of OhlcTick.


option_snapshot_trade

Latest trade snapshot for an option contract.

rust
let trades = tdx.option_snapshot_trade("SPY", "20241220", "500", "C").await?;
python
trades = tdx.option_snapshot_trade("SPY", "20241220", "500", "C")
typescript
const trades = tdx.optionSnapshotTrade('SPY', '20241220', '500', 'C');
cpp
auto trades = client.option_snapshot_trade("SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
strike_rangeintNoStrike range filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: List of TradeTick.


option_snapshot_quote

Latest NBBO quote snapshot for an option contract.

rust
let quotes = tdx.option_snapshot_quote("SPY", "20241220", "500", "C").await?;
python
quotes = tdx.option_snapshot_quote("SPY", "20241220", "500", "C")
typescript
const quotes = tdx.optionSnapshotQuote('SPY', '20241220', '500', 'C');
cpp
auto quotes = client.option_snapshot_quote("SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: List of QuoteTick.


option_snapshot_open_interest

Latest open interest snapshot for an option contract.

rust
let oi = tdx.option_snapshot_open_interest("SPY", "20241220", "500", "C").await?;
python
oi = tdx.option_snapshot_open_interest("SPY", "20241220", "500", "C")
typescript
const oi = tdx.optionSnapshotOpenInterest('SPY', '20241220', '500', 'C');
cpp
auto oi = client.option_snapshot_open_interest("SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum 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.

rust
let mv = tdx.option_snapshot_market_value("SPY", "20241220", "500", "C").await?;
python
mv = tdx.option_snapshot_market_value("SPY", "20241220", "500", "C")
typescript
const mv = tdx.optionSnapshotMarketValue('SPY', '20241220', '500', 'C');
cpp
auto mv = client.option_snapshot_market_value("SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum 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.

rust
let iv = tdx.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500", "C").await?;
python
iv = tdx.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500", "C")
typescript
const iv = tdx.optionSnapshotGreeksImpliedVolatility('SPY', '20241220', '500', 'C');
cpp
auto iv = client.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
annual_dividendfloatNoOverride annual dividend
rate_typestringNoInterest rate type (e.g. "SOFR")
rate_valuefloatNoOverride interest rate value
stock_pricefloatNoOverride underlying price
versionstringNoGreeks calculation version
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum time of day (ms from midnight)
use_market_valueboolNoUse 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.

rust
let greeks = tdx.option_snapshot_greeks_all("SPY", "20241220", "500", "C").await?;
python
greeks = tdx.option_snapshot_greeks_all("SPY", "20241220", "500", "C")
typescript
const greeks = tdx.optionSnapshotGreeksAll('SPY', '20241220', '500', 'C');
cpp
auto greeks = client.option_snapshot_greeks_all("SPY", "20241220", "500", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
annual_dividendfloatNoOverride annual dividend
rate_typestringNoInterest rate type
rate_valuefloatNoOverride interest rate value
stock_pricefloatNoOverride underlying price
versionstringNoGreeks calculation version
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum time of day
use_market_valueboolNoUse 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).

rust
let g = tdx.option_snapshot_greeks_first_order("SPY", "20241220", "500", "C").await?;
python
g = tdx.option_snapshot_greeks_first_order("SPY", "20241220", "500", "C")
typescript
const g = tdx.optionSnapshotGreeksFirstOrder('SPY', '20241220', '500', 'C');
cpp
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).

rust
let g = tdx.option_snapshot_greeks_second_order("SPY", "20241220", "500", "C").await?;
python
g = tdx.option_snapshot_greeks_second_order("SPY", "20241220", "500", "C")
typescript
const g = tdx.optionSnapshotGreeksSecondOrder('SPY', '20241220', '500', 'C');
cpp
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).

rust
let g = tdx.option_snapshot_greeks_third_order("SPY", "20241220", "500", "C").await?;
python
g = tdx.option_snapshot_greeks_third_order("SPY", "20241220", "500", "C")
typescript
const g = tdx.optionSnapshotGreeksThirdOrder('SPY', '20241220', '500', 'C');
cpp
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.

rust
let eod = tdx.option_history_eod(
    "SPY", "20241220", "500", "C", "20240101", "20240301"
).await?;
python
eod = tdx.option_history_eod("SPY", "20241220", "500", "C", "20240101", "20240301")
typescript
const eod = tdx.optionHistoryEOD('SPY', '20241220', '500', 'C', '20240101', '20240301');
cpp
auto eod = client.option_history_eod("SPY", "20241220", "500", "C", "20240101", "20240301");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter

Returns: List of EodTick.


option_history_ohlc

Intraday OHLC bars for an option contract.

rust
let bars = tdx.option_history_ohlc(
    "SPY", "20241220", "500", "C", "20240315", "60000"
).await?;
python
bars = tdx.option_history_ohlc("SPY", "20241220", "500", "C", "20240315", "60000")
typescript
const bars = tdx.optionHistoryOHLC('SPY', '20241220', '500', 'C', '20240315', '60000');
cpp
auto bars = client.option_history_ohlc("SPY", "20241220", "500", "C", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
intervalstringYesAccepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
strike_rangeintNoStrike range filter

Returns: List of OhlcTick.


option_history_trade

All trades for an option contract on a given date.

rust
let trades = tdx.option_history_trade("SPY", "20241220", "500", "C", "20240315").await?;
python
trades = tdx.option_history_trade("SPY", "20241220", "500", "C", "20240315")
typescript
const trades = tdx.optionHistoryTrade('SPY', '20241220', '500', 'C', '20240315');
cpp
auto trades = client.option_history_trade("SPY", "20241220", "500", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter

Returns: List of TradeTick.

Tier: Standard+


option_history_quote

NBBO quotes for an option contract.

rust
let quotes = tdx.option_history_quote(
    "SPY", "20241220", "500", "C", "20240315", "60000"
).await?;
python
quotes = tdx.option_history_quote("SPY", "20241220", "500", "C", "20240315", "60000")
typescript
const quotes = tdx.optionHistoryQuote('SPY', '20241220', '500', 'C', '20240315', '60000');
cpp
auto quotes = client.option_history_quote("SPY", "20241220", "500", "C", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
intervalstringYesAccepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter

Returns: List of QuoteTick.

Tier: Standard+


option_history_trade_quote

Combined trade + quote ticks for an option contract.

rust
let tq = tdx.option_history_trade_quote("SPY", "20241220", "500", "C", "20240315").await?;
python
tq = tdx.option_history_trade_quote("SPY", "20241220", "500", "C", "20240315")
typescript
const tq = tdx.optionHistoryTradeQuote('SPY', '20241220', '500', 'C', '20240315');
cpp
auto tq = client.option_history_trade_quote("SPY", "20241220", "500", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
exclusiveboolNoExclusive time bounds
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter

Returns: TradeQuoteTick data.

Tier: Pro


option_history_open_interest

Open interest history for an option contract.

rust
let oi = tdx.option_history_open_interest("SPY", "20241220", "500", "C", "20240315").await?;
python
oi = tdx.option_history_open_interest("SPY", "20241220", "500", "C", "20240315")
typescript
const oi = tdx.optionHistoryOpenInterest('SPY', '20241220', '500', 'C', '20240315');
cpp
auto oi = client.option_history_open_interest("SPY", "20241220", "500", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike 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.

rust
let g = tdx.option_history_greeks_eod(
    "SPY", "20241220", "500", "C", "20240101", "20240301"
).await?;
python
g = tdx.option_history_greeks_eod("SPY", "20241220", "500", "C", "20240101", "20240301")
typescript
const g = tdx.optionHistoryGreeksEod('SPY', '20241220', '500', 'C', '20240101', '20240301');
cpp
auto g = client.option_history_greeks_eod("SPY", "20241220", "500", "C", "20240101", "20240301");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
annual_dividendfloatNoOverride annual dividend
rate_typestringNoInterest rate type
rate_valuefloatNoOverride interest rate value
versionstringNoGreeks calculation version
underlyer_use_nbboboolNoUse NBBO for underlying price
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike 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).

rust
let g = tdx.option_history_greeks_all(
    "SPY", "20241220", "500", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_all("SPY", "20241220", "500", "C", "20240315", "60000")
typescript
const g = tdx.optionHistoryGreeksAll('SPY', '20241220', '500', 'C', '20240315', '60000');
cpp
auto g = client.option_history_greeks_all("SPY", "20241220", "500", "C", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
intervalstringYesAccepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.
annual_dividendfloatNoOverride annual dividend
rate_typestringNoInterest rate type
rate_valuefloatNoOverride interest rate value
versionstringNoGreeks calculation version
strike_rangeintNoStrike 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.

rust
let g = tdx.option_history_trade_greeks_all("SPY", "20241220", "500", "C", "20240315").await?;
python
g = tdx.option_history_trade_greeks_all("SPY", "20241220", "500", "C", "20240315")
typescript
const g = tdx.optionHistoryTradeGreeksAll('SPY', '20241220', '500', 'C', '20240315');
cpp
auto g = client.option_history_trade_greeks_all("SPY", "20241220", "500", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)
annual_dividendfloatNoOverride annual dividend
rate_typestringNoInterest rate type
rate_valuefloatNoOverride interest rate value
versionstringNoGreeks calculation version
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike 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.

rust
let g = tdx.option_history_greeks_first_order(
    "SPY", "20241220", "500", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_first_order("SPY", "20241220", "500", "C", "20240315", "60000")
typescript
const g = tdx.optionHistoryGreeksFirstOrder('SPY', '20241220', '500', 'C', '20240315', '60000');
cpp
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.

rust
let g = tdx.option_history_trade_greeks_first_order(
    "SPY", "20241220", "500", "C", "20240315"
).await?;
python
g = tdx.option_history_trade_greeks_first_order("SPY", "20241220", "500", "C", "20240315")
typescript
const g = tdx.optionHistoryTradeGreeksFirstOrder('SPY', '20241220', '500', 'C', '20240315');
cpp
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.

rust
let g = tdx.option_history_greeks_second_order(
    "SPY", "20241220", "500", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_second_order("SPY", "20241220", "500", "C", "20240315", "60000")
typescript
const g = tdx.optionHistoryGreeksSecondOrder('SPY', '20241220', '500', 'C', '20240315', '60000');
cpp
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.

rust
let g = tdx.option_history_trade_greeks_second_order(
    "SPY", "20241220", "500", "C", "20240315"
).await?;
python
g = tdx.option_history_trade_greeks_second_order("SPY", "20241220", "500", "C", "20240315")
typescript
const g = tdx.optionHistoryTradeGreeksSecondOrder('SPY', '20241220', '500', 'C', '20240315');
cpp
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.

rust
let g = tdx.option_history_greeks_third_order(
    "SPY", "20241220", "500", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_third_order("SPY", "20241220", "500", "C", "20240315", "60000")
typescript
const g = tdx.optionHistoryGreeksThirdOrder('SPY', '20241220', '500', 'C', '20240315', '60000');
cpp
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.

rust
let g = tdx.option_history_trade_greeks_third_order(
    "SPY", "20241220", "500", "C", "20240315"
).await?;
python
g = tdx.option_history_trade_greeks_third_order("SPY", "20241220", "500", "C", "20240315")
typescript
const g = tdx.optionHistoryTradeGreeksThirdOrder('SPY', '20241220', '500', 'C', '20240315');
cpp
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.

rust
let iv = tdx.option_history_greeks_implied_volatility(
    "SPY", "20241220", "500", "C", "20240315", "60000"
).await?;
python
iv = tdx.option_history_greeks_implied_volatility("SPY", "20241220", "500", "C", "20240315", "60000")
typescript
const iv = tdx.optionHistoryGreeksImpliedVolatility('SPY', '20241220', '500', 'C', '20240315', '60000');
cpp
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.

rust
let iv = tdx.option_history_trade_greeks_implied_volatility(
    "SPY", "20241220", "500", "C", "20240315"
).await?;
python
iv = tdx.option_history_trade_greeks_implied_volatility("SPY", "20241220", "500", "C", "20240315")
typescript
const iv = tdx.optionHistoryTradeGreeksImpliedVolatility('SPY', '20241220', '500', 'C', '20240315');
cpp
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.

rust
let trades = tdx.option_at_time_trade(
    "SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000"
).await?;
python
trades = tdx.option_at_time_trade("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000")
typescript
const trades = tdx.optionAtTimeTrade('SPY', '20241220', '500', 'C', '20240101', '20240301', '09:30:00.000');
cpp
auto trades = client.option_at_time_trade("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesET wall-clock time in HH:MM:SS.SSS
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike 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.

rust
let quotes = tdx.option_at_time_quote(
    "SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000"
).await?;
python
quotes = tdx.option_at_time_quote("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000")
typescript
const quotes = tdx.optionAtTimeQuote('SPY', '20241220', '500', 'C', '20240101', '20240301', '09:30:00.000');
cpp
auto quotes = client.option_at_time_quote("SPY", "20241220", "500", "C", "20240101", "20240301", "09:30:00.000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price in dollars as a string
rightstringYes"C" or "P"
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesET wall-clock time in HH:MM:SS.SSS
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter

Returns: List of QuoteTick, one per date.


Index Endpoints

index_list_symbols

List all available index symbols.

rust
let symbols = tdx.index_list_symbols().await?;
python
symbols = tdx.index_list_symbols()
typescript
const symbols = tdx.indexListSymbols();
cpp
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.

rust
let dates = tdx.index_list_dates("SPX").await?;
python
dates = tdx.index_list_dates("SPX")
typescript
const dates = tdx.indexListDates('SPX');
cpp
auto dates = client.index_list_dates("SPX");
ParameterTypeRequiredDescription
symbolstringYesIndex symbol

Returns: List of date strings (YYYYMMDD).


index_snapshot_ohlc

Latest OHLC snapshot for one or more indices.

rust
let bars = tdx.index_snapshot_ohlc(&["SPX", "VIX"]).await?;
python
bars = tdx.index_snapshot_ohlc(["SPX", "VIX"])
typescript
const bars = tdx.indexSnapshotOhlc(['SPX', 'VIX']);
cpp
auto bars = client.index_snapshot_ohlc({"SPX", "VIX"});
ParameterTypeRequiredDescription
symbolsstring[]YesOne or more index symbols
min_timestringNoMinimum time of day (ms from midnight)

Returns: List of OhlcTick.


index_snapshot_price

Latest price snapshot for one or more indices.

rust
let prices = tdx.index_snapshot_price(&["SPX"]).await?;
python
prices = tdx.index_snapshot_price(["SPX"])
typescript
const prices = tdx.indexSnapshotPrice(['SPX']);
cpp
auto prices = client.index_snapshot_price({"SPX"});
ParameterTypeRequiredDescription
symbolsstring[]YesOne or more index symbols
min_timestringNoMinimum 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.

rust
let mv = tdx.index_snapshot_market_value(&["SPX"]).await?;
python
mv = tdx.index_snapshot_market_value(["SPX"])
typescript
const mv = tdx.indexSnapshotMarketValue(['SPX']);
cpp
auto mv = client.index_snapshot_market_value({"SPX"});
ParameterTypeRequiredDescription
symbolsstring[]YesOne or more index symbols
min_timestringNoMinimum 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.

rust
let eod = tdx.index_history_eod("SPX", "20240101", "20240301").await?;
python
eod = tdx.index_history_eod("SPX", "20240101", "20240301")
typescript
const eod = tdx.indexHistoryEOD('SPX', '20240101', '20240301');
cpp
auto eod = client.index_history_eod("SPX", "20240101", "20240301");
ParameterTypeRequiredDescription
symbolstringYesIndex symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)

Returns: List of EodTick.


index_history_ohlc

Intraday OHLC bars for an index across a date range.

rust
let bars = tdx.index_history_ohlc("SPX", "20240101", "20240301", "60000").await?;
python
bars = tdx.index_history_ohlc("SPX", "20240101", "20240301", "60000")
typescript
const bars = tdx.indexHistoryOHLC('SPX', '20240101', '20240301', '60000');
cpp
auto bars = client.index_history_ohlc("SPX", "20240101", "20240301", "60000");
ParameterTypeRequiredDescription
symbolstringYesIndex symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
intervalstringYesAccepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)

Returns: List of OhlcTick.


index_history_price

Intraday price history for an index.

rust
let prices = tdx.index_history_price("SPX", "20240315", "60000").await?;
python
prices = tdx.index_history_price("SPX", "20240315", "60000")
typescript
const prices = tdx.indexHistoryPrice('SPX', '20240315', '60000');
cpp
auto prices = client.index_history_price("SPX", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesIndex symbol
datestringYesDate (YYYYMMDD)
intervalstringYesAccepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd 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.

rust
let prices = tdx.index_at_time_price("SPX", "20240101", "20240301", "09:30:00.000").await?;
python
prices = tdx.index_at_time_price("SPX", "20240101", "20240301", "09:30:00.000")
typescript
const prices = tdx.indexAtTimePrice('SPX', '20240101', '20240301', '09:30:00.000');
cpp
auto prices = client.index_at_time_price("SPX", "20240101", "20240301", "09:30:00.000");
ParameterTypeRequiredDescription
symbolstringYesIndex symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesET 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.

rust
let info = tdx.calendar_open_today().await?;
python
info = tdx.calendar_open_today()
typescript
const info = tdx.calendarOpenToday();
cpp
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.

rust
let info = tdx.calendar_on_date("20240315").await?;
python
info = tdx.calendar_on_date("20240315")
typescript
const info = tdx.calendarOnDate('20240315');
cpp
auto info = client.calendar_on_date("20240315");
ParameterTypeRequiredDescription
datestringYesDate (YYYYMMDD)

Returns: Array of CalendarDay records with calendar info for the date.


calendar_year

Calendar information for an entire year.

rust
let cal = tdx.calendar_year("2024").await?;
python
cal = tdx.calendar_year("2024")
typescript
const cal = tdx.calendarYear('2024');
cpp
auto cal = client.calendar_year("2024");
ParameterTypeRequiredDescription
yearstringYes4-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.

rust
let rates = tdx.interest_rate_history_eod("SOFR", "20240101", "20240301").await?;
python
rates = tdx.interest_rate_history_eod("SOFR", "20240101", "20240301")
typescript
const rates = tdx.interestRateHistoryEOD('SOFR', '20240101', '20240301');
cpp
auto rates = client.interest_rate_history_eod("SOFR", "20240101", "20240301");
ParameterTypeRequiredDescription
symbolstringYesRate symbol (e.g. "SOFR")
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd 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.

rust
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);
python
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}")
typescript
g = all_greeks(450.0, 455.0, 0.05, 0.015, 30.0 / 365.0, 8.50, 'C')
cpp
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;
ParameterTypeRequiredDescription
spotfloatYesUnderlying (spot) price
strikefloatYesStrike price
ratefloatYesRisk-free interest rate (annualized)
div_yieldfloatYesContinuous dividend yield (annualized)
ttefloatYesTime to expiration in years
option_pricefloatYesMarket price of the option
rightstringYesOption 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).

rust
use thetadatadx::implied_volatility;

let (iv, err) = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, "C");
python
from thetadatadx import implied_volatility

iv, err = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, "C")
typescript
iv, err = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, 'C')
cpp
auto [iv, err] = tdx::implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, "C");
ParameterTypeRequiredDescription
spotfloatYesUnderlying price
strikefloatYesStrike price
ratefloatYesRisk-free interest rate
div_yieldfloatYesDividend yield
ttefloatYesTime to expiration in years
option_pricefloatYesMarket price of the option
rightstringYesOption 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.

ParameterTypeDescription
sfloatSpot price
xfloatStrike price
vfloatVolatility (sigma)
rfloatRisk-free rate
qfloatDividend yield
tfloatTime to expiration (years)
is_callboolCall (true) or put (false) - only for directional Greeks

First-Order Greeks

FunctionSignatureDescription
value(s, x, v, r, q, t, is_call) -> f64Black-Scholes theoretical option value
delta(s, x, v, r, q, t, is_call) -> f64Rate of change of value w.r.t. spot price
theta(s, x, v, r, q, t, is_call) -> f64Time decay (daily, divided by 365)
vega(s, x, v, r, q, t) -> f64Sensitivity to volatility
rho(s, x, v, r, q, t, is_call) -> f64Sensitivity to interest rate
epsilon(s, x, v, r, q, t, is_call) -> f64Sensitivity to dividend yield
lambda(s, x, v, r, q, t, is_call) -> f64Leverage ratio (elasticity)

Second-Order Greeks

FunctionSignatureDescription
gamma(s, x, v, r, q, t) -> f64Rate of change of delta w.r.t. spot
vanna(s, x, v, r, q, t) -> f64Cross-sensitivity of delta to volatility
charm(s, x, v, r, q, t, is_call) -> f64Rate of change of delta w.r.t. time (delta decay)
vomma(s, x, v, r, q, t) -> f64Rate of change of vega w.r.t. volatility
veta(s, x, v, r, q, t) -> f64Rate of change of vega w.r.t. time

Third-Order Greeks

FunctionSignatureDescription
speed(s, x, v, r, q, t) -> f64Rate of change of gamma w.r.t. spot
zomma(s, x, v, r, q, t) -> f64Rate of change of gamma w.r.t. volatility
color(s, x, v, r, q, t) -> f64Rate of change of gamma w.r.t. time
ultima(s, x, v, r, q, t) -> f64Rate of change of vomma w.r.t. volatility (clamped to [-100, 100])

Auxiliary

FunctionSignatureDescription
dual_delta(s, x, v, r, q, t, is_call) -> f64Sensitivity of value w.r.t. strike
dual_gamma(s, x, v, r, q, t) -> f64Second derivative w.r.t. strike
d1(s, x, v, r, q, t) -> f64Black-Scholes d1 term
d2(s, x, v, r, q, t) -> f64Black-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

rust
client.start_streaming(|event: &FpssEvent| {
    match event {
        FpssEvent::Data(data) => println!("{:?}", data),
        FpssEvent::Control(ctrl) => println!("{:?}", ctrl),
        _ => {}
    }
})?;
python
client.start_streaming(lambda event: print(event))
typescript
client.startStreaming((event) => console.log(event));
cpp
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.

rust
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())?;
python
client.subscribe(Contract.stock("AAPL").quote())
client.subscribe(Contract.stock("AAPL").trade())
typescript
client.subscribe(Contract.stock('AAPL').quote());
client.subscribe(Contract.stock('AAPL').trade());
cpp
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 helperDescription
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

rust
client.unsubscribe(Contract::stock("AAPL").quote())?;
client.unsubscribe(Contract::stock("AAPL").trade())?;
client.unsubscribe(Contract::stock("AAPL").open_interest())?;
python
client.unsubscribe(Contract.stock("AAPL").quote())
typescript
client.unsubscribe(Contract.stock('AAPL').quote());
cpp
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.

rust
// 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:?}");
}
python
# Push:
client.start_streaming(lambda event: print(event))

# OR pull (context-managed):
with client.streaming_iter() as it:
    for event in it:
        print(event)
typescript
// Push:
client.startStreaming((event) => console.log(event));

// OR pull (async iterable):
const iter = client.startStreamingIter();
for await (const event of iter) {
    console.log(event);
}
cpp
// 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

rust
tdx.stop_streaming();
python
tdx.stop_streaming()
typescript
tdx.stopStreaming();
cpp
fpss.shutdown();

Streaming State

MethodReturnsSDK availabilityDescription
is_streamingboolRust/Python onlyCheck if the unified streaming connection is live
active_subscriptionslist/typed structsAll SDKsGet list of active subscriptions
subscribe(spec) / unsubscribe(spec)void / resultAll SDKsPolymorphic subscribe / unsubscribe — spec is a typed Subscription built via Contract::stock("AAPL").quote() / Contract::option(...).trade() / SecType::Stock.full_trades() / etc.
reconnectvoid / resultAll SDKsReconnect 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 update
  • Ohlcvc - Aggregated OHLCVC bar (derived from trades via internal accumulator; volume/count are i64 to avoid overflow on high-volume symbols)

FpssControl - Lifecycle events:

  • LoginSuccess - Authentication successful (includes permissions string)
  • ContractAssigned - Server assigned an ID to a contract
  • ReqResponse - Server confirmed a subscription request
  • MarketOpen / MarketClose - Market state transitions
  • ServerError / Error - Error conditions
  • Disconnected - 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 ms for rate limiting (TooManyRequests)
  • Returns 2,000 ms for 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

rust
tdx.stock_history_trade_stream("AAPL", "20240315")
    .stream(|trades: &[TradeTick]| {
        for t in trades {
            println!("{}: {}", t.date, t.price);
        }
    }).await?;

stock_history_quote_stream

rust
tdx.stock_history_quote_stream("AAPL", "20240315", "0")
    .stream(|quotes: &[QuoteTick]| {
    println!("Chunk: {} quotes", quotes.len());
}).await?;

option_history_trade_stream

rust
tdx.option_history_trade_stream("SPY", "20241220", "500", "C", "20240315")
    .stream(|trades: &[TradeTick]| {
        println!("Chunk: {} trades", trades.len());
    }).await?;

option_history_quote_stream

rust
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.

FieldType (Rust/FFI)Description
expirationi32Contract expiration (YYYYMMDD). 0 if absent.
strikef64Strike price (decoded to f64).
righti32Contract 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.

FieldTypeDescription
ms_of_dayi32Milliseconds since midnight ET
sequencei32Sequence number
ext_condition1 through ext_condition4i32Extended trade condition codes
conditioni32Trade condition code
sizei32Trade size (shares/contracts)
exchangei32Exchange code
pricef64Trade price (decoded)
condition_flagsi32Condition flags bitmap
price_flagsi32Price flags bitmap
volume_typei320 = incremental, 1 = cumulative
records_backi32Records back count
datei32Date as YYYYMMDD integer
expirationi32Contract expiration (wildcard queries)
strikef64Contract strike (wildcard queries)
righti32Contract 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.

FieldTypeDescription
ms_of_dayi32Milliseconds since midnight ET
bid_size / ask_sizei32Quote sizes
bid_exchange / ask_exchangei32Exchange codes
bid / askf64Bid and ask prices (decoded)
bid_condition / ask_conditioni32Condition codes
midpointf64Pre-computed (bid + ask) / 2.0
datei32Date as YYYYMMDD integer
expiration / strike / righti32/f64/i32Contract ID (wildcard queries)

Helper methods: is_call(), is_put(), has_contract_id(), plus contract ID helpers

OhlcTick

An aggregated OHLC bar.

FieldTypeDescription
ms_of_dayi32Bar start time (ms from midnight ET)
open / high / low / closef64OHLC prices (decoded)
volumei64Total volume in bar
counti64Number of trades in bar
datei32Date as YYYYMMDD integer
expiration / strike / righti32/f64/i32Contract 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.

FieldTypeDescription
ms_of_day / ms_of_day2i32Timestamps
open / high / low / closef64OHLC prices (decoded)
volumei64Total daily volume
counti64Total trade count
bid_size / ask_sizei32Closing quote sizes
bid_exchange / ask_exchangei32Closing quote exchanges
bid / askf64Closing bid/ask (decoded)
bid_condition / ask_conditioni32Closing quote conditions
datei32Date as YYYYMMDD
expiration / strike / righti32/f64/i32Contract 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

FieldTypeDescription
ms_of_dayi32Milliseconds since midnight ET
open_interesti32Open interest count
datei32Date as YYYYMMDD
expiration / strike / righti32/f64/i32Contract ID (wildcard queries)

GreeksResult

Result of all_greeks(). All fields are f64.

FieldOrderDescription
value-Black-Scholes theoretical value
iv-Implied volatility
iv_error-IV solver error (relative)
delta1stdV/dS
theta1stdV/dt (daily)
vega1stdV/dv
rho1stdV/dr
epsilon1stdV/dq (dividend sensitivity)
lambda1stElasticity (leverage ratio)
gamma2ndd2V/dS2
vanna2ndd2V/dSdv
charm2ndd2V/dSdt (delta decay)
vomma2ndd2V/dv2
veta2ndd2V/dvdt
speed3rdd3V/dS3
zomma3rdd3V/dS2dv
color3rdd3V/dS2dt
ultima3rdd3V/dv3
d1InternalBlack-Scholes d1
d2InternalBlack-Scholes d2
dual_deltaAuxdV/dX
dual_gammaAuxd2V/dX2

Price

All public tick fields are f64, decoded at parse time. No price_type conversion is needed in user code.

SecType

VariantCodeString
Stock0"STOCK"
Option1"OPTION"
Index2"INDEX"
Rate3"RATE"

Option right: Call, Put

  • from_char('C') / from_char('P') - parse from character
  • as_char() - convert to 'C' or 'P'

StreamResponseType

Subscription response codes returned in ReqResponse control events.

VariantCodeMeaning
Subscribed0Subscription successful
Error1General error
MaxStreamsReached2Subscription limit reached for your tier
InvalidPerms3Insufficient permissions for this data

Venue

Data venue for exchange filtering.

VariantWire 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.

rust
Contract::stock("AAPL")
Contract::index("SPX")
Contract::rate("SOFR")
Contract::option("SPY", "20261218", "60", "C")? // Result<Contract, Error>
python
# Build a typed Contract and call a topic helper to drive subscribe().
client.subscribe(Contract.stock("AAPL").quote())
typescript
// Build a typed Contract and call a topic helper to drive subscribe().
client.subscribe(Contract.stock('AAPL').quote());
cpp
// Build a typed Contract and call a topic helper to drive subscribe().
client.subscribe(tdx::Contract::stock("AAPL").quote());
FieldTypeDescription
symbolstringTicker symbol
sec_typeSecTypeSecurity type
expirationint (optional)Expiration date as YYYYMMDD (options only)
is_callbool (optional)true = call, false = put (options only)
strikestring (optional)Strike price in dollars (options only)

Credentials

rust
Credentials::from_file("creds.txt")?;   // line 1 = email, line 2 = password
Credentials::new("user@example.com", "password");
Credentials::parse("user@example.com\npassword")?;
python
Credentials.from_file("creds.txt")
Credentials("user@example.com", "password")
typescript
Credentials.from_file('creds.txt')
Credentials('user@example.com', 'password')
cpp
auto creds = tdx::Credentials::from_file("creds.txt");
auto creds = tdx::Credentials::from_email("email@example.com", "password");

Error Types

rust
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
}
python
# All errors raise RuntimeError with descriptive message
typescript
# All errors raise RuntimeError with descriptive message
cpp
// All methods throw std::runtime_error on failure

Python-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:

python
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:

python
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:

python
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:

python
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:

python
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:

python
empty = tdx.stock_history_eod("AAPL", "20260101", "20260101")
assert len(empty) == 0
table = empty.to_arrow()          # zero rows, EodTick column schema

Released under the Apache-2.0 License.