Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit/llms.txt
Use this file to discover all available pages before exploring further.
getAggregatedTrades retrieves recent trade-by-trade history for a symbol from the registered exchange adapter. Like all data-fetching functions in Backtest Kit, it uses AsyncLocalStorage to read the current execution context and aligns the to boundary strictly to the 1-minute mark, guaranteeing that no future trades can leak into the dataset. The function supports both single-window and paginated fetches depending on whether a limit is specified.
IAggregatedTradeData
isBuyerMaker: true means the buyer placed a resting limit order that was filled by an aggressive sell — i.e., a sell-driven trade. false means a buy-initiated aggressive trade.
getAggregatedTrades
Trading pair symbol (e.g.,
"BTCUSDT").Optional maximum number of most-recent trades to return. When omitted, one full
CC_AGGREGATED_TRADES_MAX_MINUTES window is returned. When provided, the function paginates backwards until at least limit trades are collected, then slices to the limit most recent trades.Time Alignment
Theto timestamp is always aligned down to the nearest 1-minute boundary to prevent look-ahead bias:
CC_AGGREGATED_TRADES_MAX_MINUTES = 60 and when = 00:12:30.500 UTC:
| Field | Value |
|---|---|
alignedTo / to | 00:12:00 UTC |
from | 23:13:00 UTC (previous hour) |
Configuration
Maximum minutes of trade history to fetch per window. Used to compute the default
from/to range and each pagination chunk size. Required by exchanges like Binance that limit the startTime/endTime window to a fixed duration.Pagination Behavior
Withoutlimit: One single [from, to] window is fetched and returned as-is.
With limit: The function paginates backwards in CC_AGGREGATED_TRADES_MAX_MINUTES chunks until the collected array contains at least limit entries. It then slices to return only the limit most recent trades (closest to alignedTo).
Exchange Adapter Contract
The adapter receives alignedfrom and to as Date objects. Live implementations may ignore these and return the current trade stream.
getAggregatedTrades is not provided in the exchange schema, calling the function from a strategy throws an error.
Compatible Packages
The[from, to] time range format produced by this function is directly compatible with:
- garch — GARCH volatility modelling on trade-by-trade data
- volume-anomaly — detecting abnormal trade volume bursts