Questions tagged [q-lang]

The q language is a programming language by kx.com for querying kdb+ databases.

Q was developed by Arthur Whitney in 2003 and is built on top of the K programming language. The names q and kdb+ are often used interchangeably, but generally q refers to the programming language and kdb+ refers to the entire runtime environment.

245 questions
2
votes
2 answers

Use value to reference a variable in a function

How can I get value to see a variable in a local scope? For example: a:2; func:{ a:1; value "a" } returns 2
nightTrevors
  • 639
  • 4
  • 11
  • 24
2
votes
2 answers

Installing qPython in Win7

Being a newbie with Python and KDB+/Q, I tried to install qPython package (Python API for KDB+, not to be mistaken for QPython). I downloaded and unzipped the source from https://github.com/exxeleron/qPython/releases/tag/qPython-1.0-RC1 In Win…
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
2
votes
1 answer

How do I add several columns at once in kdb?

Somehow, I can only find examples that show how to add one column. So I have written this code, which works, but I know there is a much better way to do this: table t already exists with columns filled with data, and I need to add new columns that…
Hopper06
  • 89
  • 2
  • 10
2
votes
1 answer

General function to parse json string to kdb table?

What would be the best way to parse the "result" of a JSON string in q and build a table out of its structure? for example, if returned a json order book: { "success":true, "message":"", "result":{ "buy":[ …
nightTrevors
  • 639
  • 4
  • 11
  • 24
2
votes
1 answer

Append one table to another using kdb/q

I have a table that's got some values, and I would like to append another table to this one. The columns in the second table don't entirely match the first. Please note I am using Q/KDB+ language to achieve this: For example: Table 1 Date TypeA…
stretchr
  • 615
  • 2
  • 9
  • 24
2
votes
4 answers

kdb Q column name with spaces

I am importing a csv file to a table, but some columns have spaces in their names. Is there anyway around this or do I need to rename the columns before importing?
Eric
  • 295
  • 2
  • 7
  • 22
2
votes
1 answer

Import csv data into KDB table, ignore "comma" in double quotes

I have a BIG csv file and would like to load this data into my KDB table. The csv can be separated by comma (,) but I would like to avoid splitting values if comma is in double quotes. Say if I have "CUSTOMER 1, CUST1" - This value should not split…
Shashi
  • 199
  • 1
  • 6
  • 19
2
votes
3 answers

Kdb/Q Group By Minimum gives infinity

Kdb calculates infinity for null column if group by is performed. t:([]a: 1 1 2;b: 3 2 0n) select min b by a from t a 1 2.0 2 ow ow is infinity. Is there any way I can get null(0n) for 2
Vikas
  • 118
  • 1
  • 8
2
votes
1 answer

Is it possible to calculate serialized size of an object without allocating memory to hold serialized data?

This is for a user interface to kdb, where a user can run arbitrary queries. I want to check the size of result and alert the user if it is likely to cause memory overflow on the client. I can do count -8!"my query result" but I suspect that kdb…
user443854
  • 7,096
  • 13
  • 48
  • 63
2
votes
1 answer

how to improve time for select in kdb

I have created a trade database on my local machine, partitioned by date. select from trade where date=x Takes about 100 ms, but when I do: select from trade where date=x,sym=`alpha it takes ~1-3 seconds. Is there a trick I'm missing (using…
Naveen Sharma
  • 1,057
  • 12
  • 32
2
votes
2 answers

Q/kdb+ Reading huge text file

I need to read a huge file (around 20G) that contains trade data, and I wonder if there's a good method to read the file without killing the memory. My current method is loading the files by columns and join those columns together: columnA:(" S ";…
user1948847
  • 955
  • 1
  • 12
  • 27
2
votes
1 answer

how do i make changes while assigning in q

For example, I know that: c1 xasc table Will return a table that is sorted in ascending order by values in c1, but that does not change the table itself. So i wonder if there exist a method other than table:`c1 xasc table that can apply the change…
user1948847
  • 955
  • 1
  • 12
  • 27
1
vote
3 answers

How to match date and string from 2 lists (KDB)?

I have two lists: data: dt sym bid ask 2017.01.01D05:00:09.140745000 AAPL 101.20 101.30 2017.01.01D05:00:09.284281800 GOOG 801.00 802.00 2017.01.02D05:00:09.824847299 AAPL 101.30 101.40 info: date …
Fomalhaut -C
  • 320
  • 2
  • 13
1
vote
1 answer

How to pass arguments to a function (Q/KDB+)?

Say I have a function: quotes:{[ticker;x;y] output: .... } How can I use this function iterate over a list in another function: combiner:{[tickerList;x;y] output: uj quotes[ticker1;x;y], quotes[ticker2;x;y], etc. }
Fomalhaut -C
  • 320
  • 2
  • 13
1
vote
2 answers

How to create a database with 2 tables of different length or multiple symbol columns?

I have two tables: table1 spanning from 2017.01.01-> 2018.01.01 table2 spanning from 2017.12.01 -> 2023.01.15 (containing mostly fake simulated data). I want to create a historical database partitioned by date, and give the user the ability to…
user91991993
  • 705
  • 5
  • 11