Skip to content

API Reference

ThetaDataDx provides a unified client for accessing ThetaData market data. Historical data flows over MDDS/gRPC; real-time streaming flows over FPSS/TCP. The SDK ships native bindings for Rust, Python, Go, and C++, all backed by the same compiled Rust core.

61 typed endpoints + 4 streaming variants + 22 Greeks functions + IV solver.

Client Construction

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

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

creds = Credentials.from_file("creds.txt")
tdx = ThetaDataDx(creds, Config.production())
go
creds, err := thetadatadx.CredentialsFromFile("creds.txt")
defer creds.Close()

config := thetadatadx.ProductionConfig()
defer config.Close()

client, err := thetadatadx.Connect(creds, config)
defer client.Close()
cpp
auto creds = tdx::Credentials::from_file("creds.txt");
auto client = tdx::ThetaDataDx::connect(creds, tdx::Config::production());

Stock Endpoints

stock_list_symbols

List all available stock ticker symbols.

rust
let symbols: Vec<String> = tdx.stock_list_symbols().await?;
python
symbols = tdx.stock_list_symbols()
go
symbols, err := client.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("EOD", "AAPL").await?;
python
dates = tdx.stock_list_dates("EOD", "AAPL")
go
dates, err := client.StockListDates("EOD", "AAPL")
cpp
auto dates = client.stock_list_dates("EOD", "AAPL");
ParameterTypeRequiredDescription
request_typestringYesData type: "EOD", "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"])
go
bars, err := client.StockSnapshotOHLC([]string{"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"])
go
trades, err := client.StockSnapshotTrade([]string{"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"])
go
quotes, err := client.StockSnapshotQuote([]string{"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"])
go
mv, err := client.StockSnapshotMarketValue([]string{"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: Vec<MarketValueTick> 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")
go
eod, err := client.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")
go
bars, err := client.StockHistoryOHLC("AAPL", "20240315", "60000")
cpp
auto bars = client.stock_history_ohlc("AAPL", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
datestringYesDate (YYYYMMDD)
intervalstringYesBar interval in milliseconds (e.g. "60000" for 1-minute)
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")
go
bars, err := client.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)
intervalstringYesBar interval in milliseconds

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")
go
trades, err := client.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")
go
quotes, err := client.StockHistoryQuote("AAPL", "20240315", "60000")
cpp
auto quotes = client.stock_history_quote("AAPL", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
datestringYesDate (YYYYMMDD)
intervalstringYesSampling interval in ms ("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")
go
tq, err := client.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: Vec<TradeQuoteTick> 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", "34200000").await?;
python
trades = tdx.stock_at_time_trade("AAPL", "20240101", "20240301", "34200000")
go
trades, err := client.StockAtTimeTrade("AAPL", "20240101", "20240301", "34200000")
cpp
auto trades = client.stock_at_time_trade("AAPL", "20240101", "20240301", "34200000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesMs from midnight ET (e.g. "34200000" = 9:30 AM)
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", "34200000").await?;
python
quotes = tdx.stock_at_time_quote("AAPL", "20240101", "20240301", "34200000")
go
quotes, err := client.StockAtTimeQuote("AAPL", "20240101", "20240301", "34200000")
cpp
auto quotes = client.stock_at_time_quote("AAPL", "20240101", "20240301", "34200000");
ParameterTypeRequiredDescription
symbolstringYesTicker symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesMs from midnight ET
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 as scaled integer string (e.g. "500000" for $500)
  • 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()
go
symbols, err := client.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("EOD", "SPY", "20241220", "500000", "C").await?;
python
dates = tdx.option_list_dates("EOD", "SPY", "20241220", "500000", "C")
go
dates, err := client.OptionListDates("EOD", "SPY", "20241220", "500000", "C")
cpp
auto dates = client.option_list_dates("EOD", "SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
request_typestringYesData type: "EOD", "TRADE", "QUOTE", etc.
symbolstringYesUnderlying symbol
expirationstringYesExpiration date (YYYYMMDD)
strikestringYesStrike price (scaled integer)
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")
go
exps, err := client.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")
go
strikes, err := client.OptionListStrikes("SPY", "20241220")
cpp
auto strikes = client.option_list_strikes("SPY", "20241220");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date (YYYYMMDD)

Returns: List of strike price strings (scaled integers).


option_list_contracts

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

rust
let contracts = tdx.option_list_contracts("EOD", "SPY", "20240315").await?;
python
contracts = tdx.option_list_contracts("EOD", "SPY", "20240315")
go
contracts, err := client.OptionListContracts("EOD", "SPY", "20240315")
cpp
auto contracts = client.option_list_contracts("EOD", "SPY", "20240315");
ParameterTypeRequiredDescription
request_typestringYesData type
symbolstringYesUnderlying symbol
datestringYesDate (YYYYMMDD)
max_dteintNoMaximum days to expiration filter

Returns: Vec<OptionContract> with root, expiration, strike, right.


option_snapshot_ohlc

Latest OHLC snapshot for an option contract.

rust
let bars = tdx.option_snapshot_ohlc("SPY", "20241220", "500000", "C").await?;
python
bars = tdx.option_snapshot_ohlc("SPY", "20241220", "500000", "C")
go
bars, err := client.OptionSnapshotOHLC("SPY", "20241220", "500000", "C")
cpp
auto bars = client.option_snapshot_ohlc("SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date (YYYYMMDD)
strikestringYesStrike price (scaled integer)
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", "500000", "C").await?;
python
trades = tdx.option_snapshot_trade("SPY", "20241220", "500000", "C")
go
trades, err := client.OptionSnapshotTrade("SPY", "20241220", "500000", "C")
cpp
auto trades = client.option_snapshot_trade("SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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", "500000", "C").await?;
python
quotes = tdx.option_snapshot_quote("SPY", "20241220", "500000", "C")
go
quotes, err := client.OptionSnapshotQuote("SPY", "20241220", "500000", "C")
cpp
auto quotes = client.option_snapshot_quote("SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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", "500000", "C").await?;
python
oi = tdx.option_snapshot_open_interest("SPY", "20241220", "500000", "C")
go
oi, err := client.OptionSnapshotOpenInterest("SPY", "20241220", "500000", "C")
cpp
auto oi = client.option_snapshot_open_interest("SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: Vec<OpenInterestTick> 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", "500000", "C").await?;
python
mv = tdx.option_snapshot_market_value("SPY", "20241220", "500000", "C")
go
mv, err := client.OptionSnapshotMarketValue("SPY", "20241220", "500000", "C")
cpp
auto mv = client.option_snapshot_market_value("SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter
min_timestringNoMinimum time of day (ms from midnight)

Returns: Vec<MarketValueTick> 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", "500000", "C").await?;
python
iv = tdx.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500000", "C")
go
iv, err := client.OptionSnapshotGreeksIV("SPY", "20241220", "500000", "C")
cpp
auto iv = client.option_snapshot_greeks_implied_volatility("SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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: Vec<IvTick> 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", "500000", "C").await?;
python
greeks = tdx.option_snapshot_greeks_all("SPY", "20241220", "500000", "C")
go
greeks, err := client.OptionSnapshotGreeksAll("SPY", "20241220", "500000", "C")
cpp
auto greeks = client.option_snapshot_greeks_all("SPY", "20241220", "500000", "C");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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: Vec<GreeksTick> with all 22 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", "500000", "C").await?;
python
g = tdx.option_snapshot_greeks_first_order("SPY", "20241220", "500000", "C")
go
g, err := client.OptionSnapshotGreeksFirstOrder("SPY", "20241220", "500000", "C")
cpp
auto g = client.option_snapshot_greeks_first_order("SPY", "20241220", "500000", "C");

Parameters are identical to option_snapshot_greeks_all.

Returns: Vec<GreeksTick> 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", "500000", "C").await?;
python
g = tdx.option_snapshot_greeks_second_order("SPY", "20241220", "500000", "C")
go
g, err := client.OptionSnapshotGreeksSecondOrder("SPY", "20241220", "500000", "C")
cpp
auto g = client.option_snapshot_greeks_second_order("SPY", "20241220", "500000", "C");

Parameters are identical to option_snapshot_greeks_all.

Returns: Vec<GreeksTick> 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", "500000", "C").await?;
python
g = tdx.option_snapshot_greeks_third_order("SPY", "20241220", "500000", "C")
go
g, err := client.OptionSnapshotGreeksThirdOrder("SPY", "20241220", "500000", "C")
cpp
auto g = client.option_snapshot_greeks_third_order("SPY", "20241220", "500000", "C");

Parameters are identical to option_snapshot_greeks_all.

Returns: Vec<GreeksTick> 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", "500000", "C", "20240101", "20240301"
).await?;
python
eod = tdx.option_history_eod("SPY", "20241220", "500000", "C", "20240101", "20240301")
go
eod, err := client.OptionHistoryEOD("SPY", "20241220", "500000", "C", "20240101", "20240301")
cpp
auto eod = client.option_history_eod("SPY", "20241220", "500000", "C", "20240101", "20240301");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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", "500000", "C", "20240315", "60000"
).await?;
python
bars = tdx.option_history_ohlc("SPY", "20241220", "500000", "C", "20240315", "60000")
go
bars, err := client.OptionHistoryOHLC("SPY", "20241220", "500000", "C", "20240315", "60000")
cpp
auto bars = client.option_history_ohlc("SPY", "20241220", "500000", "C", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
intervalstringYesBar interval in milliseconds
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", "500000", "C", "20240315").await?;
python
trades = tdx.option_history_trade("SPY", "20241220", "500000", "C", "20240315")
go
trades, err := client.OptionHistoryTrade("SPY", "20241220", "500000", "C", "20240315")
cpp
auto trades = client.option_history_trade("SPY", "20241220", "500000", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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", "500000", "C", "20240315", "60000"
).await?;
python
quotes = tdx.option_history_quote("SPY", "20241220", "500000", "C", "20240315", "60000")
go
quotes, err := client.OptionHistoryQuote("SPY", "20241220", "500000", "C", "20240315", "60000")
cpp
auto quotes = client.option_history_quote("SPY", "20241220", "500000", "C", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
intervalstringYesSampling interval in ms
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", "500000", "C", "20240315").await?;
python
tq = tdx.option_history_trade_quote("SPY", "20241220", "500000", "C", "20240315")
go
tq, err := client.OptionHistoryTradeQuote("SPY", "20241220", "500000", "C", "20240315")
cpp
auto tq = client.option_history_trade_quote("SPY", "20241220", "500000", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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", "500000", "C", "20240315").await?;
python
oi = tdx.option_history_open_interest("SPY", "20241220", "500000", "C", "20240315")
go
oi, err := client.OptionHistoryOpenInterest("SPY", "20241220", "500000", "C", "20240315")
cpp
auto oi = client.option_history_open_interest("SPY", "20241220", "500000", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
max_dteintNoMaximum days to expiration
strike_rangeintNoStrike range filter

Returns: Vec<OpenInterestTick> 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", "500000", "C", "20240101", "20240301"
).await?;
python
g = tdx.option_history_greeks_eod("SPY", "20241220", "500000", "C", "20240101", "20240301")
go
g, err := client.OptionHistoryGreeksEOD("SPY", "20241220", "500000", "C", "20240101", "20240301")
cpp
auto g = client.option_history_greeks_eod("SPY", "20241220", "500000", "C", "20240101", "20240301");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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: Vec<GreeksTick> 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", "500000", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_all("SPY", "20241220", "500000", "C", "20240315", "60000")
go
g, err := client.OptionHistoryGreeksAll("SPY", "20241220", "500000", "C", "20240315", "60000")
cpp
auto g = client.option_history_greeks_all("SPY", "20241220", "500000", "C", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
datestringYesDate (YYYYMMDD)
intervalstringYesSampling interval in ms
annual_dividendfloatNoOverride annual dividend
rate_typestringNoInterest rate type
rate_valuefloatNoOverride interest rate value
versionstringNoGreeks calculation version
strike_rangeintNoStrike range filter

Returns: Vec<GreeksTick> with all 22 Greeks at each interval.

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", "500000", "C", "20240315").await?;
python
g = tdx.option_history_trade_greeks_all("SPY", "20241220", "500000", "C", "20240315")
go
g, err := client.OptionHistoryTradeGreeksAll("SPY", "20241220", "500000", "C", "20240315")
cpp
auto g = client.option_history_trade_greeks_all("SPY", "20241220", "500000", "C", "20240315");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
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: Vec<GreeksTick> with all 22 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", "500000", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_first_order("SPY", "20241220", "500000", "C", "20240315", "60000")
go
g, err := client.OptionHistoryGreeksFirstOrder("SPY", "20241220", "500000", "C", "20240315", "60000")
cpp
auto g = client.option_history_greeks_first_order("SPY", "20241220", "500000", "C", "20240315", "60000");

Parameters are identical to option_history_greeks_all.

Returns: Vec<GreeksTick> with first-order Greeks at each interval.

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", "500000", "C", "20240315"
).await?;
python
g = tdx.option_history_trade_greeks_first_order("SPY", "20241220", "500000", "C", "20240315")
go
g, err := client.OptionHistoryTradeGreeksFirstOrder("SPY", "20241220", "500000", "C", "20240315")
cpp
auto g = client.option_history_trade_greeks_first_order("SPY", "20241220", "500000", "C", "20240315");

Parameters are identical to option_history_trade_greeks_all.

Returns: Vec<GreeksTick> 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", "500000", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_second_order("SPY", "20241220", "500000", "C", "20240315", "60000")
go
g, err := client.OptionHistoryGreeksSecondOrder("SPY", "20241220", "500000", "C", "20240315", "60000")
cpp
auto g = client.option_history_greeks_second_order("SPY", "20241220", "500000", "C", "20240315", "60000");

Parameters are identical to option_history_greeks_all.

Returns: Vec<GreeksTick> with second-order Greeks at each interval.

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", "500000", "C", "20240315"
).await?;
python
g = tdx.option_history_trade_greeks_second_order("SPY", "20241220", "500000", "C", "20240315")
go
g, err := client.OptionHistoryTradeGreeksSecondOrder("SPY", "20241220", "500000", "C", "20240315")
cpp
auto g = client.option_history_trade_greeks_second_order("SPY", "20241220", "500000", "C", "20240315");

Parameters are identical to option_history_trade_greeks_all.

Returns: Vec<GreeksTick> 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", "500000", "C", "20240315", "60000"
).await?;
python
g = tdx.option_history_greeks_third_order("SPY", "20241220", "500000", "C", "20240315", "60000")
go
g, err := client.OptionHistoryGreeksThirdOrder("SPY", "20241220", "500000", "C", "20240315", "60000")
cpp
auto g = client.option_history_greeks_third_order("SPY", "20241220", "500000", "C", "20240315", "60000");

Parameters are identical to option_history_greeks_all.

Returns: Vec<GreeksTick> with third-order Greeks at each interval.

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", "500000", "C", "20240315"
).await?;
python
g = tdx.option_history_trade_greeks_third_order("SPY", "20241220", "500000", "C", "20240315")
go
g, err := client.OptionHistoryTradeGreeksThirdOrder("SPY", "20241220", "500000", "C", "20240315")
cpp
auto g = client.option_history_trade_greeks_third_order("SPY", "20241220", "500000", "C", "20240315");

Parameters are identical to option_history_trade_greeks_all.

Returns: Vec<GreeksTick> 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", "500000", "C", "20240315", "60000"
).await?;
python
iv = tdx.option_history_greeks_implied_volatility("SPY", "20241220", "500000", "C", "20240315", "60000")
go
iv, err := client.OptionHistoryGreeksImpliedVolatility("SPY", "20241220", "500000", "C", "20240315", "60000")
cpp
auto iv = client.option_history_greeks_implied_volatility("SPY", "20241220", "500000", "C", "20240315", "60000");

Parameters are identical to option_history_greeks_all.

Returns: Vec<IvTick> with implied volatility at each interval.

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", "500000", "C", "20240315"
).await?;
python
iv = tdx.option_history_trade_greeks_implied_volatility("SPY", "20241220", "500000", "C", "20240315")
go
iv, err := client.OptionHistoryTradeGreeksImpliedVolatility("SPY", "20241220", "500000", "C", "20240315")
cpp
auto iv = client.option_history_trade_greeks_implied_volatility("SPY", "20241220", "500000", "C", "20240315");

Parameters are identical to option_history_trade_greeks_all.

Returns: Vec<IvTick> 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", "500000", "C", "20240101", "20240301", "34200000"
).await?;
python
trades = tdx.option_at_time_trade("SPY", "20241220", "500000", "C", "20240101", "20240301", "34200000")
go
trades, err := client.OptionAtTimeTrade("SPY", "20241220", "500000", "C", "20240101", "20240301", "34200000")
cpp
auto trades = client.option_at_time_trade("SPY", "20241220", "500000", "C", "20240101", "20240301", "34200000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesMs from midnight ET
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", "500000", "C", "20240101", "20240301", "34200000"
).await?;
python
quotes = tdx.option_at_time_quote("SPY", "20241220", "500000", "C", "20240101", "20240301", "34200000")
go
quotes, err := client.OptionAtTimeQuote("SPY", "20241220", "500000", "C", "20240101", "20240301", "34200000")
cpp
auto quotes = client.option_at_time_quote("SPY", "20241220", "500000", "C", "20240101", "20240301", "34200000");
ParameterTypeRequiredDescription
symbolstringYesUnderlying symbol
expirationstringYesExpiration date
strikestringYesStrike price (scaled integer)
rightstringYes"C" or "P"
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesMs from midnight ET
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()
go
symbols, err := client.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")
go
dates, err := client.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"])
go
bars, err := client.IndexSnapshotOHLC([]string{"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"])
go
prices, err := client.IndexSnapshotPrice([]string{"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: Vec<PriceTick> 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"])
go
mv, err := client.IndexSnapshotMarketValue([]string{"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: Vec<MarketValueTick> 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")
go
eod, err := client.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")
go
bars, err := client.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)
intervalstringYesBar interval in milliseconds
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")
go
prices, err := client.IndexHistoryPrice("SPX", "20240315", "60000")
cpp
auto prices = client.index_history_price("SPX", "20240315", "60000");
ParameterTypeRequiredDescription
symbolstringYesIndex symbol
datestringYesDate (YYYYMMDD)
intervalstringYesSampling interval in ms
start_timestringNoStart time (ms from midnight)
end_timestringNoEnd time (ms from midnight)

Returns: Vec<PriceTick> with price at each interval.


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", "34200000").await?;
python
prices = tdx.index_at_time_price("SPX", "20240101", "20240301", "34200000")
go
prices, err := client.IndexAtTimePrice("SPX", "20240101", "20240301", "34200000")
cpp
auto prices = client.index_at_time_price("SPX", "20240101", "20240301", "34200000");
ParameterTypeRequiredDescription
symbolstringYesIndex symbol
start_datestringYesStart date (YYYYMMDD)
end_datestringYesEnd date (YYYYMMDD)
time_of_daystringYesMs from midnight ET

Returns: Vec<PriceTick> 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()
go
info, err := client.CalendarOpenToday()
cpp
auto info = client.calendar_open_today();

Parameters: None

Returns: Vec<CalendarDay> 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")
go
info, err := client.CalendarOnDate("20240315")
cpp
auto info = client.calendar_on_date("20240315");
ParameterTypeRequiredDescription
datestringYesDate (YYYYMMDD)

Returns: Vec<CalendarDay> 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")
go
cal, err := client.CalendarYear("2024")
cpp
auto cal = client.calendar_year("2024");
ParameterTypeRequiredDescription
yearstringYes4-digit year (e.g. "2024")

Returns: Vec<CalendarDay> 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")
go
rates, err := client.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: Vec<InterestRateTick> 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 22 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::greeks;

let g = greeks::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
    true,           // is_call
);
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, True)
print(f"IV: {g['iv']:.4f}, Delta: {g['delta']:.4f}")
go
g, err := thetadatadx.AllGreeks(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, true)
fmt.Printf("IV: %.4f, Delta: %.4f\n", g.IV, g.Delta)
cpp
auto g = tdx::all_greeks(450.0, 455.0, 0.05, 0.015, 30.0 / 365.0, 8.50, true);
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
is_callboolYestrue for call, false for put

