Hi All,
I'm relatively new to quantconnect and object oriented programming. I'm attempting to replace the MACD indicator use in the example MacdAlphaModel.py with a donchian channel. I've followed the structure as closely as possible but have received this error:
Runtime Error: TypeError : No constructor matches given arguments: (, , ) at __init__ self.donchian = DonchianChannel(upperBand in Alpha6.py:line 35 TypeError : No constructor matches given arguments: (, , )
Any help as to how to fix this would be great.
Thankyou!
Code:
class Donchian6(AlphaModel):
def __init__(self, lowerBand = 55, upperBand = 55, resolution = Resolution.Daily):
self.lowerBand = lowerBand
self.upperBand = upperBand
self.resolution = resolution
self.insightPeriod = Time.Multiply(Extensions.ToTimeSpan(resolution), upperBand)
self.symbolData = {}
resolutionString = Extensions.GetEnumString(resolution, Resolution)
self.Name = '{}({},{},{})'.format(self.__class__.__name__, lowerBand, upperBand, resolutionString)
def Update(self, algorithm, data):
insights = []
return insights
def OnSecuritiesChanged(self, algorithm, changes):
for added in changes.AddedSecurities:
self.symbolData[added.Symbol] = SymbolData(algorithm, added, self.lowerBand, self.upperBand, self.resolution)
for removed in changes.RemovedSecurities:
data = self.symbolData.pop(removed.Symbol, None)
if data is not None:
algorithm.SubscriptionManager.RemoveConsolidator(removed.Symbol, data.Consolidator)
class SymbolData:
def __init__(self, algorithm, security, lowerBand, upperBand, resolution):
self.Security = security
self.donchian = DonchianChannel(upperBand, lowerBand, resolution)
self.Consolidator = algorithm.ResolveConsolidator(security.Symbol, resolution)
algorithm.RegisterIndicator(security.Symbol, self.donchian, self.Consolidator)
Varad Kabade
Hi Nicholas Fitzgerald,
While using creating indicators using the Indicator constructor, we don't need to specify the resolution. Change the following indicator constructor line to the following to resolve the issue:
Best,
Varad Kabade
Nicholas Fitzgerald
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!