首页 文章

(写入函数时,在关闭KDB时没有匹配open {)错误

提问于
浏览
0

我两天前刚开始自己学习KDB,所以这可能有点天真 .

我正在尝试编写一个函数,它接受一个输入,这是一个表,一个是一个符号(股票代码) . 我希望能够使用此函数最终迭代列表:

table /(符号列表)

但是,在编写函数时,我收到错误 . 该函数如下所示:

/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}

据我所知,这遵循语法就好了:参数用分号分隔,参数用括号括起来等等 .

难道我不能把 table 作为输入吗?为什么我收到此错误:

“(关闭}没有匹配的开头{)”

当函数确实具有匹配的开头时{

1 回答

  • 1

    当函数定义跨越多行时,每个延续行必须以一个或多个空格字符开头 . 例如:

    f:{
      x+y}
    

    是的,但是

    g:{
    x+y}
    

    是两个语法错误,因为q分别处理两行,第一行没有关闭}而第二行没有开头{ .

    有关详细信息,请参阅Starting kdb+ / Scripts .

相关问题