depth

q cheat sheet

The operators the q problems lean on. Run them in a q session to see the exact output.

TaskqNote
Running totalsums xsums 1 2 3 gives 1 3 6
Consecutive differencesdeltas xthe first item is kept as is
Moving average3 mavg xearly items use what is available
Round down to a bucket5 xbar x5 xbar 7 12 gives 5 10
Unique valuesdistinct xkeeps first-seen order
Sortasc x / desc x
Count per valuecount each group xreturns a dict
Weighted averagew wavg xweights go on the left
Group and aggregateselect avg price by sym from tresult is keyed by sym
Filter by group aggregateselect from t where size=(max;size) fby symrows with the max size per sym
As-of joinaj[`sym`time; trade; quote]the last key column is the time
Window joinwj[w; `sym`time; t; (q; (max;`bid))]aggregate over a time window
Apply over a listf each x
Fold and scan+/ x and +\ xover folds, scan keeps each step