Expand description
§thetadatadx — No-JVM ThetaData Terminal
Native Rust SDK that connects directly to ThetaData’s upstream servers,
eliminating the Java terminal entirely. No JVM, no subprocess, no local proxy —
just your application speaking the same wire protocol the terminal uses.
§Data types live in tdbe
Tick types (TradeTick, EodTick, …), Price, enums (SecType, DataType),
the FIT/FIE codecs, and the Greeks calculator have been extracted into the
tdbe crate. This crate re-exports what it
needs, but if you only want types and offline Greeks, depend on tdbe directly.
§Architecture
ThetaData exposes two upstream services:
- MDDS (Market Data Distribution Server) — historical data via gRPC at
mdds-01.thetadata.us:443 - FPSS (Feed Processing Streaming Server) — real-time streaming via custom TCP at
nj-a.thetadata.us:20000
This crate speaks both protocols natively, handling authentication, request building, response decompression, and tick parsing entirely in Rust.
§Quick Start
The recommended entry point is ThetaDataDxClient, which authenticates once and
provides both historical and streaming through a single object:
use thetadatadx::{ThetaDataDxClient, Credentials, DirectConfig};
use thetadatadx::fpss::{FpssData, FpssEvent};
use thetadatadx::fpss::protocol::Contract;
let creds = Credentials::from_file("creds.txt")?;
// Or inline: let creds = Credentials::new("user@example.com", "your-password");
// Connect -- authenticates once, historical ready immediately
let tdx = ThetaDataDxClient::connect(&creds, DirectConfig::production()).await?;
// Historical (MDDS gRPC) -- every generated method via Deref
let ticks = tdx.stock_history_eod("AAPL", "20240101", "20240301").await?;
// Streaming (FPSS TCP) -- connects lazily on first call
tdx.start_streaming(|event: &FpssEvent| {
if let FpssEvent::Data(FpssData::Trade { contract, price, size, .. }) = event {
println!("Trade: {} @ {price} x {size}", contract.symbol);
}
})?;
tdx.subscribe(Contract::stock("AAPL").quote())?;
// ... when done:
tdx.stop_streaming();For historical-only usage, just skip start_streaming() – every historical
methods are available directly on ThetaDataDxClient via Deref<Target = MddsClient>:
use thetadatadx::{ThetaDataDxClient, Credentials, DirectConfig};
let creds = Credentials::from_file("creds.txt")?;
// Or inline: let creds = Credentials::new("user@example.com", "your-password");
let tdx = ThetaDataDxClient::connect(&creds, DirectConfig::production()).await?;
let ticks = tdx.stock_history_eod("AAPL", "20240101", "20240301").await?;§Wire protocol
-
Proto definitions:
crates/thetadatadx/proto/mdds.proto— singleBetaEndpointspackage, 60 RPCs,BetaThetaTerminalservice. -
Auth flow: POST to
https://nexus-api.thetadata.us/identity/terminal/auth_userwith headerTD-TERMINAL-KEYand JSON{email, password}→SessionInfoV3with UUID. -
MDDS: Standard gRPC server-streaming over TLS. Session UUID embedded in
QueryInfo.auth_tokenfield of every request (in-band, not metadata). -
FPSS: Custom TLS-over-TCP protocol. 1-byte length + 1-byte message code + payload. FIT nibble encoding (4-bit variable-length integers) with delta compression for ticks.
See proto/MAINTENANCE.md for how to
update the proto file and regenerate stubs when ThetaData ships a new version.
Re-exports§
pub use mdds::endpoint_args as endpoint;pub use mdds::decode;pub use auth::Credentials;pub use fpss::protocol::Contract;pub use fpss::protocol::ContractParseError;pub use fpss::protocol::FullSubscriptionKind;pub use fpss::protocol::SecTypeExt;pub use fpss::protocol::Subscription;pub use fpss::protocol::SubscriptionKind;pub use fpss::EventIterator;pub use fpss::NextEvent;pub use config::DirectConfig;pub use config::FallbackPolicy;pub use config::FlatFilesConfig;pub use config::FpssFlushMode;pub use config::ReconnectAttemptClass;pub use config::ReconnectAttemptLimits;pub use config::ReconnectPolicy;pub use config::RetryPolicy;pub use config::RuntimeConfig;pub use config::DEFAULT_REST_BASE_URL;pub use error::AuthErrorKind;pub use error::Error;pub use error::FpssErrorKind;pub use flatfiles::default_output_filename as flatfile_default_filename;pub use flatfiles::flatfile_request;pub use flatfiles::flatfile_request_decoded;pub use flatfiles::flatfile_request_raw;pub use flatfiles::FlatFileFormat;pub use flatfiles::FlatFileRow;pub use flatfiles::FlatFileValue;pub use flatfiles::ReqType as FlatFileReqType;pub use flatfiles::SecType as FlatFileSecType;pub use mdds::endpoint_args::EndpointArgValue;pub use mdds::endpoint_args::EndpointArgs;pub use mdds::endpoint_args::EndpointError;pub use mdds::endpoint_args::EndpointOutput;pub use mdds::MddsClient;pub use mdds::SubscriptionTier;
Modules§
- auth
- Authentication for
ThetaDatadirect server access. - config
- Server configuration for direct
ThetaDataaccess. - error
- flatfiles
- FLATFILES: whole-universe daily snapshots over the legacy MDDS
port. Pulls one INDEX + DATA blob per
(SecType, ReqType, date)tuple and emits CSV, JSONL, orVec<FlatFileRow>. - fpss
- FPSS real-time streaming client.
- frames
arroworpolars - DataFrame extension traits —
.to_polars()/.to_arrow()on&[Tick]. - mdds
- MDDS (Market Data Distribution Server) gRPC client.
- prelude
- Convenience prelude for the fluent contract-first API.
- rest
- REST transport for the local ThetaTerminal HTTP API.
- util
- Cross-cutting utilities shared by multiple subsystems.
- utils
- wire
- gRPC wire-payload re-exports for offline-decode callers.
Structs§
- Calendar
Day - Calendar day – 5 fields. Market open/close schedule.
- Endpoint
Meta - Metadata for a single endpoint.
- EodTick
- End-of-day tick – 17 fields. Full EOD snapshot with OHLC + quote.
- Greeks
AllTick - Full union Greeks tick – every Greek the v3 server publishes on the
option_*_greeks_allandoption_*_greeks_eodendpoints. - Greeks
EodTick - End-of-day union Greeks tick – every Greek the v3 server publishes on
option_history_greeks_eod, paired with the twelve EOD trade/quote context columns (open,high,low,close,volume,count,bid_size,bid_exchange,bid_condition,ask_size,ask_exchange,ask_condition) that identify the daily bar + closing NBBO snapshot the Greeks were calculated against. - Greeks
First Order Tick - First-order Greeks tick – the strict column subset emitted by the
vendor’s
option_*_greeks_first_orderendpoints (delta / theta / vega / rho / epsilon / lambda) plus the bid/ask quote pair, the IV pair, and the underlying snapshot used to derive each Greek. - Greeks
Result - All Greeks computed in a single struct.
- Greeks
Second Order Tick - Second-order Greeks tick – the strict column subset emitted by the
vendor’s
option_*_greeks_second_orderendpoints (gamma / vanna / charm / vomma / veta) plus the bid/ask quote pair, the IV pair, and the underlying snapshot. - Greeks
Third Order Tick - Third-order Greeks tick – the strict column subset emitted by the
vendor’s
option_*_greeks_third_orderendpoints (speed / zomma / color / ultima) plus the bid/ask quote pair, the IV pair, and the underlying snapshot. The vendor’s third-order schema does not publishvera. - Index
Price AtTime Tick - Index price-at-time tick – the trade-shaped row the v3 server
publishes on
index_at_time_price. The barePriceTick(3 fields:ms_of_day,price,date) silently dropped seven server-emitted columns –sequence,ext_condition1..4,condition,size,exchange– including the SIP-exchange attribution field. - Interest
Rate Tick - Interest rate tick – 2 fields. End-of-day interest rate (percent).
- IvTick
- Implied volatility tick – 11 fields.
- Market
Value Tick - Market value tick – quoted bid/ask/price for a symbol.
- Ohlc
Tick - OHLC tick – 9 fields. Aggregated bar data including SIP-rule VWAP.
- Open
Interest Tick - Open interest tick – 3 fields.
- Option
Contract - Option contract – 4 fields. Contract specification.
- Param
Meta - Metadata for a single parameter.
- Price
- Fixed-point price with variable decimal precision.
- Price
Tick - Price tick – 3 fields. Generic price data point.
- Quote
Tick - Quote tick – 10 fields + midpoint. NBBO quote data.
- Subscription
Info - Subscription tier information captured at authentication time.
- Theta
Data DxClient - Unified
ThetaDataclient. - Trade
Greeks AllTick - Per-trade union Greeks tick – every Greek the v3 server publishes on
option_history_trade_greeks_all, paired with the trade-side execution columns (sequence,ext_condition1..4,condition,size,exchange,price) that identify which OPRA print each Greek was calculated against. - Trade
Greeks First Order Tick - Per-trade first-order Greeks tick (delta / theta / vega / rho / epsilon
/ lambda) paired with the trade-side execution columns identifying the
OPRA print each Greek was calculated against. Wire layout verified-live
against terminal jar build
202605221. - Trade
Greeks Implied Volatility Tick - Per-trade implied-volatility tick (single
implied_volatility+iv_errorpair, NOT the bid/mid/ask IV triple of the interval-sampledIvTick) paired with the trade-side execution columns identifying the OPRA print the IV was calculated against. Wire layout verified-live against terminal jar build202605221. - Trade
Greeks Second Order Tick - Per-trade second-order Greeks tick (gamma / vanna / charm / vomma /
veta) paired with the trade-side execution columns identifying the OPRA
print each Greek was calculated against. Wire layout verified-live
against terminal jar build
202605221. - Trade
Greeks Third Order Tick - Per-trade third-order Greeks tick (speed / zomma / color / ultima)
paired with the trade-side execution columns identifying the OPRA print
each Greek was calculated against. The vendor’s third-order schema does
not publish
vera. Wire layout verified-live against terminal jar build202605221. - Trade
Quote Tick - Combined trade + quote tick – 24 fields.
- Trade
Tick - Trade tick – 15 fields. Core unit of trade data.
Enums§
- Connection
Status - Current state of the streaming connection.
- Data
Type - Data field types returned in responses.
- Interval
- Wire string enum
Interval. - Param
Type - Parsed
Right - Parsed representation of the option
rightparameter. - Rate
Type - Wire string enum
RateType. - Remove
Reason - Disconnect reason codes.
- Request
Type - Wire string enum
RequestType. - Return
Type - Right
- Wire string enum
Right. - SecType
- Security type identifier.
- Stream
MsgType - Streaming message types for real-time data.
- Stream
Response Type - Streaming subscription response.
- Venue
- Wire string enum
Venue. - Version
- Wire string enum
Version.
Constants§
Statics§
Functions§
- all_
greeks - Compute all 23 Greeks at once with maximally shared intermediates.
- by_
category - All endpoints in a category.
- find
- Find an endpoint by its method name.
- implied_
volatility - Implied volatility solver using bisection. Returns
(iv, error)on success. - param_
type_ to_ json_ type - parse_
right - Parse a user-supplied
rightstring. - parse_
right_ strict - Parse a
rightthat must resolve to a single side (call or put).