quantlab.label.predefined.membership_mask#

Mask a label with an index’s point-in-time membership, judged at t only.

An index such as the S&P 500 is a universe: it says which samples exist. A forward-return label at bar t reads prices up to bar t + lookahead, so a label computed on a price panel blanked off-membership exists only when the symbol is still a member at the label’s endpoint. A stock usually leaves an index because it fell, so that drops the losers from the training target and from every factor report on it: survivorship bias.

MembershipMaskedLabel wraps any label computed on unmasked prices and sets a cell to NaN only where the symbol is not an index member on t’s own date, the same rule MembershipMaskedPredictor applies to predictions. It changes nothing else, so it drops into ModelConfig.labels and Factor.analyze(frets=...) in place of the label it wraps.

Classes

MembershipMaskedLabel

A label that is NaN where the symbol is not an index member at t.

MembershipMaskedLabelConfig

What a MembershipMaskedLabel is rebuilt from.