Reputation: 1
I just started learning KDB on my own two days ago, so this could be a bit naïve.
I am trying to write a function which takes one input which is a table and one which is a symbol (a stock ticker). I hope to be able to use this function to eventually iterate over a list:
table {function}/ (list of symbols)
However, in writing the function, I get an error. The function looks like this:
/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}
As far as I can see, this follows the syntax just fine: the arguments are separated by semicolons, the parameters are in brackets, etc.
Is it that I can't have a table as an input? Why am I getting this error:
"(closing } without matching opening { ) "
when the function does indeed have a matching opening {
Upvotes: 0
Views: 354
Reputation: 2268
When your function definition spans multiple lines, each continuation line must start with one or more space characters. For example:
f:{
x+y}
is correct, but
g:{
x+y}
is two syntax errors because q processes the two lines separately and the first line lacks a closing } while the second lacks an opening {.
See Starting kdb+ / Scripts for details.
Upvotes: 1