I want to pas a tag to an order ticket that is then printed when the order is executed.

tag_str = f'Exit Reason...'
self.MarketOrder(ticker,-qty,tag=tag_str)

When I get the ticket back in the OnOrderEvent the Tag is empty:

def OnOrderEvent(self, orderEvent):
        ticket = self.Transactions.GetOrderTicket(orderEvent.OrderId)
        if orderEvent.Status == OrderStatus.Filled:
          self.Debug(f'{self.Time}: Trade: {ticket.Symbol}, Qty:{ticket.Quantity}, Price:{ticket.AverageFillPrice}. {ticket.Tag}')

The Debug statement does not print out the Tag. Am I doing something wrong?

 

Author