KDB/q orderbook add rows

190 Views Asked by At

In a table I try to bring together the rows that have the same price by adding the quantities for an order book all_order_ask:([]ask:();ask_qty:();exchange_name:()) Keep the same ask but when it's the same price add the quantities

1

There are 1 best solutions below

6
On BEST ANSWER

To answer your followup question: combining the exchange names would be like this:

select sum ask_qty,raze string exchange_name by ask from all_order_ask

assuming that exchange_name values are symbols...if they're already strings then you only need to raze.

I'll highlight again some caveats from my earlier comment:

this leaves a lot of questions: how do you want the resulting table to be ordered? Assuming your ask prices are floats you will have to manage the fact that there will be float precision issues so two floats that appear to be the "same" may not be the same and so they won't group properly