diff --git a/tests/finance/test_slippage.py b/tests/finance/test_slippage.py index 92c4611f..a3183ab7 100644 --- a/tests/finance/test_slippage.py +++ b/tests/finance/test_slippage.py @@ -52,10 +52,11 @@ class SlippageTestCase(TestCase): slippage_model = VolumeShareSlippage() open_orders = {133: [ - Order( - {'dt': datetime.datetime(2006, 1, 5, 14, 30, tzinfo=pytz.utc), - 'amount': 100, - 'filled': 0, 'sid': 133}) + Order(**{ + 'dt': datetime.datetime(2006, 1, 5, 14, 30, tzinfo=pytz.utc), + 'amount': 100, + 'filled': 0, + 'sid': 133}) ]} txn = slippage_model.simulate( diff --git a/zipline/gens/tradesimulation.py b/zipline/gens/tradesimulation.py index e830926a..6dea9329 100644 --- a/zipline/gens/tradesimulation.py +++ b/zipline/gens/tradesimulation.py @@ -28,10 +28,19 @@ log = Logger('Trade Simulation') class Order(object): - - def __init__(self, initial_values=None): - if initial_values: - self.__dict__ = initial_values + def __init__(self, dt, sid, amount, filled=0): + """ + @dt - datetime.datetime that the order was placed + @sid - stock sid of the order + @amount - the number of shares to buy/sell + a positive sign indicates a buy + a negative sign indicates a sell + @filled - how many shares of the order have been filled so far + """ + self.dt = dt + self.sid = sid + self.amount = amount + self.filled = filled class TradeSimulationClient(object): @@ -177,7 +186,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 = Order({ + order = Order(**{ 'dt': self.simulation_dt, 'sid': sid, 'amount': int(amount),