From 2a981dc7257295f40f8f6e10b0e456b8429a5734 Mon Sep 17 00:00:00 2001 From: Jean Bredeche Date: Thu, 21 Apr 2016 15:06:25 -0400 Subject: [PATCH] BUG: Restoring 'broker_order_id' to Order's dict More long-term fix is coming later, this restores existing downstream behavior. --- zipline/finance/order.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zipline/finance/order.py b/zipline/finance/order.py index 905c2acf..7a5befdd 100644 --- a/zipline/finance/order.py +++ b/zipline/finance/order.py @@ -34,6 +34,8 @@ BUY = 1 << 1 STOP = 1 << 2 LIMIT = 1 << 3 +ORDER_FIELDS_TO_IGNORE = {'type', 'direction', '_status'} + class Order(object): # using __slots__ to save on memory usage. Simulations can create many @@ -71,6 +73,7 @@ class Order(object): self.limit_reached = False self.direction = math.copysign(1, self.amount) self.type = zp.DATASOURCE_TYPE.ORDER + self.broker_order_id = None def make_id(self): return uuid.uuid4().hex @@ -78,8 +81,11 @@ class Order(object): def to_dict(self): dct = {name: getattr(self, name) for name in self.__slots__ - if name not in {'type', 'direction', '_status', - 'broker_order_id'}} + if name not in ORDER_FIELDS_TO_IGNORE} + + if self.broker_order_id is None: + del dct['broker_order_id'] + dct['status'] = self.status return dct