Works with ChatGPT

Turn a ChatGPT prompt into a working options pull.

Copy-paste prompts, Python, and REST snippets for pulling live and historical stocks, options, and index data with Theta Data — written for how people actually use ChatGPT, not a generic tutorial.

No credit card required · free tier included · options, stocks, indices & rates
ChatGPT
You
Using the Theta Data Python library, write code to pull 1-minute OHLC bars for AAPL on Jan 2, 2024, market hours only (9:30–16:00 ET), as a pandas DataFrame.
ChatGPT
Here's a complete script using ThetaClient:
from datetime import date, time
from thetadata import ThetaClient

client = ThetaClient(dataframe_type="pandas")
bars = client.stock_history_ohlc(
    symbol="AAPL",
    date=date(2024, 1, 2),
    interval="1m",
    start_time=time(9, 30),
    end_time=time(16, 0),
)
print(bars.head())

Before you prompt

ChatGPT writes better Theta Data code when you give it less room to guess.

It hasn't necessarily seen our latest SDK release. These three habits fix almost every hallucinated method name or made-up parameter.

01 Name the interface

Tell it you're using the Theta Data Python library (or the REST API directly) — not a generic finance package. That one line rules out invented method names.

02 Anchor to a known-good call

Paste one working example before you ask for a new one. Models pattern-match much better against real code than a blank prompt.

03 Validate before you trust it

Ask it to print row counts, date ranges, and columns. Treat the first draft as a draft — not verified production code.

Copy, paste, run

Everything you need, in the format you'll actually use.

Prompts to paste into ChatGPT, plus the Python, SDK, notebook, and REST snippets it should produce — pre-verified against the current library.

Quick-start template

Using the current Theta Data Python library from PyPI, write complete, executable Python code to [describe the task]. Use [symbol(s)], [date/time range], [interval], and [required fields]. Return the result as a pandas DataFrame and [save / plot / transform it]. Use only officially supported methods, state your authentication assumptions, handle AuthenticationError and NoDataFoundError, validate the returned schema, avoid pseudo-code, and explain each section.

Anchor to a known-good call

Here is a known-good request using the Theta Data Python library: client.stock_history_eod(symbol="AAPL", start_date=date(2024,1,2), end_date=date(2024,1,5)) It returns a DataFrame with columns created, last_trade, open, high, low, close, volume (plus bid/ask fields). Using this exact pattern, write a call that pulls 5-minute OHLC bars for TSLA over the same date range.

Add error handling

Add explicit handling for AuthenticationError and NoDataFoundError (both from thetadata.errors) to the function below, without changing its return type or output columns: [paste your function]

Explain, then simplify

Explain what each section of this script does line by line, then rewrite it in the simplest possible form while keeping the same behavior and output columns: [paste your script]

Paste any of these into a ChatGPT chat or Project.

Going further

Grounding ChatGPT in the real spec

Two ways to cut hallucinations to nearly zero, in order of effort.

Feed it the OpenAPI spec

Upload openapiv3.yaml (from docs.thetadata.us) into a ChatGPT Project or paste relevant sections into the chat. It becomes the source of truth ChatGPT checks method names and parameters against, instead of guessing from training data.

Developer Mode connectors (advanced)

ChatGPT's Developer Mode can call an MCP server directly — but Theta Data's MCP server lives on 127.0.0.1, on your machine, so cloud ChatGPT can't reach it without a tunnel (e.g. ngrok) exposing it publicly. If you want a natural-language connection with zero extra setup, Claude Code and Gemini CLI connect to it directly since they run on your machine too.

Rule of thumb: use ChatGPT to write the code, then run it yourself in Jupyter, a script, or your existing pipeline. That's the workflow every snippet above is built for.

Every strategy is only as good as its data.

Free tier available — no credit card to start pulling data.