diff --git a/zipline/transforms/vwap.py b/zipline/transforms/vwap.py index 48c0b3ba..ffc097af 100644 --- a/zipline/transforms/vwap.py +++ b/zipline/transforms/vwap.py @@ -73,6 +73,7 @@ class VWAPEventWindow(EventWindow): """ def __init__(self, market_aware=True, window_length=None, delta=None): EventWindow.__init__(self, market_aware, window_length, delta) + self.fields = ('price', 'volume') self.flux = 0.0 self.totalvolume = 0.0 @@ -100,7 +101,8 @@ class VWAPEventWindow(EventWindow): # We need numerical price and volume to calculate a vwap. def assert_required_fields(self, event): - if 'price' not in event or 'volume' not in event: - raise WrongDataForTransform( - transform="VWAPEventWindow", - fields=self.fields) + for field in self.fields: + if field not in event: + raise WrongDataForTransform( + transform="VWAPEventWindow", + fields=self.fields)