Skip to content

Historical Data

ThetaDataDx provides a generated historical data surface across five asset categories. All historical data is accessed through the unified ThetaDataDxClient, which communicates over gRPC with ThetaData's MDDS servers. gRPC, protobuf parsing, zstd decompression, and FIT decoding run inside the thetadatadx Rust crate, regardless of which language binding you call.

Connecting

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());

Endpoint Categories

CategoryEndpointsPage
Stocks14 endpoints - list, snapshots, history, at-time, streamingStock Endpoints
Options34 endpoints - list, snapshots, history, Greeks, trade Greeks, at-timeOption Endpoints
Indices9 endpoints - list, snapshots, history, at-timeIndex Endpoints
Calendar3 endpoints - trading schedule, holidays, early closesCalendar
Rates1 endpoint - interest rate EOD historyRates

Date Format

All dates are YYYYMMDD strings: "20240315" for March 15, 2024.

Interval Format

Intervals are millisecond strings: "60000" for 1 minute, "300000" for 5 minutes, "3600000" for 1 hour.

DataFrame Support (Python)

Every historical method returns a typed list wrapper (EodTickList, OhlcTickList, StringList, ...). Chain .to_polars() / .to_pandas() / .to_arrow() / .to_list() on the return value for the matching representation:

python
df  = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_polars()
pdf = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_pandas()
tbl = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_arrow()
lst = tdx.stock_history_eod("AAPL", "20240101", "20240301").to_list()

The list wrapper itself behaves like a Python sequence (len(ticks), ticks[i], for t in ticks:), so most callers skip the terminal entirely.

Requires pip install thetadatadx[pandas] or [polars] / [arrow] depending on the terminal.

Time Reference

Time (ET)time_of_day
9:30 AM09:30:00.000
12:00 PM12:00:00.000
4:00 PM16:00:00.000

Empty Responses

When a query returns no data (e.g., a non-trading date), the SDK returns an empty collection rather than an error. Check for emptiness using the appropriate idiom for your language:

rust
if eod.is_empty() {
    println!("No data for this date range");
}
python
if not eod:
    print("No data for this date range")
typescript
if (eod.length === 0) {
    console.log('No data for this date range');
}
cpp
if (eod.empty()) {
    std::cout << "No data for this date range" << std::endl;
}

Released under the Apache-2.0 License.