我两天前刚开始自己学习KDB,所以这可能有点天真。
我正在尝试编写一个函数,它接受一个输入,这是一个表,一个是一个符号(股票代码)。我希望能够使用此函数最终遍历列表:
table {function} /(符号列表)
然而,在编写函数时,我收到错误。该函数如下所示:
/H is a table, y is a symbol.
suffering:{[H,y] quotes: asdf (`.ceq.getQuotes;y; 2016.01.04; 14:41; 2016.01.29; 21:18;(`source`applyca`fungible`tz)!(`exegy; 0b; `officialConsolidated ;`$"America/New_York"));
w: select from aj [`date ; select OrderId, Side, Price,Market, ltime date+time from execs where RIC= y;update date:time from quotes ];
c:select date, Market, LPrice:log Price from w;
n1: select from aj[`date`Market; c; w];
n1:update realdate:`date$date from n1;
n1:update delta:{0,1_deltas x}LPrice by realdate from n1;
agg:n,n1;
argh:select goodbp: avg delta by sym from agg where bsize >asize, Side = "1";
asf:select badbp:avg delta by sym from agg where bsize < asize, Side = "1";
poof: ej[`sym;argh;asf];
H:H, poof}
据我所知,这遵循语法就好了:参数用分号分隔,参数用括号括起来等。
我不能将表作为输入吗?为什么我收到此错误:
“(关闭}没有匹配开场{)”
当函数确实具有匹配的开头{
答案 0 :(得分:1)
当函数定义跨越多行时,每个延续行必须以一个或多个空格字符开头。例如:
f:{
x+y}
是正确的,但是
g:{
x+y}
是两个语法错误,因为q分别处理两行,第一行没有结束}而第二行没有开头{。
有关详细信息,请参阅Starting kdb+ / Scripts。