From 48a7ce5310cbd68b5a7662bffe7dfcf0881ed983 Mon Sep 17 00:00:00 2001 From: Jonathan Kamens Date: Wed, 29 May 2013 12:46:24 -0400 Subject: [PATCH] BUG: Improve check for orders for zero shares The check to filter out orders for zero shares wasn't truncated the number of shares to an integer before checking, so if a fractional amount less than 1 was being passed in, it wasn't being filtered out even though it should have been. This is now fixed. --- zipline/finance/blotter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zipline/finance/blotter.py b/zipline/finance/blotter.py index 11fd8694..bc69f5b1 100644 --- a/zipline/finance/blotter.py +++ b/zipline/finance/blotter.py @@ -86,6 +86,9 @@ class Blotter(object): StopLimit order: order(sid, amount, limit_price, stop_price) """ + # Fractional shares are not supported. + amount = int(amount) + # just validates amount and passes rest on to TransactionSimulator # Tell the user if they try to buy 0 shares of something. if amount == 0: @@ -99,7 +102,7 @@ class Blotter(object): order = Order(**{ 'dt': self.current_dt, 'sid': sid, - 'amount': int(amount), + 'amount': amount, 'filled': 0, 'stop': stop_price, 'limit': limit_price,