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]