From c36fe01637cb75dfc177f09e63442fc7c6149eab Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Thu, 20 Jun 2013 13:01:09 -0400 Subject: [PATCH] STY: Use return instead of StopIteration to short circuit blotter gen. Using `return` is a little more readable alongside the rest of the logic compared to exposing iterator internals. --- zipline/finance/blotter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zipline/finance/blotter.py b/zipline/finance/blotter.py index 92f891a8..88ec8a0a 100644 --- a/zipline/finance/blotter.py +++ b/zipline/finance/blotter.py @@ -143,12 +143,12 @@ class Blotter(object): def process_trade(self, trade_event): if trade_event.type != zp.DATASOURCE_TYPE.TRADE: - raise StopIteration + return if zp_math.tolerant_equals(trade_event.volume, 0): # there are zero volume trade_events bc some stocks trade # less frequently than once per minute. - raise StopIteration + return if trade_event.sid in self.open_orders: orders = self.open_orders[trade_event.sid] @@ -158,7 +158,7 @@ class Blotter(object): lambda o: o.dt <= trade_event.dt, orders) else: - raise StopIteration + return for order, txn in self.transact(trade_event, current_orders): order.filled += txn.amount