index_snapshot_ohlc
FreeValueStandardPro
Get the latest OHLC (open, high, low, close) snapshot for one or more index symbols. Returns the most recent bar data.
Code Example
rust
let bars: Vec<OhlcTick> = tdx.index_snapshot_ohlc(&["SPX", "VIX"]).await?;
for bar in &bars {
println!("O={} H={} L={} C={}", bar.open_price(), bar.high_price(), bar.low_price(), bar.close_price());
}python
bars = tdx.index_snapshot_ohlc(["SPX", "VIX"])
for bar in bars:
print(f"O={bar['open']:.2f} H={bar['high']:.2f} L={bar['low']:.2f} C={bar['close']:.2f}")go
bars, err := client.IndexSnapshotOHLC([]string{"SPX", "VIX"})
if err != nil {
log.Fatal(err)
}
for _, bar := range bars {
fmt.Printf("O=%.2f H=%.2f L=%.2f C=%.2f\n", bar.Open, bar.High, bar.Low, bar.Close)
}cpp
auto bars = client.index_snapshot_ohlc({"SPX", "VIX"});
for (auto& bar : bars) {
std::cout << "O=" << bar.open << " H=" << bar.high
<< " L=" << bar.low << " C=" << bar.close << std::endl;
}Parameters
symbolsstring[]requiredOne or more index symbols
min_timestringoptionalMinimum 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
- Pass multiple symbols in a single call to batch requests efficiently.
- During market hours, the snapshot reflects the current partial bar.