Missing module and won't backtest. Any ideas?
import quantconnect
from quantconnect import *
from quantconnect import QCAlgorithm
from decimal import Decimal
from QuantConnect.Data.Consolidators import WeekendConsolidator
class WeekendTradingAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1)
self.SetEndDate(2022, 1, 1)
self.SetCash(100000)
self.symbol = self.AddCrypto("ETHUSD").Symbol
self.stop_loss = Decimal("0.01")
self.take_profit = Decimal("0.01")
self.weekend_close_price = None
self.weekend_consolidator = WeekendConsolidator(timedelta(days=1))
self.weekend_consolidator.DataConsolidated += self.OnWeekendData
self.SubscriptionManager.AddConsolidator(self.symbol, self.weekend_consolidator)
def OnWeekendData(self, sender, bar):
# Check if the current bar is the last bar of the week
if bar.EndTime.dayofweek == 4:
self.weekend_close_price = bar.Close
elif bar.EndTime.dayofweek == 5:
self.weekend_close_price = None
if self.weekend_close_price is not None:
if bar.Close > self.weekend_close_price:
self.SetHoldings(self.symbol, 1)
Nico Xenox
Hey Chris D,
you don’t need Decimal change it to float() and delete the decimal import
hope that helps ;)
Best,
Nico
Chris D
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!