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

kdb/q update a keyed table element's list element

I have a table like: q)tbl[`XXX] 1977 1987 1997 and I want to update the nth element from the list of years, so the above becomes q)tbl[`XXX] 1997 1987 2007 And need it to be inplace? Been looking into the docs but having hard figuring it out.
Alim Hasanov
  • 197
  • 1
  • 3
  • 16
0
votes
2 answers

[KDB+/Q]: (Re-)define view programmatically (dynamically)

I can define view either by loading a q script, or interactively from console: q)myview::a+b / even semi-programmatically using ugly strings: value"myview::a+b" Some exploration: q)value `. `myview :: (+;`a;`b) `a`b "a+b" I can see…
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
0
votes
2 answers

Trying to aggregate by mean and then trim outliers of observations based on the mean in kdb

I'm trying to find the average value by item type, and then set a variable y that takes the value: missing value if x = 0, y = x. Then round values that are too big or too small: if x > 0, x > mu, then set y = mu if x < 0, x < mu, then set y =…
user7613376
0
votes
1 answer

Add q/kdb Build System to Sublime 3

I am using Sublime Text 3 (on Mac OS) and would like to add a q/kdb build to it so I can run the q code directly from ST. I have the below build file: { "cmd": ["/Users/XXX/q/m32/q", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line…
Alim Hasanov
  • 197
  • 1
  • 3
  • 16
0
votes
1 answer

How to change namespace by parameter in KDB+

I want to change namespace by a given parameter something like below: f:{system "d x"} but this failed, .i.e q)f[".new"] {system "d x"} '" @ .,["\\"] "d x" How can I do this? Thanks.
Rongshu
  • 31
  • 3
0
votes
1 answer

kdb+ : Command Line parameter as a filename to be saved as

How do I parse a command line parameter and use it as a variable in the script to be used as filename to be saved as. I have tried the below but it is not working fname:.z.X[2] ..... ...more code... .... /Save the table into a csv…
Alim Hasanov
  • 197
  • 1
  • 3
  • 16
0
votes
1 answer

kdb+ : concatenate table elements into a third column

I have this: a b c "aa" "bb" "cc" "aaa" "bbb" "ccc" I want to end up with -,|,/,\ in between or any other third string: a b c ab "aa" "bb" "cc" "aa-bb" "aaa" "bbb" "ccc" ""aaa-bbb" for example
Alim Hasanov
  • 197
  • 1
  • 3
  • 16
0
votes
2 answers

[KDB+/Q]: Manipulate parse tree of a function (`inverse` combinator)

How to extract and manipulate parse tree of a lambda/function? E.g. given the function pair:{` sv x,y}' I'd like to arrive at the "inverse" version using a combinator called inverse so that the following call returns (note the now swapped order of…
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
0
votes
2 answers

upsert into unkeyed kdb table

I am trying to modify the entry in the factor column that corresponds to the provided date. I cannot find any good documentation for KDB's upsert function and I have zero idea what I am doing wrong here.. query: {[table;dates;factors] table upsert…
jono
  • 171
  • 1
  • 1
  • 9
0
votes
1 answer

Finding position of key in list column of a table

I have a table with one of columns keyname being int and another column keylist being list of int. I am trying to create another column which is position of keyname in keylist in my table in following manner: update keypos:{y?x} . (keyname;keylist)…
Rahul
  • 755
  • 4
  • 8
  • 16
0
votes
2 answers

Regex syntax for support q/k/kdb+ comment using JLexer

Q: What do I need using for my lexer logic? Only regex or maybe special functions of lexer? Where does the mistake in my syntax for q multi-comment? Details: I'm trying to write intellij idea plugin for k/q/kdb+ (wiki, q/kdb+), and my plugin based…
Alykoff Gali
  • 1,121
  • 17
  • 32
0
votes
2 answers

select from with wildcard, in Q KDB

I use KDB with a tool that let me set queries. With this tool, only the parameters (filter value) can be changed with user interaction, not the structure of the query. I need a query to be run on user action. By default, I want it to select every…
Sithered
  • 481
  • 7
  • 23
0
votes
0 answers

Tickperplant subscription by sym sending single records not tables by editing .u.pub

I have a ticker plant that has the schema: quote:([]time:(); sym:();expiration:();mtype:();price:();cond:();exchange:();volume:()) trade:([]time:();…
Rtrader
  • 917
  • 4
  • 11
  • 26
0
votes
1 answer

How to save what I have selected into a new table in KDB

I have selected something in a table how to put what I have selected into a new table? Select code is like: select vwap:(sum PRICE*VOLUME)%(sum VOLUME) by SYMBOL,DATE from trade
0
votes
2 answers

How to apply a function to an entire column?

I have the following table from a JDBC connection in Q. q)r some_int this created_at updated_at .. -----------------------------------------------------------------------------.. 1231231 "ASD"…
Istvan
  • 7,500
  • 9
  • 59
  • 109