Use the bin binary on a per-ticker basis

175 views Asked by At

For two tables each with datetime and ticker symbol columns, how can we achieve the functionality of the binary function bin within each ticker group. That is, instead of returning the latest index from the entire left-table prior to the time of each right-table row, for a given right-table row it should return the latest index from the left-table amongst only the rows of the same ticker symbol as the right-table row.

My first thought would be to add a per-group index in the left-table, apply bin on each ticker group for it’s group-index and then use the unique (ticker,group-index) pair to find the index on the full left-table. However, I am not sure how to implement this or if this is the best way to achieve the desired functionality.

1

There are 1 answers

0
WSUN000 On

Could you give some sample inputs and desired output?

This sounds like something you can solve with aj

Check https://code.kx.com/q/ref/aj/ for details