Skip to content

stock_history_trade

Retrieve every trade execution for a stock on a given date. Returns tick-level data with price, size, exchange, and condition codes.

FreeValueStandardPro

Code Example

rust
let data = tdx.stock_history_trade("SPY", "20260315").await?;
for t in &data {
    println!("date={} ms_of_day={} price={:.2} size={} exchange={} condition={} sequence={}",
        t.date, t.ms_of_day, t.price, t.size, t.exchange, t.condition, t.sequence);
}
python
data = tdx.stock_history_trade("SPY", "20260315")
for t in data:
    print(f"date={t.date} ms_of_day={t.ms_of_day} price={t.price:.2f} "
          f"size={t.size} exchange={t.exchange} condition={t.condition} sequence={t.sequence}")
typescript
const data = tdx.stockHistoryTrade('SPY', '20260315');
for (const t of data) {
    console.log(`date=${t.date} ms_of_day=${t.ms_of_day} price=${t.price} size=${t.size} exchange=${t.exchange} condition=${t.condition}`);
}
cpp
auto data = client.stock_history_trade("SPY", "20260315");
for (const auto& t : data) {
    printf("date=%d ms_of_day=%d price=%.2f size=%d exchange=%d condition=%d sequence=%d\n",
        t.date, t.ms_of_day, t.price, t.size, t.exchange, t.condition, t.sequence);
}

Parameters

symbolstringrequired
Ticker symbol
datestringrequired
Date in YYYYMMDD format
start_timestringoptional
Start time as milliseconds from midnight ET
end_timestringoptional
End time as milliseconds from midnight ET
venuestringoptional
Data venue filter

Response Fields (TradeTick)

ms_of_dayi32
Milliseconds since midnight ET
sequencei32
Sequence number
ext_condition1 through ext_condition4i32
Extended trade condition codes
conditioni32
Trade condition code (encodes SIP condition flags such as regular sale, odd lot, intermarket sweep)
sizei32
Trade size in shares
exchangei32
Exchange code
pricef64
Trade price (decoded at parse time).
condition_flagsi32
Condition flags bitmap
price_flagsi32
Price flags bitmap
volume_typei32
0 = incremental volume, 1 = cumulative volume
records_backi32
Records back count
datei32
Date as YYYYMMDD integer

Helper methods: is_cancelled(), regular_trading_hours(), is_seller(), is_incremental_volume()

Sample Response

json
[
  {"date": 20260402, "ms_of_day": 34200000, "price": 646.42, "size": 126, "exchange": 4, "condition": 1, "sequence": 1704668},
  {"date": 20260402, "ms_of_day": 34200000, "price": 646.42, "size": 126, "exchange": 73, "condition": 95, "sequence": 1704670},
  {"date": 20260402, "ms_of_day": 34200000, "price": 646.42, "size": 126, "exchange": 43, "condition": 95, "sequence": 1704674}
]

SPY trades on 2026-04-02. Full response contains 887,576 trades. Use the _stream variant for large responses.

Notes

  • A single day of AAPL trades can exceed 100,000 rows. Use the Rust _stream variant for large responses to avoid holding everything in memory.
  • Use start_time and end_time to limit to regular trading hours (9:30 AM = 34200000, 4:00 PM = 57600000).
  • The condition and condition_flags fields encode SIP trade condition codes (e.g., regular sale, odd lot, intermarket sweep).

Released under the Apache-2.0 License.