diff --git a/tests/test_perf_tracking.py b/tests/test_perf_tracking.py index 659e9677..bc043f67 100644 --- a/tests/test_perf_tracking.py +++ b/tests/test_perf_tracking.py @@ -42,7 +42,8 @@ tradingday = datetime.timedelta(hours=6, minutes=30) def create_txn(event, price, amount): - return create_transaction(event, amount, price, "fakeuid") + mock_order = Order(None, None, event.sid, id=None) + return create_transaction(event, mock_order, price, amount) def benchmark_events_in_range(sim_params): diff --git a/zipline/finance/slippage.py b/zipline/finance/slippage.py index f8ed0f13..82fdb46a 100644 --- a/zipline/finance/slippage.py +++ b/zipline/finance/slippage.py @@ -99,14 +99,14 @@ class Transaction(object): return py -def create_transaction(event, amount, price, order_id): +def create_transaction(event, order, price, amount): txn = { 'sid': event.sid, 'amount': int(amount), 'dt': event.dt, 'price': price, - 'order_id': order_id + 'order_id': order.id } transaction = Transaction(**txn) @@ -189,11 +189,11 @@ class VolumeShareSlippage(SlippageModel): if order.direction * cur_amount > 0: txn = create_transaction( event, - cur_amount, + order, # In the future, we may want to change the next line # for limit pricing event.price + simulated_impact, - order.id + cur_amount ) txns.append(txn) @@ -228,9 +228,9 @@ class FixedSlippage(SlippageModel): txn = create_transaction( event, - order.amount, + order, event.price + (self.spread / 2.0 * order.direction), - order.id + order.amount, ) # mark the date of the order to match the transaction