kdb

How to ungroup list columns in data.table?

你说的曾经没有我的故事 提交于 2019-12-06 01:29:45
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 columns, each with the same number of element on each row, would expand the data.table. This an extension of this post . library(data.table) library(tidyr) t = Sys.time() DT = data.table(a=c(1,2,3), b=c('q','w','e'), c=list(rep(t,2),rep(t+1,3),rep(t,0)), d=list(rep(1,2),rep(20,3),rep(1,0))) print(DT) a b c d 1: 1 q 2016-01-09 09:55:14,2016-01-09 09:55:14

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

↘锁芯ラ 提交于 2019-12-05 15:55:28
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 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 800.50;shares:500 100 500 900 100) data: dt sym price shares 2017.01.05D19:45:00:238248239 AAPL 101.20 500 2017.01.05D20:46:00:282382392 GOOG 800.20 100 2017.01.05D21:47:00:232842342 AAPL 102.30 500 2017.01.05D22

How to send a data.frame from R to Q/KDB?

…衆ロ難τιáo~ 提交于 2019-12-05 14:08:10
I have a large data.frame (15 columns and 100,000 rows) in an existing R session that I want to send to a Q/KDB instance. From KDB's cookbook , the possible solutions are: RServer for Q : use KDB to create new R instance which shares memory space. This doesn't work because my data is in an existing instance of R. RServe : run an R server and use TCP/IP to communicate with Q/KDB client. This does not work, because as per RServe's documentation , " every connection has a separate workspace and working directory " and so i presume does not see my existing data. R Math Library : access R's

How to apply max function for each row in KDB?

北慕城南 提交于 2019-12-05 07:21:39
I want to ensure all values in column x are no smaller than 0.5, so I do: update x:max (x 0.5) from myTable But this gives an error (in Studio For KDB+ ): An error occurred during execution of the query. The server sent the response: type Studio Hint: Possibly this error refers to wrong type, e.g `a+1 What's wrong? You can try using | q)update x|0.5 from myTable Rahul It should work. It worked for me. This is the query I used for testing: update x:max(x;0.5) from myTable -- Check semicolon in max function Try the kdb vector conditional its similar to case-when in SQL: q)t:([] a:6?.9) q)t a ---

q/kdb+ windows server setup

穿精又带淫゛_ 提交于 2019-12-05 06:55:57
I'm trying to setup qStudio in windows. While adding a new server, an error message pops up, saying: Connection does not work.java.io.IOException: java.sql.SQLException: Connection refused: connect. Used default "Server Properties" configuration: Host: localhost Port: 5000 Server Type: KDB Username: Password: Very new to Q/KDB+.. Searched in google, but didn't find the answer. please help! Thank you! Might be a silly question but have you set up a KDB+ process yet? Download the free version from http://kx.com/software-download.php Explode to C:\q , set up QHOME environment var to point to this

How to join multiple tables

心已入冬 提交于 2019-12-04 18:36:39
I'm trying to join multiple tables in q a b c key | valuea key | valueb key | valuec 1 | xa 1 | xb 2 | xc 2 | ya 2 | yb 4 | wc 3 | za The expected result is key | valuea | valueb | valuec 1 | xa | xb | 2 | ya | yb | xc 3 | za | | 4 | | | wc The can be acheieved simply with (a uj b) uj c BUT does anyone know how i can do it in functional form? I don't know how many tables i actually have I need basically a function that will go over the list and smash any number of keyed tables together... f:{[x] x uj priorx}; f[] each (a;b;c;d;e...) Can anyone help? or suggest anything? Thanks! Another

KDB: apply dyadic function across two lists

冷暖自知 提交于 2019-12-04 01:32:48
问题 Consider a function F[x;y] that generates a table. I also have two lists; xList:[x1;x2;x3] and yList:[y1;y2;y3] . What is the best way to do a simple comma join of F[x1;y1],F[x1;y2],F[x1;y3],F[x2;y1],..., thereby producing one large table? 回答1: You have asked for the cross product of your argument lists, so the correct answer is raze F ./: xList cross yList 回答2: Depending on what you are doing, you might want to look into having your function operate on the entire list of x and the entire

What performance can we expect from kdb+ 32bit

╄→гoц情女王★ 提交于 2019-12-03 08:50:44
Kx announced their free kdb+ (32bit) time series database. What performance in terms of reads/writes per second can we typically expect from this database? I do understand this is a complex question as the answer depends on a setup, number of nodes, etc. I am hoping someone will be able to provide us some numbers as well as use cases. After more investigation I found sample performance benchmarks on the kx.com website : On an AMD Opteron box with 4 GB of RAM, we get 0.672 million inserts per second (single insert) 6.944 million inserts per second (bulk insert 10) 20.408 million inserts per

KDB: apply dyadic function across two lists

时光总嘲笑我的痴心妄想 提交于 2019-12-01 07:39:37
Consider a function F[x;y] that generates a table. I also have two lists; xList:[x1;x2;x3] and yList:[y1;y2;y3] . What is the best way to do a simple comma join of F[x1;y1],F[x1;y2],F[x1;y3],F[x2;y1],..., thereby producing one large table? You have asked for the cross product of your argument lists, so the correct answer is raze F ./: xList cross yList Depending on what you are doing, you might want to look into having your function operate on the entire list of x and the entire list of y and return a table, rather than on each pair and then return a list of tables which has to get razed. The

KDB+ like asof join for timeseries data in pandas?

假如想象 提交于 2019-11-30 11:49:59
问题 kdb+ has an aj function that is usually used to join tables along time columns. Here is an example where I have trade and quote tables and I get the prevailing quote for every trade. q)5# t time sym price size ----------------------------- 09:30:00.439 NVDA 13.42 60511 09:30:00.439 NVDA 13.42 60511 09:30:02.332 NVDA 13.42 100 09:30:02.332 NVDA 13.42 100 09:30:02.333 NVDA 13.41 100 q)5# q time sym bid ask bsize asize ----------------------------------------- 09:30:00.026 NVDA 13.34 13.44 3 16