From e70490a415cc35468f27f623aa1e36a2255ed91a Mon Sep 17 00:00:00 2001 From: Nathan Wolfe Date: Tue, 28 Jun 2016 17:20:09 -0400 Subject: [PATCH] BUG: Correct AverageDollarVolume NaN handling `AverageDollarVolume` used `nanmean`, which discards NaNs before averaging, giving an ADV which is too high for any equities that have any NaNs. Changing the method to `nansum` divided by window length so that the denominator is the same no matter whether there are NaNs or not. --- zipline/pipeline/factors/technical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zipline/pipeline/factors/technical.py b/zipline/pipeline/factors/technical.py index 10666a8a..c7e26efe 100644 --- a/zipline/pipeline/factors/technical.py +++ b/zipline/pipeline/factors/technical.py @@ -156,7 +156,7 @@ class AverageDollarVolume(CustomFactor): inputs = [USEquityPricing.close, USEquityPricing.volume] def compute(self, today, assets, out, close, volume): - out[:] = nanmean(close * volume, axis=0) + out[:] = nansum(close * volume, axis=0) / len(close) class _ExponentialWeightedFactor(SingleInputMixin, CustomFactor):