Skip to main content

No-JVM ThetaData Terminal — native Rust SDK for direct market data access (Python bindings)

Project description

thetadatadx (Python)

Python SDK for ThetaData market data, powered by the thetadatadx Rust crate via PyO3.

This is NOT a Python reimplementation. Every call goes through compiled Rust — gRPC communication, protobuf parsing, zstd decompression, FIT tick decoding, and TCP streaming all happen at native speed. Python is just the interface.

Installation

pip install thetadatadx

# With pandas DataFrame support
pip install thetadatadx[pandas]

Or build from source (requires Rust toolchain):

pip install maturin
maturin develop --release

Quick Start

from thetadatadx import Credentials, Config, DirectClient

# Authenticate and connect
creds = Credentials.from_file("creds.txt")
client = DirectClient(creds, Config.production())

# Fetch end-of-day data
eod = client.stock_history_eod("AAPL", "20240101", "20240301")
for tick in eod:
    print(f"{tick['date']}: O={tick['open']:.2f} H={tick['high']:.2f} "
          f"L={tick['low']:.2f} C={tick['close']:.2f} V={tick['volume']}")

# Intraday 1-minute OHLC bars
bars = client.stock_history_ohlc("AAPL", "20240315", "60000")
print(f"{len(bars)} bars")

# Option chain
exps = client.option_list_expirations("SPY")
strikes = client.option_list_strikes("SPY", exps[0])

Greeks Calculator

Full Black-Scholes calculator with 22 Greeks, running in Rust:

from thetadatadx import all_greeks, implied_volatility

# All Greeks at once
g = all_greeks(
    spot=450.0, strike=455.0, rate=0.05, div_yield=0.015,
    tte=30/365, option_price=8.50, is_call=True
)
print(f"IV={g['iv']:.4f} Delta={g['delta']:.4f} Gamma={g['gamma']:.6f}")

# Just IV
iv, err = implied_volatility(450.0, 455.0, 0.05, 0.015, 30/365, 8.50, True)

API

Credentials

  • Credentials(email, password) — direct construction
  • Credentials.from_file(path) — load from creds.txt

Config

  • Config.production() — ThetaData NJ production servers
  • Config.dev() — dev servers with shorter timeouts

DirectClient(creds, config)

All methods return lists of dicts.

Method Description
stock_list_symbols() All stock symbols
stock_history_eod(symbol, start, end) EOD data
stock_history_ohlc(symbol, date, interval) Intraday OHLC
stock_history_trade(symbol, date) All trades
stock_history_quote(symbol, date, interval) NBBO quotes
stock_snapshot_quote(symbols) Live quote snapshot
option_list_expirations(symbol) Expiration dates
option_list_strikes(symbol, exp) Strike prices
option_list_symbols() Option underlyings
index_list_symbols() Index symbols

FpssClient(creds, buffer_size=1024)

Real-time streaming client.

Method Description
subscribe(symbol, data_type) Subscribe to a stream ("QUOTE", "TRADE", "OI")
next_event(timeout_ms=5000) Poll for the next event (returns dict or None on timeout)
shutdown() Graceful shutdown

to_dataframe(data)

Convert a list of tick dicts to a pandas DataFrame. Requires pip install thetadatadx[pandas].

_df method variants

All DirectClient data methods have _df variants that return DataFrames directly: stock_history_eod_df(), stock_history_ohlc_df(), stock_history_trade_df(), etc.

all_greeks(spot, strike, rate, div_yield, tte, price, is_call)

Returns dict with 22 Greeks: delta, gamma, theta, vega, rho, iv, vanna, charm, vomma, veta, speed, zomma, color, ultima, d1, d2, dual_delta, dual_gamma, epsilon, lambda.

implied_volatility(spot, strike, rate, div_yield, tte, price, is_call)

Returns (iv, error) tuple.

Architecture

Python code
    │  (PyO3 FFI)
    ▼
thetadatadx Rust crate
    │  (tonic gRPC / tokio TCP)
    ▼
ThetaData servers

No HTTP middleware, no Java terminal, no subprocess. Direct wire protocol access at Rust speed.

