diff --git a/zipline/finance/blotter.py b/zipline/finance/blotter.py index 227d95cf..b434cfaa 100644 --- a/zipline/finance/blotter.py +++ b/zipline/finance/blotter.py @@ -296,10 +296,10 @@ class Order(object): self.amount = int(self.amount / ratio) - if self.limit: + if self.limit is not None: self.limit = round(self.limit * ratio, 2) - if self.stop: + if self.stop is not None: self.stop = round(self.stop * ratio, 2) @property @@ -324,10 +324,10 @@ class Order(object): For a stop order, True IFF stop_reached. For a limit order, True IFF limit_reached. """ - if self.stop and not self.stop_reached: + if self.stop is not None and not self.stop_reached: return False - if self.limit and not self.limit_reached: + if self.limit is not None and not self.limit_reached: return False return True diff --git a/zipline/test_algorithms.py b/zipline/test_algorithms.py index ca624594..31f8818d 100644 --- a/zipline/test_algorithms.py +++ b/zipline/test_algorithms.py @@ -424,6 +424,12 @@ class AmbitiousStopLimitAlgorithm(TradingAlgorithm): # prevent trigger). self.order(self.sid, -100, limit_price=1, stop_price=1) + ################### + # Rounding Checks # + ################### + self.order(self.sid, 100, limit_price=.00000001) + self.order(self.sid, -100, stop_price=.00000001) + ########################################## # Algorithm using simple batch transforms