Questions tagged [kdb]

kdb+ is a proprietary high-performance database developed by Kx Systems.

kdb+ is a proprietary high-performance database developed by KX.

Features

  • Scalable column-oriented database for massive data volumes
  • Manages real-time and historical data in one platform
  • A single system allowing for low latency communication between kdb+ processes
  • Coupled with the expressive q programming and query language

It comes with a programming language called q (or kdb/q). Both q and kdb are written in the k language which has the tag on this site.

More Information

KX have recently launched the KX Community, a site moderated daily by KX employees to ensure all questions are answered. For any questions, on q/kdb+ or any of the KX technology and products, our KX experts are on hand to help!

2014 questions
4
votes
3 answers

select only those columns from table have not null values in q kdb

I have a table: q)t:([] a:1 2 3; b:```; c:`a`b`c) a b c ----- 1 a 2 b 3 c From this table I want to select only the columns who have not null values, in this case column b should be omitted from output.(something similar to dropna method in…
Utsav
  • 5,572
  • 2
  • 29
  • 43
4
votes
2 answers

Is there an `outer` or `exclusive or` operator equivalent to `inter` in KDB?

Let's say I have the following two lists: x : `a`b`c`d; y : `a`b`e`f; For the intersection, there is the inter operator: q)x inter y `a`b Is there a similar operator to do the EXCLUSIVE OR such that I would get: q)x outer y `c`d`e`f ?
JejeBelfort
  • 1,593
  • 2
  • 18
  • 39
4
votes
3 answers

Parallel Processing in kdb

When we use -s, main thread delegate some work to slave threads. I'm running below code on the session with 3 slave thread: q -s 3 select from t where date within 2019.01.18 2019.01.20 Trying to understand how q used threads internally for above…
Utsav
  • 5,572
  • 2
  • 29
  • 43
4
votes
1 answer

Comparison of sublist and take operator(#) in q kdb

While fetching a subset of data from a table when I use sublist or take operator(#), most of the times take operator is slow compared to sublist function. 5 observations posted in comment after querying table t in hdb which consists of 231131 rows…
Utsav
  • 5,572
  • 2
  • 29
  • 43
4
votes
1 answer

(q/kdb+) Split string column into float columns

What is the best way to split the string column b t:([]a:3,4,5;b:("45 | 37 <> 5 | 6";"67 | 981 <> 50 | 7";"1 | 71 <> 15 | 8")) a b 3 "45 | 37 <> 5 | 6" 4 "67 | 981 <> 50 | 7" 5 "1 | 71 <> 15 | 8" to get this a b c …
Jms
  • 139
  • 14
4
votes
3 answers

kdb+ - how to start process without blocking the terminal in linux

I am trying to run couple of processes on linux of kdb+(TP, RDB, HDB) e.g q tick.q sym /mnt/disks/disk1/OnDiskDB/ -p 5000 The problem which I have is that I have to keep terminals opened to keep q processes running Below are my steps: I tried: q…
4
votes
2 answers

KDB select only rows with max value on a column elegantly

I have this table for stock prices (simplified version here): +----------+--------+-------+ | Time | Ticker | Price | +----------+--------+-------+ | 10:00:00 | A | 5 | | 10:00:01 | A | 6 | | 10:00:00 | B | 3…
Kai
  • 91
  • 1
  • 4
4
votes
1 answer

kdb items being list and convert into row

I have the following kdb table name value price ------------------------- Paul 1 2 3 4 where value and price are lists. How can I convert them into name value price ------------------------------ Paul 1 3 Paul 2 …
Theboy
  • 353
  • 1
  • 2
  • 8
4
votes
2 answers

kdb/q how to drop entries from lists

I am trying to concatenate several csv's with identical columns. getDataFromCsv :{[fn]; if[not () ~key hsym fn; data: ("zSzzSISSIIIIIffffff"; enlist "\t") 0:fn; ... do stuff... :data];} getFiles:{[dates;strat];root:"/home/me/data_";:{x:…
chrise
  • 4,039
  • 3
  • 39
  • 74
4
votes
1 answer

How to generate datatable by iterating through multiple lists? (KDB)

I have a function quotes[ticker;startDate;endDate], and a function indexConstituents[index;startDate;endDate] that yield the below: daterange: 2017.12.05,2017.12.06; quotes'[AAPL;daterange] date time sym price 2017.12.05 09:45 AAPL…
Fomalhaut -C
  • 320
  • 2
  • 13
4
votes
2 answers

Iterate function over list of inputs (Q/KDB)

I have a function, f[symbol;date0;date1] , as well as a range of dates, say 2017.12.04 2017.12.05 2017.12.06 I'd like to run this function for a given symbol - assume "AAPL" - once for each day. In…
Fomalhaut -C
  • 320
  • 2
  • 13
4
votes
2 answers

Apply formula to current and previous rows only (Q/KDB)

I have a formula that I'd like to apply row-by-row, such that only the current and previous rows on any given row are included in calculation. Consider this data: data:([]dt:2017.01.05D19:45:00.238248239 2017.01.05D20:46:00.282382392…
Fomalhaut -C
  • 320
  • 2
  • 13
4
votes
3 answers

Create rolling calculation based unique entries (Q/KDB+)

I have a table: q)data:([]dt:2017.01.05D19:45:00.238248239 2017.01.05D20:46:00.282382392 2017.01.05D21:47:00.232842342 2017.01.05D22:48:00.835838442 2017.01.05D20:49:00.282382392;sym:`AAPL`GOOG`AAPL`BBRY`GOOG;price:101.20 800.20 102.30 2.20…
Fomalhaut -C
  • 320
  • 2
  • 13
4
votes
1 answer

Weighted avgerage of list columns in kdb

How can I calculate a column of weighted averages from 2 other columns that both have multiple entries per row in kdb? For example, given the following table: T:([]sym:`a`b`c;size:(2 8;5 2 10;3 7);price:(1 2;1 1 10;2 4)) I would like to add the…
CWD
  • 323
  • 1
  • 6
4
votes
3 answers

KDB: In-place delete from dictionary

To upsert an element into the dictionary, I do q) d[`x]:12345 This modifies existing dictionary and the operation cost is close to O(1) or O(log N) depending on the underlying implementation (hash table or tree) (I don't know in fact). However, to…
Sanny
  • 303
  • 3
  • 9