Append columns to empty table - Q/KDB+

748 views Asked by At

I'm pulling data from a source that returns tick data for stocks (timespan + float prices).

I need to build 1 table that has the tick data for each stock, while inserting new timespan index values for each one. Example:

AAPL:
t0    101.20
t3    102.10

GOOG:
t1    850.50
t2    860.10

Table:
    AAPL    GOOG
t0  101.20  NA
t1  NA      850.50
t2  NA      860.10
t3  102.10  NA

There would be many symbols, so I can't just manually type AAPL, GOOG etc.

1

There are 1 answers

5
Thomas Smyth - Treliant On BEST ANSWER

While it would be possible to set up a table like you have described it would not be advisable. You would be better to set up a column to record each stock, sym in this case:

t                             sym  price
-------------------------------------------
2018.02.05D14:11:09.241245000 AAPL 101.7808
2018.02.05D14:11:09.241246000 GOOG 103.0177
2018.02.05D14:11:09.241246000 AAPL 107.8503
2018.02.05D14:11:09.241247000 GOOG 105.3471