'How does wavg work in depth using a vectorised approach?
The objective of the snippet below is to evaluate weighted mid for n levels of an order book. The code snippet is from the book Machine Learning and Big Data with kdb+/q (2020 Wiley).
n:10;
quote: ([] sym: n?`A`B; time: asc n?0t; bid1: n?10f; bidSize1: n?100 );
update bid2: 0 | bid1 - .1 * n ? 10, bidSize2: n?100, ask1: bid1 + .2 * n ? 10, askSize1: n?100 from quote;
update ask2: ask1 + .1 * n ? 10, askSize2: n?100 from `quote;
select sym,time, wmid: ( bidSize1; bidSize2; askSize1; askSize2 ) wavg (bid1; bid2; ask1; ask2) from quote
I would like to understand a generic rule for how the wavg method works in-depth for lists of vectors. Could you please help me? Appreciate your help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
