The code is trying to access the index of an empty collection:
var symbol = order.OrderLegCollections[0].Instrument.Symbol;
Runtime error:
2023-04-21T18:47:22.5256253Z ERROR:: BrokerageSetupHandler.LoadExistingHoldingsAndOrders(): System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at System.Collections.Generic.List`1.get_Item(Int32 index)
at QuantConnect.Brokerages.TDAmeritrade.Utils.Extensions.ConvertOrder(OrderModel order) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean.Brokerages.TDAmeritrade/QuantConnect.TDAmeritrade/Utils/Extensions.cs:line 198
at QuantConnect.Brokerages.TDAmeritrade.TDAmeritradeBrokerage.GetOpenOrders() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean.Brokerages.TDAmeritrade/QuantConnect.TDAmeritrade/TDAmeritradeBrokerage.cs:line 248
at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.GetOpenOrders(IAlgorithm algorithm, IResultHandler resultHandler, ITransactionHandler transactionHandler, IBrokerage brokerage, HashSet`1 supportedSecurityTypes) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BrokerageSetupHandler.cs:line 524
at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.LoadExistingHoldingsAndOrders(IBrokerage brokerage, IAlgorithm algorithm, SetupHandlerParameters parameters) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BrokerageSetupHandler.cs:line 399
Potential Solution
N/A
Reproducing the Problem
Live algorithm fetching open order.
Checklist
[x] I have completely 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
[x] I have provided detailed steps to reproduce the issue
Expected Behavior
Unhandled exceptions should be avoided.
Actual Behavior
The code is trying to access the index of an empty collection:
Runtime error:
Potential Solution
N/A
Reproducing the Problem
Live algorithm fetching open order.
Checklist
master
branch