To find trades that occurred outside of the best bid offer query the result of the asof join:
q)select from aj[sym
time;t;q] where (price<bidPrice)|price>askPrice
time sym price size bidPrice bidSize askPrice askSize
12:00:03.000 A 10.5 200 11 200 13.2 200
12:00:06.000 A 8.5 100 6.5 200 7.8 200
12:00:12.000 A 12 100 8.5 200 10.2 200
Hi Hemant,
I see Joma has answered your question - Just a note, if you would like to perform an “except” on tables, make sure that the columns are the same.
//This would not work as the aj table has columns of both trade and quote,
t except aj[sym
time;t;q]
If you wanted to exclude these from the trades table, you could do something like this.
t:t except select time,sym,price,size from aj[sym
time;t;q] where (price<bidPrice)|price>askPrice
Regards,
Matt