MAINT: Change signature of create_transaction.

- Change the expected type for order information from the string
  of the order id to an `Order` object, so that it matches the same
  abstraction level as passing in an event.
- Change the order (not to be confused with the parameter named `order`)
  of the parameters so that they go from left to right in order of
  static -> dynamic, i.e. the parameters most likely to change within
  each invoration are the amount and price, with amount more likely
  to change than price.
This commit is contained in:
Eddie Hebert
2013-06-10 17:10:48 -04:00
parent 7d26168359
commit 2b5b670493
2 changed files with 8 additions and 7 deletions
+2 -1
View File
@@ -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):
+6 -6
View File
@@ -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