Lean icon indicating copy to clipboard operation
Lean copied to clipboard

ZeroDivisionError in FundamentalUniverseSelectionModel.py line 46

Open fcnorman opened this issue 6 years ago • 0 comments

Expected Behavior

More elegant handling of ZeroDivisionError.

Actual Behavior

ZeroDivisionError thrown.

Potential Solution

Solution is to check for zero. If zero found, handle the error.

Reproducing the Problem

Runtime Error: ZeroDivisionError : float division by zero at in FundamentalUniverseSelectionModel.py:line 46 at SelectFine in QC500UniverseSelectionModel.py:line 75 :: percent = self.numberOfSymbolsFine/float(len(sortedBySector)) ZeroDivisionError : float division by zero Stack Trace: System.Exception: ZeroDivisionError : float division by zero at in FundamentalUniverseSelectionModel.py:line 46 at SelectFine in QC500UniverseSelectionModel.py:line 75 :: percent = self.numberOfSymbolsFine/float(len(sortedBySector)) ---> Python.Runtime.PythonException: ZeroDivisionError : float division by zero at Python.Runtime.Dispatcher.Dispatch (System.Collections.ArrayList args) [0x00018] in :0 at __System_Func2\[\[System_Collections_Generic_IEnumerable1[[QuantConnect_Data_Fundamental_FineFundamental, QuantConnect_Common, Version=2_4_0_0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4_0_0_0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[QuantConnect_Symbol[], QuantConnect_Common, Version=2_4_0_0, Culture=neutral, PublicKeyToken=null]]Dispatcher.Invoke (System.Collections.Generic.IEnumerable`1[T] ) [0x0000f] in :0 at QuantConnect.Data.UniverseSelection.FineFundamentalUniverse.SelectSymbols (System.DateTime utcTime, QuantConnect.Data.UniverseSelection.BaseDataCollection data) [0x00011] in :0 at QuantConnect.Data.UniverseSelection.Universe.PerformSelection (System.DateTime utcTime, QuantConnect.Data.UniverseSelection.BaseDataCollection data) [0x0000e] in :0 at QuantConnect.Lean.Engine.DataFeeds.UniverseSelection.ApplyUniverseSelection (QuantConnect.Data.UniverseSelection.Universe universe, System.DateTime dateTimeUtc, QuantConnect.Data.UniverseSelection.BaseDataCollection universeData) [0x00308] in :0 at QuantConnect.Lean.Engine.DataFeeds.SubscriptionSynchronizer+d__10.MoveNext () [0x00349] in :0 at QuantConnect.Lean.Engine.DataFeeds.LiveSynchronizer+d__5.MoveNext () [0x0009c] in :0 --- End of inner exception stack trace ---

System Information

From running Alpha stream algo.

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

fcnorman avatar Jan 02 '20 20:01 fcnorman