Skip to content

option_history_ohlc

FreeValueStandardPro

Retrieve intraday OHLC bars for an option contract on a given date at a specified interval.

Code Example

rust
let data = tdx.option_history_ohlc("SPY", "20260417", "550", "C", "20260315", "60000").await?;
for t in &data {
    println!("date={} ms_of_day={} open={:.2} high={:.2} low={:.2} close={:.2} volume={} count={}",
        t.date, t.ms_of_day, t.open, t.high, t.low, t.close, t.volume, t.count);
}
python
data = tdx.option_history_ohlc("SPY", "20260417", "550", "C", "20260315", "60000")
for t in data:
    print(f"date={t.date} ms_of_day={t.ms_of_day} open={t.open:.2f} high={t.high:.2f} "
          f"low={t.low:.2f} close={t.close:.2f} volume={t.volume} count={t.count}")
typescript
const data = tdx.optionHistoryOHLC('SPY', '20260417', '550', 'C', '20260315', '60000');
for (const t of data) {
    console.log(`date=${t.date} ms_of_day=${t.ms_of_day} open=${t.open} high=${t.high} low=${t.low} close=${t.close}`);
}
cpp
auto data = client.option_history_ohlc("SPY", "20260417", "550", "C", "20260315", "60000");
for (const auto& t : data) {
    printf("date=%d ms_of_day=%d open=%.2f high=%.2f low=%.2f close=%.2f volume=%d count=%d\n",
        t.date, t.ms_of_day, t.open, t.high, t.low, t.close, t.volume, t.count);
}

Parameters

symbolstringrequired
Underlying symbol
expirationstringrequired
Expiration date in YYYYMMDD format
strikestringrequired
Strike price in dollars as a string
rightstringrequired
"C" for call, "P" for put
datestringrequired
Date in YYYYMMDD format
intervalstringrequired
Accepts milliseconds ("60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.
start_timestringoptional
Start time as milliseconds from midnight
end_timestringoptional
End time as milliseconds from midnight
strike_rangeintoptional
Strike range filter

Response

openfloat
Opening price
highfloat
High price
lowfloat
Low price
closefloat
Closing price
volumeint
Volume in interval
countint
Number of trades
datestring
Date
ms_of_dayint
Milliseconds from midnight

Sample Response

json
[
  {"date": 20260402, "ms_of_day": 34200000, "open": 98.59, "high": 98.59, "low": 98.59, "close": 98.59, "volume": 1, "count": 1},
  {"date": 20260402, "ms_of_day": 34260000, "open": 0.00, "high": 0.00, "low": 0.00, "close": 0.00, "volume": 0, "count": 0},
  {"date": 20260402, "ms_of_day": 34320000, "open": 0.00, "high": 0.00, "low": 0.00, "close": 0.00, "volume": 0, "count": 0}
]

1-minute OHLC bars for SPY 2026-04-17 550 call. Deep ITM options are illiquid -- most bars show zero volume.

Notes

  • Shorthand is supported: "1m", "5m", "15m", "1h". Milliseconds ("60000", "300000", "900000", "3600000") are auto-converted to the nearest valid preset.

Released under the Apache-2.0 License.