From 79f7fe69ef6d7d90fe8b7a52b9aa1bc05daa65b1 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Thu, 7 Feb 2013 18:17:26 -0500 Subject: [PATCH] Checks to make sure that an Event has a type before checking type. The Dividend event is currently missing 'type', causing the type check to fail. TODO: Add a type to Dividends. --- zipline/transforms/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zipline/transforms/utils.py b/zipline/transforms/utils.py index fa951415..87bf647c 100644 --- a/zipline/transforms/utils.py +++ b/zipline/transforms/utils.py @@ -136,7 +136,8 @@ class StatefulTransform(object): log.info('Running StatefulTransform [%s]' % self.get_hash()) for message in stream_in: # we only handle TRADE events. - if message.type != DATASOURCE_TYPE.TRADE: + if (hasattr(message, 'type') + and message.type != DATASOURCE_TYPE.TRADE): continue # allow upstream generators to yield None to avoid # blocking. @@ -217,8 +218,8 @@ class EventWindow(object): def update(self, event): - if event.type != DATASOURCE_TYPE.TRADE: - continue + if hasattr(event, 'type') and event.type != DATASOURCE_TYPE.TRADE: + return self.assert_well_formed(event) # Add new event and increment totals.