Questions tagged [kdb]
kdb+ is a proprietary high-performance database developed by Kx Systems.
2,072
questions
0
votes
0
answers
25
views
Use KDB to Generate Best Bid Ask Order Table from Best Bid Ask Quote Table (nbbo)
Now i have the nbbo, which record the best bid ask quote information. I need to generate the corresponding order flow from this. The nbbo looks like:
date sym time bid bsize ...
0
votes
1
answer
37
views
Find common elements in a nested list
How to find common elements in nested list, please suggest better solution.
q)list2:((12 18 23 25 45); (7 12 18 24 28); (1 5 8 12 15 16 18))
q){ (x 0) inter (x 1) inter (x 2)} [list2]
12 18
0
votes
1
answer
29
views
How to locate the triggering function
I want to find the function that invokes all the other functions inside of my tick setup. Theortically I know .u.end calls the end of day function within the processes (rdb.q) for example, but I can't ...
0
votes
1
answer
47
views
kdb/q What kind of Join would I need for this scenario?
I have two tables like this:
participants: each person in the race, along with their score and the name of race they ran in
Name
Score
Race
Ann
66
8a
Bob
20
8a
Ann
73
7d
Bob
25
7d
races: the ...
0
votes
1
answer
28
views
KDB Checking for matching values in an empty mixed list
I am trying to extract values from a column of type C and compare the value with various strings. A simple in works well as long as the column value is not null.
a: exec colName from select from ...
0
votes
1
answer
57
views
KDB/Q How to transpose a table with multiple keys?
I have a table modeled after the question here:
KDB/Q How to transpose a table?
but my table has an extra 2 keys. What is the general solution to transposing a table with multiple keys? Example table ...
0
votes
2
answers
59
views
Kdb ema function for irregular time series
In kdb, an ema function is already provided which works fine for regular time series.
However for irregular time series, does anyone have an ema function implemented for that?
I think I am suppose to ...
1
vote
2
answers
115
views
kdb like left join in pandas with df having duplicate values in the key column of both the dataframes
I'm looking for a kdb like left join (left inner join) in pandas(seems like pandas merge and join method provide left outer join support)
Toy example -
In KDB -
q)lt: ([] ticker:`goog`amzn`goog`msft; ...
0
votes
2
answers
57
views
Kdb generate a new column from a column of 1,-1 and null, it should generate fills 1s and -1s but it should have 0ss if the direction changes
I have a table t: ([] dir: 0n 1 0n 0n -1 0n 0n 0n 1 1 -1 0n -1 0n)
I want to generate a new column based on dir it should basicly fills the null values however I dont want the newDir column to change ...
0
votes
1
answer
136
views
Find All Pairs Of Target Sum
Can you please help on solution in kdb to find all pairs of target sum.
I have find the solution in java using multiple containers but not able to solve in vector programming.
import java.util.HashMap;...
1
vote
1
answer
68
views
kdb+ unable to use csv data after import
I'm trying to load csv data to test some kdb+ q functions I've written. After loading the data to a table and flipping one row into a dictionary, I have unexpected commas in the referenced data.
I ...
0
votes
2
answers
56
views
kdb/Q How to Union Join two tables, summing a specific value?
I have two tables:
info
First
Last
Score
Full Name
Ann
R
10
Ann R
Bob
C
12
Bob C
Ann
R
13
Ann R
Fil
B
19
Fil B
summary
Full Name
Sum_Scores
Ann R
23
Fil B
19
Bob C
12
The summary table ...
-3
votes
0
answers
140
views
How can I fix the Unlicenced Workstation error in qJupyter?
Consider:
I have ran the following command:
docker run -it --name myjupyterq -p 8888:8888 kxsys/jupyterq
The qJupyter instance has started up and I can access it, but it says the workstation is not ...
0
votes
1
answer
62
views
How to change the q command in qJupyter?
I want to change
Starting Kernel: ['q', 'jupyter_kernel.q' ... ]
to
Starting Kernel: ['taskset -c 1,2 ${QHOME}/l64/q', 'jupyter_kernel.q' ... ]
The debug comes from running :
jupyter console --kernel=...
0
votes
1
answer
66
views
What is a good rule of thumb for setting memory limits on KDB rdbs?
The question basically says it all.
How much memory should we allocate on an RDB. Is it 50% above the expected traffic or more like 3x of the expected traffic?
I cannot find any suggestions on the KX ...
0
votes
1
answer
62
views
kdb/q How to use the Do Accumulator using a function that takes in multiple outputs?
I have a function that takes in 2 tables and outputs the score and state of one table:
// tableOne tableTwo -> Score tableOne
fGetOutput:{[one;two]
...
?[scoreone >= scoretwo; (scoreone, ...
0
votes
2
answers
58
views
kdb/q How to append a list to a table?
I have a table like this:
nameTable
Name
Included
Ann
1
Bob
0
Cat
1
I have a function that gets the "bits" from the Included? column:
// get the bits
fGetBits:{[nameTable]
nameTable: ...
0
votes
1
answer
61
views
kdb/q How do I save a kdb workspace using VS Code?
I'm using VS Code as my IDE, and I know that people use notation like below to load up a workspace:
\l C:/git/.../NameOfFile.q
I think this is called saving a (kdb) workspace, how can I do that so ...
0
votes
0
answers
83
views
Create SLOW SUBSCRIBER in KDB+
I am trying to simulate a slow subscriber in KDB+.
I don't think I need to load the .u.q file and initialize .u.init since the table is already in the publish list of TP which I verified using .z.w
As ...
0
votes
2
answers
87
views
How to find the rank of a kdb function and throw error
How to find the rank of a kdb function through program for test validation.
For example -> func: {x+y*10} / rank 2
For func function the rank is 2 however how to identify if the rank is low i.e &...
0
votes
2
answers
75
views
kdb/q How can I save a Dictionary?
I have a dictionary and I'm trying to save using kdb/q. To save my dictionary, I try the same method as I would a table:
save `output.csv
However, my output dictionary (type 99h) gives me an error:
q)...
0
votes
1
answer
69
views
kdb/Q How to iterate on a function x number of times?
I'm new to kdb/Q, what is the equivalent of iteration, where I need to run a function 10 times?
In Python, it would be something like creating some kind of iterator, using a while loop to run the ...
0
votes
1
answer
62
views
kdb/Q How to store and return multiple values in a function?
I have a question about returning one of two lists with the more optimal metric.
My function takes in a list of numbers. It then changes one of those numbers, and compares which list has the highest ...
0
votes
2
answers
91
views
KDB/q pass two list of arguments to a function
Hi recently started learning KDB, I am trying to performing something like below, would appreciate your help with simplifying it.
q)f:{[x;dt] flip `Destination`Session`Time!(3#last ` vs x;`start`mid`...
0
votes
1
answer
51
views
How can I set up a folder with server specific configs to replace default configs of my app?
I want to have a folder which will contain various files which will replace default ones when bouncing the app.
For example. if I have a example1.csv which is loaded in proc1.q
and example1.csv's path ...
0
votes
2
answers
113
views
List Every 6 Months Between Dates
I have a function that can list dates between a start and end date using `til
I’m trying to find something (maybe using `xbar) which will list every date in 6 month intervals from the start date
Eg. ...
0
votes
1
answer
74
views
kdb/Q How to update single row in table?
I'm trying to find out how I can update a single value in a single, specified row in my table.
What I need is to go from this:
table - before
Index
Value
0
a
1
b
2
c
to this, specifically ...
0
votes
2
answers
147
views
kdb/q How to use conditionals (if/else) in a function
I'm trying to see how I can change the value in a table based on its current state.
Currently, the isSelected column is either a 0 or 1, and I want to change its value to the other, but I don't know ...
0
votes
1
answer
57
views
.Q.hp giving error when used in try-catch
When tried to run .Q.hp (https://code.kx.com/q/ref/dotq/#hp-http-post) in try-catch, I am getting an error ".[k){hmb[x;`POST;(y;z)]};[Ljava.lang.Object;@7c8be683;[Ljava.lang.Object;@724c1762;]&...
0
votes
2
answers
69
views
what is the use of -1 command in a function in kdb
I have come across below function which uses -1 command
q)whereami:{-1 "cd ~ ",system "cd";} / defining the function
q)whereami[] / executing the function
cd ~ /Users/utsav/...
0
votes
2
answers
72
views
Where is the attribute information stored for partitioned table in kdb
I have a partitioned table in kdb which is partitioned on data and parted on tick column.
Where is the attribute metadata that the table is parted on tick column being stored in kdb?
Example -
t:([] ...
0
votes
1
answer
76
views
Is there a way to suppress empty output (`::`) when using the magic %%q (with PyKX, NOT PyQ) in Jupyter notebook?
When using the %%q magic with PyKX in jupyter notebook, it seems that the output from each line of code is printed, including ::. See, e.g., the example on the documentation . Is there a way to ...
0
votes
1
answer
147
views
Winsorizing in kdb/q
Given a table with an arbitrary number of columns what is the most efficient way to winsorize columns? i.e. set all outliers to a specified percentile of the data? For example, a 90% winsorization ...
0
votes
1
answer
76
views
How to re-enumerate kdb database
I have a database with a bloated sym file (350million+) due to id columns being symbols.
This is a large database, 1TB+ with 5 years of data.
I can use dbmaint to convert the string columns to symbols....
0
votes
1
answer
55
views
update table multiplied with exchange rate
I have two tables, i need to check if the currencyStr from table1 is present in table2 and update the qty with the corresponding exchangeRate.
table1:([] qty: 100 200 150 130 200 230 300; currencyStr: ...
0
votes
0
answers
42
views
Does TorQ has a general template for creating RTEs?
TorQ has templates for creating rdbs, hdbs etc. I cannot seem to find any for rtes. Amy I missing anything or should rtes be created from scratch.
The only thing I see in the codebase that comes close ...
0
votes
2
answers
138
views
kdb/q Modified Climbing hill algo
I have a question about the methods for doing the climbing hill algorithm with a specific problem I have.
I have 2 metrics: Sum_x and Sum_y, and I have about a hundred rows in this format:
CategoryA
...
-1
votes
1
answer
64
views
Load data into a hdb instance in kdb
how to load data from folder /tmp/HDB/ into a hdb instance on port 2020
I have data extracts into the folder /tmp/HDB/ and want to upload the data to the hdb instance of port 2020 in kx refinery.
I ...
0
votes
1
answer
112
views
Does data intellect's TorQ framework allow for different permissions across environments?
We have our app running in 4-5 different environments.
Each env has different permissions (we have users who can use everything in dev, certain things in uat and nothing in prod)
I looked at the torq ...
0
votes
1
answer
79
views
how to transpose columns in a kdb table?
I would like to transpose a table:
Eg.
tab:([]date:10?(2023.09.01;2023.09.02;2023.09.04);algo:10?`A`B`C`D;timeZone:10?(00:00:00;00:05:00;00:10:00);cnt:(10?10))
update total:sum (cnt) by algo,date from ...
0
votes
2
answers
226
views
Rename a column in kdb q
How to rename a column from TotalPercent to "%"
TotalPercent
98
87
to output as
%
98
87
in kdb q
0
votes
3
answers
76
views
kdb/Q: How to select rows where at least one column is not null?
I have a table that looks like this:
ID
Name
1_Day_Time
2_Day_Time
2B
May
762
8D
Air
142
W2
Tim
908
332
9H
Bee
5E
Ice
712
How do I only select those rows with at least one non-null in the ...
0
votes
2
answers
78
views
to replace the name with original name in kdb q
there are two tables
Names- with columns - OriginalName, username
Names:([]OriginalName:("Arnab ahmed";"Arnab ahmed";"Arnab ahmed (TY)"); username:("ancdv";&...
0
votes
3
answers
78
views
KDB/q How to use qsql select statement to find item in list where type is empty list in a column of characters?
I have a table and passed it into a function where I use the primary ID to generate a column of characters.
However, there are a few areas in this newly-created column where instead of characters it's ...
0
votes
2
answers
68
views
KDB/q How to left join on two columns
I am trying to left join one table to another. I have one table that looks like this:
WORKING_TABLE:
Store
ID
Cost
Date
AXA
2B
2.3
2023.01.01
DEP
2B
2.8
2023.01.01
ZOO
2B
5.0
2023.01.02
REP
3C
8....
1
vote
3
answers
95
views
update the name in a table
I have two tables
Names- with columns - OriginalName, username1, username2, username3, username4, username5, username6, username7
Names:([] OriginalName: "Frank Rochitz"; username1:"&...
0
votes
3
answers
88
views
Kdb/q: Function output returning 'length error when querying table
I have a table called DATA that looks like this:
StartDate
EndDate
NAME
TYPE
2023.05.05
2023.09.18
Ash
A
2023.01.01
2023.05.04
Ash
B
2023.07.03
2023.09.18
May
C
2023.03.21
2023.07.02
May
D
I ...
0
votes
0
answers
73
views
KDB type error when calling function using error trap
I have a function that connects to a process, extracts some information and returns it.
func1:{[processName]
h: hopen getConnDetails[processName];
sampleData:h"select from ...
0
votes
3
answers
84
views
replacing lists with empty lists in a table
A user was asking how to create a select statement that replaces long lists with empty long lists in a table column for certain rows (given by a where constraint).
sample table
t: ([] myCol: 3 cut til ...
0
votes
1
answer
75
views
How to calculate the distance to the nearest higher value in DolphinDB?
In my dataset, there's a column named “f1“. Given a specific row with a value of 10, I want to find the nearest higher value above it, which is 11 in the first row. The distance between them is 4 (...