From 372a714eb8296618f9de179a48847ae10db8a8d4 Mon Sep 17 00:00:00 2001 From: fawce Date: Tue, 5 Feb 2013 21:41:15 -0500 Subject: [PATCH] deleting the portfolio object from every event. --- zipline/gens/tradesimulation.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zipline/gens/tradesimulation.py b/zipline/gens/tradesimulation.py index df698e13..e830926a 100644 --- a/zipline/gens/tradesimulation.py +++ b/zipline/gens/tradesimulation.py @@ -256,6 +256,14 @@ class AlgorithmSimulator(object): """ # Update our portfolio. self.algo.set_portfolio(event.portfolio) + # the portfolio is modified by each event passed into the + # performance tracker (prices and amounts can change). + # Performance tracker sends back an up-to-date portfolio + # with each event. However, we provide the portfolio to + # the algorithm via a setter method, rather than as part + # of the event data sent to handle_data. To avoid + # confusion, we remove it from the event here. + del event.portfolio # Update our knowledge of this event's sid sid_data = self.universe[event.sid]