I have continuously received the following error when attempting to backtest and do not know how to resolve it:

Error Message

[ERROR] FATAL UNHANDLED EXCEPTION:Engine.Run(): Error running algorithm System.ArgumentException: Unable to locate next market open within two weeks.,   at QuantConnect.Securities.SecurityExchangeHours.GetNextMarketOpen(DateTime localDateTime, Boolean extendedMarketHours) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Common/Securities/SecurityExchangeHours.cs:line 320,   at QuantConnect.Scheduling.TimeRules.<>c__DisplayClass14_0.b__1(DateTime date) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Common/Scheduling/TimeRules.cs:line 172,   at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext(), atSystem.L∈q.Eνmerab≤.WhereSe≤ctEνmerab≤Itera→r2.MoveNext(),   at QuantConnect.Scheduling.ScheduledEvent.get_NextEventUtcTime() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Common/Scheduling/ScheduledEvent.cs:line 80,   at QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.<>c.b__11_0(KeyValuePair2x)∈LeanCloudCI.Builderb∈DebugsrcQuantCo∩ectLeanEnterpriseEng∈eRealTimeBacktest∈gRealTimeHand≤r.cs:l∈e158, atSystem.L∈q.Eνmerab≤Sorter2.ComputeKeys(TElement[] elements, Int32 count),   at System.Linq.EnumerableSorter1.ComputeMap(TE≤ment[]e≤ments,Int32count), atSystem.L∈q.Eνmerab≤Sorter1.Sort(TElement[] elements, Int32 count),   at System.Linq.OrderedEnumerable1.GetEνmera→r()+MoveNext(), atSystem.L∈q.Eνmerab≤.Se≤ctIPartitionItera→r2.ToList(),   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source),   at QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.GetScheduledEventsSortedByTime() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Engine/RealTime/BacktestingRealTimeHandler.cs:line 156,   at QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.Setup(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IApi api, IIsolatorLimitResultProvider isolatorLimitProvider) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Engine/RealTime/BacktestingRealTimeHandler.cs:line 52,   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath, WorkerThread workerThread) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Engine/Engine.cs:line 295

Author

Conrad Krol

June 2024