Hi guys, After this new version arrived I got this error can anyone look into it.
# Rolling Window Fractal Indicator (Binance)
CRYPTO = "USDCUSDT"; BAR = 60;
class BlackpantherFractal(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 5, 1)
self.SetEndDate(2022, 5, 3)
self.SetCash("USDT", 1000)
self.crypto = self.AddCrypto(CRYPTO, Resolution.Minute, Market.Binance).Symbol
self.SetSecurityInitializer(lambda s: s.SetLeverage(1))
self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin)
self.Consolidate(self.crypto, timedelta(minutes = BAR), self.CustomBarHandler)
self.window = RollingWindow[TradeBar](3)
self.consolidator = TradeBarConsolidator(timedelta(minutes=BAR))
self.SubscriptionManager.AddConsolidator(self.crypto, self.consolidator)
self.SetWarmUp(BAR, Resolution.Minute)
def CustomBarHandler(self, bar):
if self.IsWarmingUp: return
self.window.Add(bar)
if not self.window.IsReady: return
H = [self.window[i].High for i in range(3)]
L = [self.window[i].Low for i in range(3)]
C = [self.window[i].Close for i in range(3)]
curr_price = self.Securities[self.crypto].Price
if not self.Portfolio[self.crypto].IsLong:
if ( curr_price <= L[1] <= L[2]):
self.SetHoldings(self.crypto,1)
elif not self.Portfolio[self.crypto].IsShort:
if ( curr_price >= H[1] >= H[2]):
self.SetHoldings(self.crypto,-1)
problem :- During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/project/main.pyc. AlgorithmPythonWrapper(): name 'QCAlgorithm' is not defined at class BlackpantherFractal(QCAlgorithm): at Python.Runtime.PythonException.ThrowLastAsClrException() at Python.Runtime.NewReferenceExtensions.BorrowOrThrow(NewReference& reference) at Python.Runtime.PyModule.Import(String name) at Python.Runtime.Py.Import(String name) at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper..ctor(String moduleName) at AlgorithmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs:line 74 in main.py: line 4 name 'QCAlgorithm' is not defined
Louis Szeto
Hi Blackpanther
Please add the following line on top of your algorithm:
Best
Louis
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.
Vladimir
Blackpanther
Here it is.
Blackpanther
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!