Returns: GreeksResult containing all 22 fields.


implied_volatility

Solve for implied volatility using bisection (up to 128 iterations).

rust
let (iv, err) = greeks::implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, true);
python
from thetadatadx import implied_volatility

iv, err = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, True)
go
iv, ivErr, err := thetadatadx.ImpliedVolatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, true)
cpp
auto [iv, err] = tdx::implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0/365.0, 8.50, true);
ParameterTypeRequiredDescription
spotfloatYesUnderlying price
strikefloatYesStrike price
ratefloatYesRisk-free interest rate
div_yieldfloatYesDividend yield
ttefloatYesTime to expiration in years
option_pricefloatYesMarket price of the option
is_callboolYestrue for call, false for put

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; Go and C++ use a dedicated FpssClient.

Starting the Stream

rust
tdx.start_streaming(|event: &FpssEvent| {
    match event {
        FpssEvent::Data(data) => println!("{:?}", data),
        FpssEvent::Control(ctrl) => println!("{:?}", ctrl),
        _ => {}
    }
})?;
python
tdx.start_streaming()
go
fpss := thetadatadx.NewFpssClient(creds, config)
defer fpss.Close()
cpp
tdx::FpssClient fpss(creds, tdx::Config::production());

Subscribing

rust
let req_id = tdx.subscribe_quotes(&Contract::stock("AAPL"))?;
let req_id = tdx.subscribe_trades(&Contract::stock("AAPL"))?;
let req_id = tdx.subscribe_open_interest(&Contract::stock("AAPL"))?;
let req_id = tdx.subscribe_full_trades(SecType::Stock)?;
python
tdx.subscribe_quotes("AAPL")
tdx.subscribe_trades("AAPL")
go
reqID, err := fpss.SubscribeQuotes("AAPL")
reqID, err := fpss.SubscribeTrades("AAPL")
reqID, err := fpss.SubscribeOpenInterest("AAPL")
reqID, err := fpss.SubscribeFullTrades("STOCK")
cpp
int req_id = fpss.subscribe_quotes("AAPL");
int req_id = fpss.subscribe_trades("AAPL");
int req_id = fpss.subscribe_open_interest("AAPL");
int req_id = fpss.subscribe_full_trades("STOCK");
MethodDescription
subscribe_quotesSubscribe to real-time NBBO quote updates
subscribe_tradesSubscribe to real-time trade updates
subscribe_open_interestSubscribe to open interest updates
subscribe_full_tradesSubscribe to all trades for a security type

