Looks like the second trade that's causing the trouble and missing the condition is "Cancelled record".
In addition to the fix, it would be good to have an option to exclude dark pool trades from the aggregates. Dark pool trades are not included in real-time candles, so it makes the algos...