Lean
Lean copied to clipboard
OrderCommand null reference because no data
Expected Behavior
- Order is placed or rejected correctly
Actual Behavior
2022-07-27T20:40:24.8865635Z ERROR:: BacktestingBrokerage.Scan(): System.NullReferenceException: Object reference not set to an instance of an object.
at QuantConnect.Orders.Fills.EquityFillModel.IsExchangeOpen(Security asset, Boolean isExtendedMarketHours) in Lean/Common/Orders/Fills/EquityFillModel.cs:line 1033
at QuantConnect.Orders.Fills.EquityFillModel.MarketFill(Security asset, MarketOrder order) in Lean/Common/Orders/Fills/EquityFillModel.cs:line 236
at QuantConnect.Orders.Fills.EquityFillModel.Fill(FillModelParameters parameters) in Lean/Common/Orders/Fills/EquityFillModel.cs:line 71
at QuantConnect.Brokerages.Backtesting.BacktestingBrokerage.Scan() in Lean/Brokerages/Backtesting/BacktestingBrokerage.cs:line 379
Potential Solution
- Check for null data point in the EquityFillModel
- The OrderCommand could also run pre submittion order checks, like done by the QCAlgorithm layer
Reproducing the Problem
- Deploy Live
- Add TSLA
- Placed order for TSLA
- If it didn't have any data yet null referenced at https://github.com/QuantConnect/Lean/blob/master/Common/Orders/Fills/EquityFillModel.cs#L1033 currentBar being null
System Information
N/A
Checklist
- [x] I have completely filled out this template
- [x] I have confirmed that this issue exists on the current
masterbranch - [x] I have confirmed that this is not a duplicate issue by searching issues
- [x] I have provided detailed steps to reproduce the issue