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)
symbolstringrequiredTicker symbol
datestringrequiredDate in
YYYYMMDD formatintervalstringrequiredBar interval in milliseconds (e.g.
"60000" for 1-minute)start_timestringoptionalStart time as milliseconds from midnight ET
end_timestringoptionalEnd time as milliseconds from midnight ET
venuestringoptionalData venue filter
Parameters (Date Range)
symbolstringrequiredTicker symbol
start_datestringrequiredStart date in
YYYYMMDD formatend_datestringrequiredEnd date in
YYYYMMDD formatintervalstringrequiredBar interval in milliseconds
Response Fields (OhlcTick)
ms_of_dayi32Bar start time (milliseconds from midnight ET)
open / high / low / closei32Fixed-point OHLC prices. Use
open_price(), high_price(), low_price(), close_price() for decoded f64.volumei32Total volume in the bar
counti32Number of trades in the bar
price_typei32Decimal type for price decoding
datei32Date as
YYYYMMDD integerCommon Intervals
| Interval | Milliseconds |
|---|---|
| 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_timeparameters (single-date variant only) let you filter to regular trading hours or a custom window.