quantlab.factor.kunquant_cs.CrossSectionalWeightedMean#
- class quantlab.factor.kunquant_cs.CrossSectionalWeightedMean(v, w)[source]#
Bases:
GenericCrossSectionalOpWeighted mean of
vacross symbols per bar, broadcast to every symbol.sum(w * v) / sum(w)over the symbols whosevis finite and whose weight is finite and positive; any other symbol is left out. A bar with no such symbol is NaN. Give the weight 0 outside a universe to average over the universe only, as the cap-weighted market return of an estimation universe does.Shares
CrossSectionalZScore’s constraints: batch runs start at bar 0 and the symbol count is a multiple of the SIMD block width.- Parameters:
- vOpBase
The values to average.
- wOpBase
The weights, such as market capitalizations.
Examples
>>> Output(CrossSectionalWeightedMean(Input("ret"), Input("cap")), "market")