Skip to content

stock_history_ohlc / stock_history_ohlc_range

Intraday OHLC bars at a configurable interval. Two variants are available:

  • stock_history_ohlc - bars for a single date
  • stock_history_ohlc_range - bars across a date range
FreeValueStandardPro

Code Example (Single Date)

rust
// 1-minute bars for a single date
let bars: Vec<OhlcTick> = tdx.stock_history_ohlc("AAPL", "20240315", "60000").await?;
println!("{} bars", bars.len());
python
# 1-minute bars for a single date
bars = tdx.stock_history_ohlc("AAPL", "20240315", "60000")
print(f"{len(bars)} bars")
go
// 1-minute bars for a single date
bars, err := client.StockHistoryOHLC("AAPL", "20240315", "60000")
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%d bars\n", len(bars))
cpp
// 1-minute bars for a single date
auto bars = client.stock_history_ohlc("AAPL", "20240315", "60000");
std::cout << bars.size() << " bars" << std::endl;

Code Example (Date Range)

rust
// 5-minute bars across a date range
let bars: Vec<OhlcTick> = tdx.stock_history_ohlc_range(
    "AAPL", "20240101", "20240301", "300000"
).await?;
python
# 5-minute bars across a date range
bars = tdx.stock_history_ohlc_range("AAPL", "20240101", "20240301", "300000")
go
// 5-minute bars across a date range
bars, err := client.StockHistoryOHLCRange("AAPL", "20240101", "20240301", "300000")
cpp
// 5-minute bars across a date range
auto bars = client.stock_history_ohlc_range("AAPL", "20240101", "20240301", "300000");

Parameters (Single Date)

symbolstringrequired
Ticker symbol
datestringrequired
Date in YYYYMMDD format
intervalstringrequired
Bar interval in milliseconds (e.g. "60000" for 1-minute)
start_timestringoptional
Start time as milliseconds from midnight ET
end_timestringoptional
End time as milliseconds from midnight ET
venuestringoptional
Data venue filter

Parameters (Date Range)

symbolstringrequired
Ticker symbol
start_datestringrequired
Start date in YYYYMMDD format
end_datestringrequired
End date in YYYYMMDD format
intervalstringrequired
Bar interval in milliseconds

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 f64.
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

Common Intervals

IntervalMilliseconds
1 minute"60000"
5 minutes"300000"
15 minutes"900000"
1 hour"3600000"

Notes

  • Use the single-date variant for intraday analysis of a specific session.
  • Use the range variant for building multi-day bar charts or backtesting.
  • Optional start_time / end_time parameters (single-date variant only) let you filter to regular trading hours or a custom window.

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