FPSS Streaming

Real-time market data via ThetaData's FPSS servers:

from thetadatadx import Credentials, FpssClient

creds = Credentials.from_file("creds.txt")
fpss = FpssClient(creds, buffer_size=1024)

# Subscribe to real-time quotes
fpss.subscribe("AAPL", "QUOTE")
fpss.subscribe("SPY", "TRADE")

# Poll for events
while True:
    event = fpss.next_event(timeout_ms=5000)
    if event is None:
        break  # timeout, no event received
    if event["type"] == "quote":
        print(f"Quote: {event['contract']} bid={event['bid']} ask={event['ask']}")
    elif event["type"] == "trade":
        print(f"Trade: {event['contract']} price={event['price']} size={event['size']}")

fpss.shutdown()

pandas DataFrame Conversion

Convert any result to a pandas DataFrame:

from thetadatadx import Credentials, Config, DirectClient, to_dataframe

creds = Credentials.from_file("creds.txt")
client = DirectClient(creds, Config.production())

# Option 1: convert an existing result
eod = client.stock_history_eod("AAPL", "20240101", "20240301")
df = to_dataframe(eod)
print(df.head())

# Option 2: use _df convenience methods
df = client.stock_history_eod_df("AAPL", "20240101", "20240301")
df = client.stock_history_ohlc_df("AAPL", "20240315", "60000")
df = client.option_list_expirations_df("SPY")

