q - Composing symbols in KDB -
i'm working on python project interacting kdb+ database. future version of database have minor change, , since can't proceed python programming, thought i'd give shot myself instead of waiting update kdb developer.
i'm working mock database spits out randomly generated symbols this: instr1,instr2, instr81 etc.
i have looked around , beleive symbols generated line .gen.uni:$"instr",/: string til .gen.cfg.unisize;
the thing i'd achieve symbols exchangex.instry instead of instry (where x , y generated numbers).
for convieniece i've changed line $"instr",/: string til 4 brain doesn't hurt much.
how 1 achieve this? found out sv function i've tried many variations of sv ($"exchange",/: string til 4;$"instr",/: string til 4) nothing seems work.
thanks time!
ps: i've removed backticks here , there because of so's formatting
using roll operator useful generating kind of data: http://code.kx.com/q/ref/random/#roll
function below generate random list of symbols.
paramaters:
x - number of symbols want generated
y - number of different exchanges
z - number of different instruments
q){` sv' flip `$("exch",/:string x?y;"inst",/:string x?z)} q){` sv' flip `$("exch",/:string x?y;"inst",/:string x?z)}[100;4;10] `exch0.inst2`exch3.inst3`exch3.inst0`exch2.inst0`exch3.inst4`exch3.inst4`exch2.inst0`exch0.inst3`exch3.inst4`exch0.inst5`exch3.inst0`exch1.inst5`exch1.inst7`exch2.inst4`exch2.inst3`exch3.inst1`exch3.inst6`exch2.inst2`exch2.inst.. q)
Comments
Post a Comment