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, FpssControl, FpssEvent};
use thetadatadx::fpss::protocol::Contract;
#[tokio::main]
async fn main() -> Result<(), thetadatadx::Error> {
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| {
match event {
FpssEvent::Data(FpssData::Trade { contract, price, size, .. }) => {
println!("Trade: {} @ {price} x {size}", contract.symbol);
}
_ => {}
}
})?;
tdx.subscribe(Contract::stock("AAPL").quote())?;
// ... when done:
tdx.stop_streaming();
Ok(())
}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::FpssFlushMode;pub use config::ReconnectPolicy;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 surface: whole-universe daily snapshots over the legacy MDDS port.
- fpss
- FPSS (Feed Processing Streaming Server) real-time streaming client.
- frames
polarsorarrow - DataFrame ergonomics for Rust consumers —
.to_polars()/.to_arrow()extension traits on slices of tick rows. - mdds
- MDDS (Market Data Distribution Server) gRPC client.
- observability
- Optional Prometheus exporter for the
metricscrate recorders. - prelude
- Convenience prelude for the fluent contract-first API.
- 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
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. - Interest
Rate Tick - Interest rate tick – 3 fields. End-of-day interest rate.
- IvTick
- Implied volatility tick – 4 fields.
- Market
Value Tick - Market value tick – quoted bid/ask/price for a symbol.
- Ohlc
Tick - OHLC tick – 8 fields. Aggregated bar data.
- 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
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).