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
symbolstringrequiredIndex symbol (e.g.
"SPX")start_datestringrequiredStart date in
YYYYMMDD formatend_datestringrequiredEnd date in
YYYYMMDD formatintervalstringrequiredBar interval in milliseconds (e.g.
"60000" for 1-minute)start_timestringoptionalStart time of day as milliseconds from midnight
end_timestringoptionalEnd time of day as milliseconds from midnight
Response
openf64Opening price
highf64High price
lowf64Low price
closef64Closing price
volumeu64Volume
countu32Number of trades in bar
ms_of_dayu32Milliseconds from midnight ET
dateu32Date as
YYYYMMDD integerNotes
- Common intervals:
"60000"(1 min),"300000"(5 min),"900000"(15 min),"3600000"(1 hour). - Use
start_timeandend_timeto 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.