Back

"Runtime Error: Cannot convert null to 'bool'......"?

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)

 

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hey there! This should have never worked as you are not returning whether the indicator is ready from the Update function. We're aware it worked earlier in the year but not sure how =)

Fix is just add "return self.IsReady" to the end of your Update method. 

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed