Lean icon indicating copy to clipboard operation
Lean copied to clipboard

System.Exception: Attempted to divide by zero. in LogReturn indicator

Open superichmann opened this issue 2 years ago • 0 comments

 System.Exception: Attempted to divide by zero. in LogReturn.cs:line 60
 ---> QuantConnect.Exceptions.SystemExceptionInterpreter+SanitizedException: Attempted to divide by zero.
   at System.Decimal.DecCalc.VarDecDiv(DecCalc& d1, DecCalc& d2)
   at QuantConnect.Indicators.LogReturn.ComputeNextValue(IReadOnlyWindow`1 window, IndicatorDataPoint input) in Indicators\LogReturn.cs:line 60
   at QuantConnect.Indicators.IndicatorBase`1.ValidateAndComputeNextValue(T input) in Indicators\IndicatorBase.cs:line 340
   at QuantConnect.Indicators.IndicatorBase`1.Update(IBaseData input) in Indicators\IndicatorBase.cs:line 259
   at QuantConnect.Algorithm.QCAlgorithm.<>c__DisplayClass580_0.<RegisterIndicator>b__1(Object sender, IBaseData consolidated) in Algorithm\QCAlgorithm.Indicators.cs:line 2428
   at QuantConnect.Data.Consolidators.DataConsolidator`1.OnDataConsolidated(IBaseData consolidated) in Common\Data\Consolidators\DataConsolidator.cs:line 109
   at QuantConnect.Data.Consolidators.IdentityDataConsolidator`1.Update(T data) in Common\Data\Consolidators\IdentityDataConsolidator.cs:line 60
   at QuantConnect.Lean.Engine.AlgorithmManager.Run(AlgorithmNodePacket job, IAlgorithm algorithm, ISynchronizer synchronizer, ITransactionHandler transactions, IResultHandler results, IRealTimeHandler realtime, ILeanManager leanManager, CancellationToken token) in Engine\AlgorithmManager.cs:line 600

Maybe on this opportunity check all of the indicators for this bug? this is the third case I am opening in the past month for indicator bugs.

Expected Behavior

the strategy should continue running and not crash

Actual Behavior

the strategy crash

Potential Solution

make it so not crash

Reproducing the Problem

:{

System Information

windows 10 .NET 6

Checklist

  • [ ] I have completely filled out this template
  • [ ] I have confirmed that this issue exists on the current master branch
  • [ ] I have confirmed that this is not a duplicate issue by searching issues
  • [ ] I have provided detailed steps to reproduce the issue

superichmann avatar Feb 14 '24 10:02 superichmann