All subscription methods return a request ID. The server confirms via a ReqResponse control event.

Unsubscribing

rust
tdx.unsubscribe_quotes(&Contract::stock("AAPL"))?;
tdx.unsubscribe_trades(&Contract::stock("AAPL"))?;
tdx.unsubscribe_open_interest(&Contract::stock("AAPL"))?;
python
# Not exposed in Python - use stop_streaming()
go
fpss.UnsubscribeQuotes("AAPL")
fpss.UnsubscribeTrades("AAPL")
fpss.UnsubscribeOpenInterest("AAPL")
cpp
fpss.unsubscribe_quotes("AAPL");
fpss.unsubscribe_trades("AAPL");
fpss.unsubscribe_open_interest("AAPL");

Receiving Events

rust
// Events arrive via the callback passed to start_streaming()
tdx.start_streaming(|event| {
    if let FpssEvent::Data(FpssData::Trade { contract_id, price, size, .. }) = event {
        println!("Trade: contract={}, price={}, size={}", contract_id, price, size);
    }
})?;
python
event = tdx.next_event(timeout_ms=5000)  # returns dict or None
if event:
    print(event)
go
event, err := fpss.NextEvent(5000)  // returns json.RawMessage or nil
cpp
std::string event = fpss.next_event(5000);  // empty string on timeout

