Yesterday my script tried to execute an order, but got a error message back from the broker. Which is fine, the error was actually valid, but I just figured I need to capture this error and treat it.
Question goes: how can I capture an order execution failure at the same moment I executed the order, I could always check position if flat on the next bar update, but I need a more real time control. Can that be captured on OnBarUpdate right after the execution command (Enterlong, entershort), like in a try catch? Or can I capture if the order was executed successfully on the event OnExecution?
What would you guys recommend?
thank you,
Rodrigo
Comment