Skip to content

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[]required
One or more index symbols
min_timestringoptional
Minimum 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

  • Pass multiple symbols in a single call to batch requests efficiently.
  • During market hours, the snapshot reflects the current partial bar.

Released under the GPL-3.0-or-later License.