Around three months ago, all my projects that used to be working fine suddenly start throwing the runtime error:

Cannot convert null to 'bool' because it is a non-nullable value type (Open Stacktrace)

This is really frustrating because nothing was done and yet it changed from working to broken just overnight. I am already reducing my code to the bare minimum but this is still happening. Does anyone have similar experience?

from numpy import sort
from numpy import mean
from numpy import std
from numpy import array
from numpy import argpartition
from numpy import zeros
from scipy.stats import skew
from collections import deque


class CustomSimpleMovingAverage:
def __init__(self, name, period):
self.Name = name
self.Time = datetime.min
self.Value = 0
self.IsReady = False
self.queue = deque(maxlen=period)

def __repr__(self):
return "{0} -> IsReady: {1}. Time: {2}. Value: {3}".format(self.Name, self.IsReady, self.Time, self.Value)

# Update method is mandatory
def Update(self, input):
self.queue.appendleft(input.Close)
count = len(self.queue)
self.Time = input.EndTime
self.Value = sum(self.queue) / count
self.IsReady = count == self.queue.maxlen

class DebugTest(QCAlgorithm):
LookBackLen = 150
tradeSize = 1.0
skewThreshold = 0.1
selectTopN = 3

def Initialize(self):
self.SetStartDate(2010, 12, 12) # Set Start Date
self.SetCash(13000) # Set Strategy Cash

self.AddEquity("XLP", Resolution.Daily)

# Indicator
self.custom = CustomSimpleMovingAverage('custom', 60)
self.RegisterIndicator("XLP", self.custom, Resolution.Daily)

self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)

def OnData(self, data):
for i in range(self.selectTopN):
self.SetHoldings("XLP", 1.0)