def create_txn(trade_event, price, amount): """ Create a fake transaction to be filled and processed prior to the execution of a given trade event. """ mock_order = Order(trade_event.dt, trade_event.sid, amount, id=None) return create_transaction(trade_event, mock_order, price, amount)
def process_order(self, trade_bar, my_order): spread = self.spreads[my_order.sid] # In this model, the slippage is going to be half of the spread for # the particular stock slip_amount = spread / 2 # Compute the price impact of the transaction. Size of price impact is # proprotional to order size. # A buy will increase the price, a sell will decrease it. new_price = trade_bar.price + (slip_amount * my_order.direction) log.info('executing order ' + str(trade_bar.sid) + ' stock bar price: ' + \ str(trade_bar.price) + ' and trade executes at: ' + str(new_price)) # Create the transaction using the new price we've calculated. return zpSlippage.create_transaction(trade_bar, my_order, new_price, my_order.amount)
def process_order(self, trade_bar, my_order): spread = self.spreads[my_order.sid] # In this model, the slippage is going to be half of the spread for # the particular stock slip_amount = spread / 2 # Compute the price impact of the transaction. Size of price impact is # proprotional to order size. # A buy will increase the price, a sell will decrease it. new_price = trade_bar.price + (slip_amount * my_order.direction) log.info('executing order ' + str(trade_bar.sid) + ' stock bar price: ' + \ str(trade_bar.price) + ' and trade executes at: ' + str(new_price)) # Create the transaction using the new price we've calculated. return zpSlippage.create_transaction( trade_bar, my_order, new_price, my_order.amount )
def create_txn(event, price, amount): mock_order = Order(None, None, event.sid, id=None) txn = create_transaction(event, mock_order, price, amount) txn.source_id = 'MockTransactionSource' return txn
def create_txn(event, price, amount): mock_order = Order(None, None, event.sid, id=None) return create_transaction(event, mock_order, price, amount)
def create_txn(sid, price, amount, dt): return create_transaction(sid, amount, price, dt, "fakeuid")