Hi all,I need your help.I have two trade price time series (tick data) for securities A and B,and they are of course irregularly spaced, since they are trade pricetick data.What I am using are two columns:timestamp and trade price.I would like the make them aligned and synchonous, and then take thedifference of these two,how to do that?One way I could think of is:Security A:timestamp tradeprice12:30:00 1012:30:03 1312:30:09 8Security B:timestamp tradeprice12:30:01 2 12:30:04 612:30:07 8---------------------------------------------------------I just need to assume for security A, between interval [12:30:00,12:30:03], the trade price stays at 10, and after that, it stays at13, until becoming 8.For security B, I do the same.Essentially, I just need to “union” the timestamp sets,and then backfill each series,and then I can do any calculations on them.But I don’t know what are the command for this in Q/KDB…Please help me! Thank yuo!
Hi,
Given
q)A:(timestamp:12:30:00.000 + 0 3 9;tradeprice:10 13 8)
q)B:(timestamp:12:30:00.000 + 1 4 7;tradeprice:2 6 8)
Is
q)update spread:tradepriceA - tradepriceB from fills timestamp xasc (
timestamp
tradepriceA xcol A)uj(
timestamp`tradepriceB xcol B)
the kind of thing you are looking for?
Regards,
Andrew