Shutting Down

rust
tdx.stop_streaming();
python
tdx.stop_streaming()
go
fpss.Shutdown()
cpp
fpss.shutdown();

Streaming State

MethodReturnsDescription
is_streamingboolCheck if the streaming connection is live
contract_map / contract_lookupmap/stringLook up server-assigned contract IDs
active_subscriptionslist/JSONGet list of active subscriptions

FpssEvent Types

Events are delivered as one of three categories:

FpssData - Market data events:

  • 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)

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)

RawData - Unparsed frames with unknown message codes.

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

For historical endpoints that can return millions of rows, _stream variants process data chunk-by-chunk without loading everything into memory. Available in Rust only.

stock_history_trade_stream

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

stock_history_quote_stream

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

option_history_trade_stream

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

option_history_quote_stream

rust
tdx.option_history_quote_stream("SPY", "20241220", "500000", "C", "20240315", "0", |quotes: &[QuoteTick]| {
    println!("Chunk: {} quotes", quotes.len());
}).await?;

Types and Enums

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
pricei32Fixed-point price (use get_price())
condition_flagsi32Condition flags bitmap
price_flagsi32Price flags bitmap
volume_typei320 = incremental, 1 = cumulative
records_backi32Records back count
price_typei32Decimal type for price decoding
datei32Date as YYYYMMDD integer

