diff --git a/docs/source/whatsnew/0.9.1.txt b/docs/source/whatsnew/0.9.1.txt index fab99497..1f5791d7 100644 --- a/docs/source/whatsnew/0.9.1.txt +++ b/docs/source/whatsnew/0.9.1.txt @@ -17,7 +17,10 @@ None Enhancements ~~~~~~~~~~~~ -None +* Added masking to :class:`zipline.pipeline.CustomFactor`. + Custom factors can now be passed a Filter upon instantiation. This tells the + factor to only compute over stocks for which the filter returns True, rather + than always computing over the entire universe of stocks. (:issue:`1095`) Experimental Features ~~~~~~~~~~~~~~~~~~~~~ diff --git a/zipline/pipeline/factors/factor.py b/zipline/pipeline/factors/factor.py index 4edf66d4..f7054131 100644 --- a/zipline/pipeline/factors/factor.py +++ b/zipline/pipeline/factors/factor.py @@ -1136,6 +1136,11 @@ class CustomFactor(PositiveWindowLengthMixin, CustomTermMixin, Factor): Number of rows to pass for each input. If this argument is not passed to the CustomFactor constructor, we look for a class-level attribute named `window_length`. + mask : zipline.pipeline.Filter, optional + A Filter describing the assets on which we should compute each day. + Each call to ``CustomFactor.compute`` will only receive assets for + which ``mask`` produced True on the day for which compute is being + called. Notes -----