Skip to content

index_history_ohlc

FreeValueStandardPro

Retrieve intraday OHLC bars for an index across a date range at a specified interval.

Code Example

rust
let data = tdx.index_history_ohlc("SPX", "20260101", "20260301", "60000").await?;
for t in &data {
    println!("date={} ms_of_day={} open={:.2} high={:.2} low={:.2} close={:.2}",
        t.date, t.ms_of_day, t.open, t.high, t.low, t.close);
}
python
data = tdx.index_history_ohlc("SPX", "20260101", "20260301", "60000")
for t in data:
    print(f"date={t.date} ms_of_day={t.ms_of_day} open={t.open:.2f} "
          f"high={t.high:.2f} low={t.low:.2f} close={t.close:.2f}")
typescript
const data = tdx.indexHistoryOHLC('SPX', '20260101', '20260301', '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.index_history_ohlc("SPX", "20260101", "20260301", "60000");
for (const auto& t : data) {
    printf("date=%d ms_of_day=%d open=%.2f high=%.2f low=%.2f close=%.2f\n",
        t.date, t.ms_of_day, t.open, t.high, t.low, t.close);
}

Parameters

symbolstringrequired
Index symbol (e.g. "SPX")
start_datestringrequired
Start date in YYYYMMDD format
end_datestringrequired
End 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 of day as milliseconds from midnight
end_timestringoptional
End time of day as milliseconds from midnight

Response

openf64
Opening price
highf64
High price
lowf64
Low price
closef64
Closing price
volumeu64
Volume
countu32
Number of trades in bar
ms_of_dayu32
Milliseconds from midnight ET
dateu32
Date as YYYYMMDD integer

Sample Response

json
[
  {"date": 20260402, "ms_of_day": 34200000, "open": 6820.51, "high": 6825.40, "low": 6815.23, "close": 6823.18},
  {"date": 20260402, "ms_of_day": 34260000, "open": 6823.18, "high": 6830.55, "low": 6820.12, "close": 6828.42},
  {"date": 20260402, "ms_of_day": 34320000, "open": 6828.42, "high": 6835.67, "low": 6826.09, "close": 6834.15}
]

SPX 1-minute OHLC bars. Requires Standard subscription.

Notes

  • Shorthand is supported: "1m", "5m", "15m", "1h". Milliseconds ("60000", "300000", "900000", "3600000") are auto-converted to the nearest valid preset.
  • Use start_time and end_time to filter to regular trading hours only (e.g. "34200000" to "57600000" for 9:30 AM to 4:00 PM ET).
  • For end-of-day data only, use index_history_eod instead.

Released under the Apache-2.0 License.