mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-24 13:00:57 +08:00
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:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user