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 ThetaDataDx, which authenticates once and
provides both historical and streaming through a single object:
use thetadatadx::{ThetaDataDx, 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 = ThetaDataDx::connect(&creds, DirectConfig::production()).await?;
// Historical (MDDS gRPC) -- all 61 methods 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_id, price, size, .. }) => {
println!("Trade: {contract_id} @ {price} x {size}");
}
_ => {}
}
})?;
tdx.subscribe_quotes(&Contract::stock("AAPL"))?;
// ... when done:
tdx.stop_streaming();
Ok(())
}For historical-only usage, just skip start_streaming() – all 61 historical
methods are available directly on ThetaDataDx via Deref<Target = MddsClient>:
use thetadatadx::{ThetaDataDx, Credentials, DirectConfig};
let creds = Credentials::from_file("creds.txt")?;
// Or inline: let creds = Credentials::new("user@example.com", "your-password");
let tdx = ThetaDataDx::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 auth::Credentials;pub use config::DirectConfig;pub use config::FpssFlushMode;pub use config::ReconnectPolicy;pub use endpoint::EndpointArgValue;pub use endpoint::EndpointArgs;pub use endpoint::EndpointError;pub use endpoint::EndpointOutput;pub use error::AuthErrorKind;pub use error::Error;pub use error::FpssErrorKind;pub use mdds::MddsClient;pub use registry::EndpointMeta;pub use registry::ParamMeta;pub use registry::ParamType;pub use registry::ReturnType;pub use registry::ENDPOINTS;pub use unified::ConnectionStatus;pub use unified::SubscriptionInfo;pub use unified::ThetaDataDx;pub use prost;
Modules§
- auth
- Authentication for
ThetaDatadirect server access. - config
- Server configuration for direct
ThetaDataaccess. - decode
- endpoint
- Shared endpoint invocation runtime for
thetadatadx. - error
- fpss
- FPSS (Feed Processing Streaming Server) real-time streaming client.
- mdds
- MDDS (Market Data Distribution Server) gRPC client.
- observability
- Optional Prometheus exporter for the
metricscrate recorders. - proto
- Generated protobuf types from
mdds.proto(packageBetaEndpoints). - registry
- Endpoint registry – single source of truth for all
MddsClientendpoints. - right
- Canonical parser for the option
rightparameter. - unified
- Unified
ThetaDataclient – single entry point, one auth, lazy FPSS.
Structs§
- Greeks
Result - All Greeks computed in a single struct.
Enums§
- Parsed
Right - Parsed representation of the option
rightparameter.
Functions§
- all_
greeks - Compute all 22 Greeks at once with maximally shared intermediates.
- implied_
volatility - Implied volatility solver using bisection. Returns
(iv, error). - parse_
right - Parse a user-supplied
rightstring. - parse_
right_ strict - Parse a
rightthat must resolve to a single side (call or put).