Helper methods: get_price(), is_cancelled(), regular_trading_hours(), is_seller(), is_incremental_volume()

QuoteTick

An NBBO quote.

FieldTypeDescription
ms_of_dayi32Milliseconds since midnight ET
bid_size / ask_sizei32Quote sizes
bid_exchange / ask_exchangei32Exchange codes
bid / aski32Fixed-point prices
bid_condition / ask_conditioni32Condition codes
price_typei32Decimal type for price decoding
datei32Date as YYYYMMDD integer

Helper methods: bid_price(), ask_price(), midpoint_price(), midpoint_value()

OhlcTick

An aggregated OHLC bar.

FieldTypeDescription
ms_of_dayi32Bar start time (ms from midnight ET)
open / high / low / closei32Fixed-point OHLC prices
volumei32Total volume in bar
counti32Number of trades in bar
price_typei32Decimal type for price decoding
datei32Date as YYYYMMDD integer

Helper methods: open_price(), high_price(), low_price(), close_price()

EodTick

Full end-of-day snapshot with OHLC + closing quote data (18 fields).

FieldTypeDescription
ms_of_day / ms_of_day2i32Timestamps
open / high / low / closei32Fixed-point OHLC prices
volumei32Total daily volume
counti32Total trade count
bid_size / ask_sizei32Closing quote sizes
bid_exchange / ask_exchangei32Closing quote exchanges
bid / aski32Closing bid/ask (fixed-point)
bid_condition / ask_conditioni32Closing quote conditions
price_typei32Decimal type
datei32Date as YYYYMMDD

