From 6f6434cf513bedb93f5d0a393930048c54d27a35 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 23 Jan 2013 09:21:59 -0500 Subject: [PATCH] Converts slippage orders to use a simple object. Reducing the number of ndicts that are created, so that profiling has less noise. --- zipline/gens/tradesimulation.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zipline/gens/tradesimulation.py b/zipline/gens/tradesimulation.py index 4cf41196..109e2796 100644 --- a/zipline/gens/tradesimulation.py +++ b/zipline/gens/tradesimulation.py @@ -26,6 +26,13 @@ from zipline.gens.utils import hash_args log = Logger('Trade Simulation') +class Order(object): + + def __init__(self, initial_values=None): + if initial_values: + self.__dict__ = initial_values + + class TradeSimulationClient(object): """ Generator-style class that takes the expected output of a merge, a @@ -169,7 +176,7 @@ class AlgorithmSimulator(object): Closure to pass into the user's algo to allow placing orders into the transaction simulator's dict of open orders. """ - order = ndict({ + order = Order({ 'dt': self.simulation_dt, 'sid': sid, 'amount': int(amount),