I used the schema defined in http://code.kx.com/svn/kx/kdb+/tick/tba.q:
trade:bid:ask:([]time:timespan$();sym:
symbol$();price:float$();size:
int$())
I want to join bid and ask tables into a single quote table but can't figure out how to do it. aj[] uses only one of the table's time column but I need both time columns combined.
E.g.
bid
time size price
----------------
10:00:00 10 0.05
10:00:03 10 0.06
10:00:06 20 0.06
ask
time size price
----------------
10:00:00 10 0.06
10:00:02 10 0.07
10:00:04 20 0.07
The result should be:
time bs bprc as aprc
--------------------------
10:00:00 10 0.05 10 0.06
10:00:02 10 0.05 10 0.07
10:00:03 10 0.06 10 0.07
10:00:04 10 0.06 20 0.07
10:00:06 20 0.06 20 0.07
Is anyone using this tba schema? It is much more compact and saves on disk space significantly but I see that it's not really flexible with regards to queries. If I wanted to get an average spread per day then how I would go about it?
Thank you!
You don't need
aj
to achieve what you want.uj
combined withfills
will do the job:Hope this helps.
Update. If you need to support multiple symbols then you should group by
time
andsym
as @user2393012 suggested:and then:
The idea is that you apply
fills
to values within each group only, preventing prices from leaking outside symbol boundaries.