Install with: pip install thetadatadx[pandas]

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thetadatadx-1.2.3.tar.gz (116.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

thetadatadx-1.2.3-cp313-cp313-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.13Windows x86-64

thetadatadx-1.2.3-cp313-cp313-manylinux_2_38_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

thetadatadx-1.2.3-cp313-cp313-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

thetadatadx-1.2.3-cp312-cp312-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.12Windows x86-64

thetadatadx-1.2.3-cp312-cp312-manylinux_2_38_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

thetadatadx-1.2.3-cp312-cp312-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

thetadatadx-1.2.3-cp311-cp311-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.11Windows x86-64

thetadatadx-1.2.3-cp311-cp311-manylinux_2_38_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

thetadatadx-1.2.3-cp311-cp311-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

thetadatadx-1.2.3-cp310-cp310-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.10Windows x86-64

thetadatadx-1.2.3-cp310-cp310-manylinux_2_38_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

thetadatadx-1.2.3-cp310-cp310-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

thetadatadx-1.2.3-cp39-cp39-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.9Windows x86-64

thetadatadx-1.2.3-cp39-cp39-manylinux_2_38_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.38+ x86-64

thetadatadx-1.2.3-cp39-cp39-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file thetadatadx-1.2.3.tar.gz.

File metadata

  • Download URL: thetadatadx-1.2.3.tar.gz
  • Upload date:
  • Size: 116.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for thetadatadx-1.2.3.tar.gz
Algorithm Hash digest
SHA256 daedbd00b0af1449b87bc3ef26afd01509481526b476cb8c6a88856b1ec73d10
MD5 5fd836e900a731f185bbd504b6fa0557
BLAKE2b-256 ab916145c53143414731f744fc50a04de8584bd40bcc7fd721697f8910868629

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cf425847eb7cb2bfcf41b805033c4575d003ca4301eb2117fb73bebe59573227
MD5 a88712eaf556a36b80eff02fece4671e
BLAKE2b-256 8a060013176c9d85e034f29a1a8bf7dde57817e7499c4bed2b5faffac5c80b24

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 0733201d2a6df3ff590c4ac52dd3320b461d8390bd915ac91daf1c39ceb74f31
MD5 89fd1fe5cfc65307ded5f453182ba52a
BLAKE2b-256 af9341a791106d1b5a0752277010ea5b13a53c21a0dec2af789682d53ecac11d

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30d731ff250f8e48c44119a8fbe0d676fd7438192a9e4cce6f9e648a33d2b707
MD5 b1e7a2464789c5f4bfc70efaed31868f
BLAKE2b-256 654b3efda4d43fa0228be5f70e736f9c9b59c38134a95e1acd694ac49b09ed24

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 601f54b2b090586eb93e87869aac134b1e02dace15efba6fb1a9e1da9d74aa9d
MD5 23fcd0961f00b342d9ec3c3aef00d9d4
BLAKE2b-256 8ee7204f9694741f4e3e2a83402273fccbdfbc141525c5d51e78415fc8f38d52

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 3622460b62cdd43c66421b0959d9f83c184c8a2c0ea14fd538d27ffc8a3e1ca7
MD5 3d68b3ca6f20078786b18ff5077f8a3d
BLAKE2b-256 7ac235fe5ea33376ddd6caaf6192defd8586b5890b457fb405f0b4c0ec96e73e

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 60ed7cc77da624f6c2188fadc2d8789bd5f2f2e10ca35a8f641814cca71cd8d1
MD5 a59b81143f0f295f14f3002289ad8d48
BLAKE2b-256 81654f8aa419f96d35397826e2f0013d2d9e54caad6f4a55c6416b0842ebcca9

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bd36897ddd0e4df5e84e280a5f8859916755986b5e6c6ea2688801f4a2658ea6
MD5 0bb5f1020ffae144b1215453d46ec73a
BLAKE2b-256 bd14dec5107b01d8f3d14e73d915866bed35e6e26e933cf33833e03b7fa7f9bc

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 9a62bf551d6a633f161c568ccff5ca776f5897022f063c56f33f96d8cd73f34a
MD5 88a936c25c6d7259f06f8440dbfd361b
BLAKE2b-256 154e4afc07103601e162a225e88b6d95e60f0b613970739bf75f092922480671

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9806b9ca68c9354786d5224cd0328424f31f5d700c9b19e6050c4fe9f9b1a6c
MD5 71bcfc7a331a11903ccc82b7d83c0650
BLAKE2b-256 02227781ccae749e0a69045b0cd28f7f589a2e8bf98acf04086a876d1b08ff78

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bedad6c8fea442f5480bbcfec0546c9a6be15acafb2c5b4892e029e1e2abd75a
MD5 eee5131d5e9c3db2b568df439461d30d
BLAKE2b-256 506426a6e0fe14c19f0fbb97e5b5049992f8b88d4f38afdd498d9b55b5110bb8

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 5eb18d39e0014b91ed77652090fe85a5ed69e1b08e1a3e093b646aa7559854b7
MD5 e24651ef49f5a75497cdc4f5c55e9979
BLAKE2b-256 db4f42cdf3b2a1dab7626c2b896fb4b1a917c03d9f1278c4796889f0a49a733f

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5c19e40005b9ca1913b29f76f09994311a5df5e605c2ec19e5a38a7423d27da
MD5 38ba6b983ab874169d5366252aa83fb9
BLAKE2b-256 81999c0305202da084177a3e7f15ac67a1518193d3664e292c4aa514989369d7

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: thetadatadx-1.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for thetadatadx-1.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4bbde5fa8c81d88cc428ee9f0aca7eb9edcd5f946f2c00ec9619d2b20ead7e27
MD5 1e232983c1cd0ad7ee548c863bbef065
BLAKE2b-256 ce5b7bff5632956e201e396f8b607b92601aa8423e6bc7e610a4f48f1f723179

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp39-cp39-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp39-cp39-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 e949c249ee3de53618066f82ea5c1bd04f3c5f1285321f8fb88ff2496de723a9
MD5 fe84d4208ac664b56725815102bebf73
BLAKE2b-256 c1255cbdfbc1ae7f1442c1c7cacbb37baa8e77556218dffd27b4b6c6635aa9f3

See more details on using hashes here.

File details

Details for the file thetadatadx-1.2.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thetadatadx-1.2.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e289e7817c27c816182a88197ea33039628aa0f11cb95b4be08121c6a408418
MD5 dced27755dda2675ee05e938bc96fa54
BLAKE2b-256 a38ddc45c1aec83f3c4139de9bbd346bec9973e0d26ff0a1243a217b6c9be6e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page