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 bars: Vec<OhlcTick> = tdx.index_history_ohlc(
    "SPX", "20240101", "20240301", "60000"  // 1-minute bars
).await?;
for bar in &bars {
    println!("{} {}: O={} H={} L={} C={}",
        bar.date, bar.ms_of_day, bar.open_price(), bar.high_price(),
        bar.low_price(), bar.close_price());
}
python
bars = tdx.index_history_ohlc("SPX", "20240101", "20240301", "60000")
print(f"{len(bars)} 1-minute bars")

# 5-minute bars
bars_5m = tdx.index_history_ohlc("SPX", "20240101", "20240301", "300000")
go
bars, err := client.IndexHistoryOHLC("SPX", "20240101", "20240301", "60000")
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%d bars\n", len(bars))
cpp
auto bars = client.index_history_ohlc("SPX", "20240101", "20240301", "60000");
for (auto& bar : bars) {
    std::cout << bar.date << " " << bar.ms_of_day
              << ": O=" << bar.open << " C=" << bar.close << std::endl;
}

Parameters

symbolstringrequired
Index symbol (e.g. "SPX")
start_datestringrequired
Start date in YYYYMMDD format
end_datestringrequired
End date in YYYYMMDD format
intervalstringrequired
Bar interval in milliseconds (e.g. "60000" for 1-minute)
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

Notes

  • Common intervals: "60000" (1 min), "300000" (5 min), "900000" (15 min), "3600000" (1 hour).
  • 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 GPL-3.0-or-later License.