Helper methods: open_price(), high_price(), low_price(), close_price(), bid_price(), ask_price(), midpoint_value()

TradeQuoteTick

Combined trade + quote tick (25 fields). Contains the full trade data plus the prevailing NBBO quote at the time of the trade.

Helper methods: trade_price(), bid_price(), ask_price()

OpenInterestTick

FieldTypeDescription
ms_of_dayi32Milliseconds since midnight ET
open_interesti32Open interest count
datei32Date as YYYYMMDD

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

Fixed-point price with variable decimal precision.

real_price = value * 10^(price_type - 10)
price_typeMultiplierExample
0Zero(0, 0) = 0.0
60.0001(1502500, 6) = 150.2500
70.001(5, 7) = 0.005
80.01(15025, 8) = 150.25
101.0(100, 10) = 100.0
12100.0(5, 12) = 500.0

Methods: to_f64(), is_zero(), Display (formats with correct decimals)

Prices with different price_type values can be compared directly - they are normalized internally.

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, true, 60000)  // call, strike 60000
python
# Passed as string symbol to subscribe methods
tdx.subscribe_quotes("AAPL")
go
// Passed as string symbol to subscribe methods
fpss.SubscribeQuotes("AAPL")
cpp
// Passed as string symbol to subscribe methods
fpss.subscribe_quotes("AAPL");
FieldTypeDescription
rootstringTicker symbol
sec_typeSecTypeSecurity type
exp_dateint (optional)Expiration date as YYYYMMDD (options only)
is_callbool (optional)true = call, false = put (options only)
strikeint (optional)Strike price as scaled integer (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")
go
creds, err := thetadatadx.CredentialsFromFile("creds.txt")
creds := thetadatadx.NewCredentials("email@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 {
    Auth(String),          // Invalid credentials (401/404)
    Http(String),          // Network or server issue
    Grpc(tonic::Status),   // gRPC transport error
    NoData,                // Symbol does not exist
}
python
# All errors raise RuntimeError with descriptive message
go
// All methods return (result, error)
cpp
// All methods throw std::runtime_error on failure

Python-Specific Features

DataFrame Support

All 61 data methods have _df variants that return pandas DataFrames directly:

python
df = tdx.stock_history_eod_df("AAPL", "20240101", "20240301")
df = tdx.option_history_ohlc_df("SPY", "20241220", "500000", "C", "20240315", "60000")

Requires pip install thetadatadx[pandas].

Polars Support

python
from thetadatadx import to_polars

eod = tdx.stock_history_eod("AAPL", "20240101", "20240301")
df = to_polars(eod)

Requires pip install thetadatadx[polars].

Manual Conversion

python
from thetadatadx import to_dataframe

eod = tdx.stock_history_eod("AAPL", "20240101", "20240301")
df = to_dataframe(eod)

Released under the GPL-3.0-or-later License.