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
let data = tdx.stock_history_ohlc("SPY", "20260315", "60000").await?;
for t in &data {
println!("date={} ms_of_day={} open={:.2} high={:.2} low={:.2} close={:.2} volume={} count={}",
t.date, t.ms_of_day, t.open, t.high, t.low, t.close, t.volume, t.count);
}python
data = tdx.stock_history_ohlc("SPY", "20260315", "60000")
for t in data:
print(f"date={t.date} ms_of_day={t.ms_of_day} open={t.open:.2f} high={t.high:.2f} "
f"low={t.low:.2f} close={t.close:.2f} volume={t.volume} count={t.count}")typescript
const data = tdx.stockHistoryOHLC('SPY', '20260315', '60000');
for (const t of data) {
console.log(`date=${t.date} open=${t.open} high=${t.high} low=${t.low} close=${t.close} volume=${t.volume}`);
}cpp
auto data = client.stock_history_ohlc("SPY", "20260315", "60000");
for (const auto& t : data) {
printf("date=%d ms_of_day=%d open=%.2f high=%.2f low=%.2f close=%.2f volume=%d count=%d\n",
t.date, t.ms_of_day, t.open, t.high, t.low, t.close, t.volume, t.count);
}Code Example (Date Range)
rust
let data = tdx.stock_history_ohlc_range("SPY", "20260101", "20260301", "300000").await?;
for t in &data {
println!("date={} ms_of_day={} open={:.2} high={:.2} low={:.2} close={:.2} volume={} count={}",
t.date, t.ms_of_day, t.open, t.high, t.low, t.close, t.volume, t.count);
}python
data = tdx.stock_history_ohlc_range("SPY", "20260101", "20260301", "300000")
for t in data:
print(f"date={t.date} ms_of_day={t.ms_of_day} open={t.open:.2f} high={t.high:.2f} "
f"low={t.low:.2f} close={t.close:.2f} volume={t.volume} count={t.count}")typescript
const data = tdx.stockHistoryOHLCRange('SPY', '20260101', '20260301', '300000');
for (const t of data) {
console.log(`date=${t.date} open=${t.open} high=${t.high} low=${t.low} close=${t.close} volume=${t.volume}`);
}cpp
auto data = client.stock_history_ohlc_range("SPY", "20260101", "20260301", "300000");
for (const auto& t : data) {
printf("date=%d ms_of_day=%d open=%.2f high=%.2f low=%.2f close=%.2f volume=%d count=%d\n",
t.date, t.ms_of_day, t.open, t.high, t.low, t.close, t.volume, t.count);
}Parameters (Single Date)
symbolstringrequiredTicker symbol
datestringrequiredDate in
YYYYMMDD formatintervalstringrequiredAccepts milliseconds (
"60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.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 formatintervalstringrequiredAccepts milliseconds (
"60000") or shorthand ("1m"). Valid presets: 100ms, 500ms, 1s, 5s, 10s, 15s, 30s, 1m, 5m, 10m, 15m, 30m, 1h.Response Fields (OhlcTick)
ms_of_dayi32Bar start time (milliseconds from midnight ET)
open / high / low / closef64OHLC prices (decoded at parse time).
volumei64Total volume in the bar
counti64Number of trades in the bar
datei32Date as
YYYYMMDD integerSample Response
json
[
{"date": 20260402, "ms_of_day": 34200000, "open": 646.42, "high": 647.47, "low": 646.38, "close": 646.86, "volume": 727186, "count": 10708},
{"date": 20260402, "ms_of_day": 34260000, "open": 646.85, "high": 647.44, "low": 646.69, "close": 647.37, "volume": 282666, "count": 3331},
{"date": 20260402, "ms_of_day": 34320000, "open": 647.35, "high": 647.39, "low": 646.57, "close": 646.63, "volume": 329227, "count": 3967}
]SPY 1-minute bars on 2026-04-02. Full response contains 391 bars.
Common Intervals
| Shorthand | Milliseconds |
|---|---|
"1m" | "60000" |
"5m" | "300000" |
"15m" | "900000" |
"1h" | "3600000" |
Milliseconds are auto-converted to the nearest valid preset internally. Either form can be used.
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.