Hi, as a small exercise, i am trying to compute the VWAP over the different depths of the order book.The simplest way is select timestamp, depth_vwap1: (bq0; bq1; aq0; aq1) wavg (bp0; bp1; ap0; ap1) from data now i am trying to abstract i in a function so that we can pass the max depth the vwap goes to as a parameter:
q)maxDepth:2
q)quantities: `$raze(("bq"; "aq"),/:\:string til maxDepth) // Note `$ to convert strings to symbols
q)prices : `$raze(("bp"; "ap"),/:\:string til maxDepth) // Note `$ to convert strings to symbols
Create needed list to pass to functional query:
q)enlist,quantities
enlist
`bq0
`bq1
`aq0
`aq1
q)-1 .Q.s1 enlist,quantities; //.Q.s1 very useful to show full structure of object
(enlist;`bq0;`bq1;`aq0;`aq1)