Interactive Jupyter notebooks demonstrating the thetadatadx Python SDK. Each notebook is self-contained and progresses from basics to advanced real-time streaming.
FLATFILES coverage: the existing notebooks cover the MDDS (historical) and FPSS (streaming) surfaces. A FLATFILES notebook walking through whole-universe daily blobs is tracked alongside the Python binding work — see issue #435 and the per-binding flat-file demos issue #445. Once the Python binding ships flat-file methods, a
notebooks/flat-files/directory will land here.
pip install thetadatadx[all] jupyter matplotlibThe [all] extra installs both pandas and polars support. If you only need one:
pip install thetadatadx[pandas] jupyter matplotlibNotebook 106 additionally requires ipywidgets:
pip install ipywidgetsAll notebooks expect ThetaData credentials. Create a creds.txt file in this directory (or wherever you run Jupyter from) with your ThetaData email on line 1 and password on line 2:
your-email@example.com
your-password
This file is loaded by Credentials.from_file("creds.txt") in each notebook. Alternatively, you can pass credentials inline:
from thetadatadx import Credentials
creds = Credentials("your-email@example.com", "your-password")Do not commit creds.txt to version control. It is already in .gitignore.
| # | Notebook | Description |
|---|---|---|
| 101 | Getting Started | Connect, list symbols, EOD data, OHLC bars, option expirations/strikes, Greeks calculator |
| 102 | Historical Analysis | Price charts, daily returns distribution, intraday volume, bid-ask spreads, multi-symbol comparison |
| 103 | Options Chain | Build a full option chain DataFrame, implied volatility smile, open interest visualization |
| 104 | Greeks Surface | 3D volatility surface, delta/gamma/theta heatmaps, time decay analysis |
| 105 | Real-Time Streaming | FPSS quote and trade subscriptions, event collection, trade flow summary |
| 106 | Live Option Chain | In-notebook interactive chain with ipywidgets, auto-refresh, IV smile and term structure plots |
| 107 | Full Trade Stream | Stock + option trade firehose, block detector, momentum analysis, premium flow dashboard |
The entry point. Covers installation, authentication, and a tour of the core API surface:
- Install
thetadatadxwith pandas support - Create
Credentialsand connect aThetaDataDxclient to production servers - List all available stock symbols
- Fetch AAPL end-of-day data and convert to a pandas DataFrame
- Fetch 1-minute OHLC bars for a single trading day
- List SPY option expirations and strikes
- Compute all 22 Greeks (including IV) with the built-in Rust Black-Scholes calculator
Quantitative analysis patterns using historical data:
- Full-year AAPL EOD price chart
- Log return distribution with histogram
- Intraday trade volume distribution across the trading session
- NBBO quote data: bid-ask spread analysis over the day
- Multi-symbol comparison (AAPL, MSFT, GOOGL)
Build a complete option chain from scratch:
- List all expirations for SPY
- Identify the nearest monthly expiration (third Friday, 14+ DTE)
- Fetch all strikes for that expiration
- Pull snapshot NBBO quotes for every call and put
- Assemble the unified option chain DataFrame
- Compute and plot the implied volatility smile
- Visualize open interest across strikes
Three-dimensional visualization of the options Greeks:
- Fetch 6 expirations spanning near-term to several months out
- Compute full Greeks across all expirations and strikes
- Build the IV surface (strike x expiration x IV)
- 3D surface plot of implied volatility
- Delta, gamma, theta heatmaps across the surface
- Time decay analysis: theta acceleration as expiration approaches
Introduction to the FPSS (Fast Push Streaming Service) client:
- Start streaming via
ThetaDataDx(persistent TCP connection) - Subscribe to AAPL quote updates
- Collect quote events over a 10-second window
- Display quote updates in a table
- Subscribe to AAPL trades
- Trade flow summary
- Clean unsubscribe and shutdown
Note: FPSS streaming requires real-time data access in your ThetaData subscription. Data is only available during market hours (9:30 AM - 4:00 PM ET).
A fully interactive, live-updating option chain rendered inside the notebook:
- Dropdown expiration selector
- Full chain with Greeks computed via the Rust Black-Scholes calculator
- ITM/ATM color coding
- One-click and auto-refresh modes
- IV smile plot and multi-expiration term structure visualization
Requires ipywidgets. For a richer standalone GUI with tabbed expirations and configurable display, see the Streamlit live-chain app.
Advanced real-time trade analysis covering the full firehose:
- Connect and authenticate
- Subscribe to stock trade streams for a watchlist of symbols
- Real-time analysis: volume by symbol, large block detection, price momentum, buy/sell imbalance
- Subscribe to option trades per-contract (underlying, expiration, strike, right)
- Combined stock + option dashboard with live-updating summary
The Rust core decodes FIT payloads and delta-decompresses ticks before they reach Python. Each event dict has named fields (price, size, exchange, condition, ms_of_day, etc.) - no raw payload handling required.
Start Jupyter from the repository root or this directory:
cd notebooks
jupyter notebookOr with JupyterLab:
jupyter labOpen notebook 101 first and work through them in order. Each notebook links to the next at the bottom.