I'm trying to run an xbar aggregation on trade data after an xgroup aggregation however I can't get seem to get it right:
I am trying to take a table of the following format (consisting of trades):
time side amount price exchange
------------------------------------------------
2019.08.22T12:01:04.389 sell 54 9953.5 exchange1
2019.08.22T12:01:05.034 sell 205 9953.5 exchange1
2019.08.22T12:01:05.754 sell 150 9953.5 exchange1
2019.08.22T12:01:06.375 sell 516 9953.5 exchange1
2019.08.22T12:01:07.044 sell 100 9953.5 exchange1
2019.08.22T12:01:07.691 sell 1500 9953.5 exchange1
2019.08.22T12:01:08.393 sell 300 9953.5 exchange1
2019.08.22T12:01:09.005 sell 2254 9953.5 exchange2
2019.08.22T12:01:09.625 sell 500 9957.5 exchange2
2019.08.22T12:01:10.448 sell 5330 9953.5 exchange2
2019.08.22T12:01:11.065 sell 260 9953.5 exchange2
2019.08.22T12:01:11.701 sell 38 9953.5 exchange2
2019.08.22T12:01:12.404 sell 44 9953.5 exchange2
2019.08.22T12:01:12.974 sell 41 9953.5 exchange2
on one hand I would like to use xbar to group them into time buckets of 5 minutes i.e.
select price, amount by 5 xbar time.minute from trades
and on the other I am trying to group them by side and exchange i.e.
exchangeside xgroup trades
I am looking for the best method to combine the above 2 methods such that I have 4 groups bucketed/windowed/aggregated by time i.e.
exchange1 sell time1 price1 amt1
time2 price2 amt2
exchange1 buy time1 ...
time2 ...
exchange2 sell time1 ...
time2 ...
exchange2 buy time1 ...
time2 ...
etc.
How would one succinctly achieve this? Thanks