我在跟踪这份文件: https://code.kx.com/q/wp/capi/#publishing-to-a-kdb-tickerplant个
在sym.q中:
交易:([]时间:timespan$();[sym:
符号$()];价格:float$();size:
长$())
现在,我希望使用键控表,这就是为什么上面的模式遵循键控表语法.
但问题是tickerPLANT模式应该以time:TimeSpan列开头,它导致的问题是当我输入type trade
时,它返回98h,而不是99h(这是键表的类型编号).
因此,在《R.Q》中:
/q tick/r.q [host]:port[:usr:pwd] [host]:port[:usr:pwd]
/2008.09.09 .k ->.q
if[not "w"=first string .z.o;system "sleep 1"];
upd:upsert
/ get the ticker plant and history ports, defaults are 5010,5012
.u.x:.z.x,(count .z.x)_(":5010";":5012");
/ end of day: save, clear, hdb reload
.u.end:{t:tables`.;t@:where `g=attr each t@\:`sym;.Q.hdpf[`$":",.u.x 1;`:.;x;`sym];@[;`sym;`g#] each t;};
/ init schema and sync up from log file;cd to hdb(so client save can run)
.u.rep:{(.[;();:;].)each x;if[null first y;:()];-11!y;system "cd ",1_-10_string first reverse y};
/ HARDCODE \cd if other than logdir/db
/ connect to ticker plant for (schema;(logcount;log))
.u.rep .(hopen `$":",.u.x 0)"(.u.sub[`;`];`.u `i`L)";
我有upsert,但因为它不是真正的键表,它导致一次又一次地插入重复的条目,而不是更新同一行的唯一键.