Skip to content

stock_snapshot_ohlc

Latest OHLC (open-high-low-close) snapshot for one or more stocks. Returns the current or most recent trading session's aggregated bar.

FreeValueStandardPro

Code Example

rust
let bars: Vec<OhlcTick> = tdx.stock_snapshot_ohlc(&["AAPL", "MSFT"]).await?;
for bar in &bars {
    println!("O={} H={} L={} C={} V={}",
        bar.open_price(), bar.high_price(),
        bar.low_price(), bar.close_price(), bar.volume);
}
python
bars = tdx.stock_snapshot_ohlc(["AAPL", "MSFT"])
for bar in bars:
    print(f"O={bar['open']:.2f} H={bar['high']:.2f} "
          f"L={bar['low']:.2f} C={bar['close']:.2f}")
go
bars, err := client.StockSnapshotOHLC([]string{"AAPL", "MSFT"})
if err != nil {
    log.Fatal(err)
}
for _, bar := range bars {
    fmt.Printf("O=%.2f H=%.2f L=%.2f C=%.2f V=%d\n",
        bar.Open, bar.High, bar.Low, bar.Close, bar.Volume)
}
cpp
auto bars = client.stock_snapshot_ohlc({"AAPL", "MSFT"});
for (auto& bar : bars) {
    std::cout << "O=" << bar.open << " H=" << bar.high
              << " L=" << bar.low << " C=" << bar.close
              << " V=" << bar.volume << std::endl;
}

Parameters

symbolsstring[]required
One or more ticker symbols
venuestringoptional
Data venue filter
min_timestringoptional
Minimum time of day as milliseconds from midnight ET

Response Fields (OhlcTick)

ms_of_dayi32
Bar start time (milliseconds from midnight ET)
open / high / low / closei32
Fixed-point OHLC prices. Use open_price(), high_price(), low_price(), close_price() for decoded values.
volumei32
Total volume in the bar
counti32
Number of trades in the bar
price_typei32
Decimal type for price decoding
datei32
Date as YYYYMMDD integer

Notes

  • Accepts multiple symbols in a single call. Batch requests to reduce round-trips.
  • Prices are stored as fixed-point integers. Use the helper methods to get decoded float values.

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