From efadc6cf68adb405960fc415b5d15c67e18b1158 Mon Sep 17 00:00:00 2001 From: Jonathan Kamens Date: Thu, 30 May 2013 11:24:29 -0400 Subject: [PATCH] MAINT: blotter shouldn't allow orders of more than 1e+11 shares --- zipline/finance/blotter.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zipline/finance/blotter.py b/zipline/finance/blotter.py index bc69f5b1..c3ad52d3 100644 --- a/zipline/finance/blotter.py +++ b/zipline/finance/blotter.py @@ -52,6 +52,7 @@ class Blotter(object): # event. self.new_orders = [] self.current_dt = None + self.max_shares = int(1e+11) def __repr__(self): return """ @@ -98,6 +99,11 @@ class Blotter(object): log.debug(zero_message) # Don't bother placing orders for 0 shares. return + elif amount > self.max_shares: + # Arbitrary limit of 100 billion (US) shares will never be + # exceeded except by a buggy algorithm. + raise OverflowError('Can\'t order more than %d shares' % + self.max_shares) order = Order(**{ 'dt': self.current_dt,