I've stock trade database (name "TRADES") and I'm trying for a long time to make a simple loop (with function EACH) which would sum all quantities that are above a pre-defined quantity threshold for every ISIN. The data looks like this:
q) select TIME, PRICE, QUANTITY from TRADES where ISIN=`IT123
TIME PRICE QUANTITY
8:58:05 9.47 66
9:00:09 9.47 55
9:00:56 9.48 107
9:01:06 9.49 7
9:01:33 9.50 9
9:03:11 9.07 200
9:06:27 9.07 100
9:07:46 9.12 65...
At first, I try this code for one ISIN:
q) myquant: ([] qu: 1 + til 100) //pre-define quantities from 1 to 100
q) f:{[x] (select sum QUANTITY from TRADES where ISIN=`IT123, QUANTITY> x)}
q) f each myquant.qu //use function EACH for all x that are in myquant
And then I get some hieroglyphs... Maybe it is because the list is wrongly specified?
I also need to do these calculations not just for one, but for all ISIN's that I have in the database (i.e. "EACH distinct ISIN").
Thanks very much for the help in advance.