Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Unexpected Order Event Handling

Open jaredbroad opened this issue 2 years ago • 1 comments

Expected Behavior

Settings.UnexpectedOrderEventsHandling 
    = UnexpectedOrder.Ignore       # Drop without matching order id.
    = UnexpectedOrder.Merge       # Add asset; accept the fill.
    = UnexpectedOrder.Shutdown # Default

void OnUnexpectedOrderEvent(UnexpectedOrderEvent event);

It could allow users to manually enter with intelligent risk control exits. Or reusing the same UUID in FIX networks.

Actual Behavior

Always shuts down strategy.

Potential Solution

In the fill handling add the additional options above and act based on the setting of the strategy.

Reproducing the Problem

Placing a trade in the OANDA cloud terminal while running a live Oanda algorithm

Checklist

  • [x] I have filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues

jaredbroad avatar Sep 26 '23 14:09 jaredbroad

The IBrokerageMessageHandler already allows this functionality, overriding the HandleOrder and setting a custom behavior, see for example https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/CustomBrokerageSideOrderHandlingRegressionPartialAlgorithm.py. By default orders are rejected TODO here: Brokerages should now trigger the new OnNewBrokerageOrderNotification base method to trigger the functionality

Martin-Molinero avatar Jun 07 '24 14:06 Martin-Molinero