Separating Trade Buy and Sell Volume Within Candle Bars
Summary
The document asks how to total trade volume by buy and sell classification for each candle, using a one-minute bar as an example. Its proposed approach collects trades while a bar is active, classifies them when a new bar begins, sums the amounts, then clears the buffers before collecting for the next bar. The author reports that the two totals together substantially exceed the candle's recorded volume during live-style backtesting.
The example highlights a data-alignment and deduplication problem, but it does not provide a diagnosis or a verified solution. It leaves open whether repeated trade records, polling boundaries, trade-side definitions, or backtest behavior account for the discrepancy. The code also appears to sum the first buffered trade repeatedly instead of indexing each trade, so its totals cannot be trusted as written. The material is useful as a troubleshooting case, not as a validated volume-classification method; reliable aggregation would require checking trade identifiers, bar timestamps, and the platform's volume conventions.
Key ideas
- The proposed workflow accumulates trade records during a candle and classifies them when the next candle begins.
- The author observes that summed buy and sell amounts exceed the candle's reported volume.
- Repeated records or incorrect bar-boundary handling could distort the totals, but the document does not establish the cause.
- The sample summation appears to reuse one trade amount rather than iterate over each buffered trade.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.