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
2 answers

q - recursion with /

In q, a common illustration for the over operator / is the implementation of fibonacci sequence 10 {x,sum -2#x}/ 1 1 This indeed prints the first 10 fibonacci numbers but doesn't make sense in regards of the definition of the over operator in this…
tenticon
  • 2,639
  • 4
  • 32
  • 76
4
votes
2 answers

q kdb fill missing fxrates

I have a table in kdb with 3 columns: date, currency, fx rate. Some of the fx are missing, and I want to replace the null fx by the value on the previous day, for the same currency obviously. I cannot use fills as it is because it may mix…
curious
  • 65
  • 5
4
votes
2 answers

[KDB+/Q]: Apply list of functions over data sequentially (pipe)

In kdb+/q, how to pipe data through a sequential list of functions so that output of previous step is the input to next step? For example: q)t:([]sym:`a`c`b;val:1 3 2) q)`sym xkey `sym xasc t / how to achieve the same result as…
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
4
votes
2 answers

Kdb - string to double or float

I am trying to convert a string into a double or a float in KDB - the string contains a number with "accounting" format of the like of 2,228,25 (amount) - is I use something like "j"$amount I get 50 44 50 50 56 46 50 53 as a return value. How do I…
GiPoldo
  • 51
  • 1
  • 2
4
votes
2 answers

Loop with EACH in Q KDB+

I've stock trade database (name "TRADES") and I'm trying for a long time to make a simple loop (with function EACH) which would sum all quantities that are above a pre-defined quantity threshold for every ISIN. The data looks like this: q) select…
Linas
  • 43
  • 1
  • 6
4
votes
1 answer

KDB/Q: Why I got length error when select data using vector condition for symbol list?

I have a table: t3:([]a:2 3 4;b:`CA`AB`) I have a query: select from t3 where b in ?[a=2;`CA`AB;`AB] Bong... it give me `length error. But these works: select from t3 where b in ?[a=2;`CA;`AB] select from t3 where b in `CA`AB Cannot think of…
Lance LI
  • 113
  • 3
  • 9
4
votes
1 answer

Sliding window on time in KDB/Q

There are some functions in Q/KDB that let us aggregate on a sliding window (msum, mavg, etc.). But these functions takes the number of previous rows into account. I'd like a function that would aggregate on a sliding window but with time instead of…
Sithered
  • 481
  • 7
  • 23
4
votes
2 answers

Getting aggregate functions to return null in KDB

In SQL, aggregate functions sum(x), avg(x), max(x), min(x) will return NULL when x is empty or contains only NULL values. In KDB, sum and avg return zero, while max and min return (+ or -) infinity. To get the desired behavior of returning null I…
JSLover
  • 165
  • 1
  • 10
4
votes
2 answers

Convert Notepad++ syntax highlighting file to vim (or does anyone have a q/kdb+ vim syntax highlight file?)

I have a syntax highlighting file for the q/kdb+ language and I'd like to convert it to a vim compatible file so my q code won't look any more ugly than usual. Are there utilities available to automatically convert notepad++ xml syntax highlighting…
Peter Byrne
  • 41
  • 1
  • 2
4
votes
1 answer

Prevent KDB+ database from dying due to abort error

If max memory is set using -w command line argument and if a bad query is fired which allocates too much memory, KDB is exiting with "-w abort" error. Is it possible to make KDB just stop executing that query and not kill itself. At least is there a…
Ramprasad
  • 75
  • 1
  • 7
4
votes
2 answers

How do I perform an efficient left join in kdb?

I want to run a conventional SQL-style left join in KDB+ / Q. We get at least one row in the result for every row in the left table. If there is more than one match in the right table, I get a row for each of those, not just for the first…
JSLover
  • 165
  • 1
  • 10
4
votes
3 answers

How to find out KDB Query Execution Time

I would like to find out how much time a query took for getting executed. I plan to log this for audit and support purposes. I have found this in the documentation: q)\t log til 100000 / milliseconds for log of first 100000…
4
votes
2 answers

KDB+/Q: About unused parameters in inner functions

I have this function f f:{{z+x*y}[x]/[y]} I am able to call f without a 3rd parameter and I get that, but how is the inner {z+x*y} able to complete without a third parameter?
zrb
  • 851
  • 7
  • 16
4
votes
1 answer

KDB/k: Functional form to create a table variable

Is there a functional form equivalent to the following? trades:([]date:`date$();time:`time$();sym:`symbol$();price:`real$();size:`int$(); cond:`char$()) Assuming the function name is "ct"... trades:ct[fieldNames;types]
zrb
  • 851
  • 7
  • 16
4
votes
1 answer

How to ungroup list columns in data.table?

tidyr provides the unnest function that help expanding list columns. This is similar to the much (20x) faster ungroup function in kdb. I am looking for a similar (but much faster) function that, assuming a data.table that contains several list…
statquant
  • 13,672
  • 21
  • 91
  • 162