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
0
votes
1 answer

How do I find the time difference between the first record and the current record

I have a table that selects record every minute. I want to add a column that calculates how much time has passed between my current record and the first record. But I am not sure how to do that. For example, if my first record has time 2:30, second…
0
votes
2 answers

separating the records in a kdb table

There is a table with a column that I would like to break into multiple records. For example q)tab:([]a:1 2 3;b:(`a;`$"b c";`d);c:2 3 4) q)tab a b c ------- 1 a 2 2 b c 3 3 d 4 There is a space between b and c in the second entry of column b,…
Terry
  • 523
  • 9
  • 21
0
votes
1 answer

How can I calculate correlation dynamically in kdb

I have a table of returns that I want to calculate correlation for every n rows, but I am not sure how to do that. To be more illustrative, my table t is sym1 sym2 sym3 sym4 3 4 5 1 0 -1 6 4 -3 10 8 9 -4 19 -1 6 How can I calculate…
0
votes
1 answer

Replace first n entries in a column in kdb

How can I replace the values in the first n columns of my table? i.e. mycol:(1 2 3 4) to mycol:(a a 3 4) Thank you in advance!
0
votes
1 answer

Replicating the error when saving down at the end of day

I would like to update the table so it has error message at EOD savedown. The goal is to have different type of data than the assigned type in the same column. eg. update col:5i from `t where i = 0 However, i got type error. Any idea how I should…
Terry
  • 523
  • 9
  • 21
0
votes
1 answer

Remove table duplicates under certain conditions

I have a table like below that shows me some pnl by instrument (code) for some shifts, maturity, etc. Instrument 123 appears two times (2 sets of shift, booknumber, insmat but different pnl). I would like to clean the table to only keep the first…
Victor Gl
  • 81
  • 1
  • 8
0
votes
2 answers

Retrieving splayed tables in q kdb

I tried the following code to retrieve the splayed table, but in vain. After loading sym, the table still leaves its symbol columns as bare enumerations. \l dir/file load `:dir/file/sym get `:/dir/file/ Here is the file structure file -sym…
0
votes
3 answers

kdb: getting one row from HDB

For a normal table, we can select one row using select[1] from t. How can I do this for HDB? I tried select[1] from t where date=2021.02.25 but it gives error Not yet implemented: it probably makes sense, but it’s not defined nor implemented, and…
kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80
0
votes
1 answer

KDB - Why does upsert work when insert does not

I am trying to manipulate the upd function in a KDB tickerplant so that it can accept a table as the data argument. When trying to insert locally, insert does not seem to like being passed the data from the table but will handle a list of lists fine…
0
votes
2 answers

(KDB/Q+) Update top N rows of a simple table

I I have a simple table in KDB and would like to know if there's an elegant way to update the first N rows and set all the values to 0n without explicitly specifying each of the column names because I do not know how many columns I have…
JKuek
  • 11
  • 2
0
votes
2 answers

Extracting data from piped string KDB

I have the below table t:flip…
pmade1
  • 21
  • 4
0
votes
1 answer

kdb - solver function to solve for IRR

Having trouble implementing a rate of return calculation to compare to Excel's XIRR calc which is essentially an solver algorithm to find the discount rate at which the NPV of an investment is zero using provided cash flow and dates in a table. Per…
Jason_L
  • 427
  • 1
  • 3
  • 12
0
votes
1 answer

kdb: differences between value and eval

From KX: https://code.kx.com/q/ref/value/ says, when x is a list, value[x] will be result of evaluating list as a parse tree. Q1. In code below, I understand (A) is a parse tree, given below definition. However, why does (B) also work? Is ("+";3;4)…
kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80
0
votes
1 answer

kdb: can the $ function take 5 arguments?

From https://code.kx.com/q/wp/parse-trees/#the-solution I came across below function, which translates enlisted symbols or symbol lists into the string "enlist". ereptest:{ //returns a boolean (1=count x) and ((0=type x) and 11=type first x) or…
kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80
0
votes
1 answer

kdb: what is the type of parse"x[y]"?

For expression parse"x[y]", I think it means a function/map/list application of x on argument y, possibly a projection. Please correct me if I'm wrong. Now entering into Q console, I get below output. q)parse"x[y]" x y q)l:parse"x[y]" q)count…
kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80