KDB reverse asof join (aj) i.e. Next quote instead of previous

aj['time'sym;trade;quote] combines each trade with the previous quote value.

I would like to make the same connection, but on the next quote value instead of the previous one.

How can I achieve this?

+4
source share
1 answer

Define the following function:

k)ajr: {.Q.ft[{d:x_z;$[&/j:-1<i:(x#z)binr x#y;y,'d i;+.[+.Q.ff[y]d;(!+d;j);:;.+d i j:&j]]}[x,();;0!z]]y}

which is just the definition of aj in k, and binr instead of bin.

Then it can be used just like aj, but it will return the next quote instead of the previous one.

Source: https://groups.google.com/d/topic/personal-kdbplus/F-5zVzkvc6c

+4
source

Source: https://habr.com/ru/post/1670726/


All Articles