class CalmLightBrownKitten(QCAlgorithm):

def Initialize(self):

self.SetStartDate(2020, 1, 1) # Set Start Date

self.SetEndDate(2021 , 1 , 1)

self.SetCash(1000) # Set Strategy Cash

self.btcusd = self.AddCrypto("USDTUSD", Resolution.Minute , Market.FTX).Symbol

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

self.entryPrice = 0

self.nextEntryTime = self.Time

self.roc = self.ROC(self.btcusd, 6, Resolution.Hour)

# History warm up for shortcut helper SMA indicator

closing_prices = self.History(self.btcusd, 6, Resolution.Hour)["close"]

for time, price in closing_prices.loc[self.btcusd].item():

self.roc.Update(time, price)

self.RegisterIndicator(self.btcusd, self.roc, Resolution.Daily)

def OnData(self, data):

#usdt_price = data[self.btcusd].Price

self.Securities["USDTUSD"].Price

#self.Log(f"Time: {self.Time}; Price: {usdt_price};")

history = self.History(self.btcusd, 6, Resolution.Hour)

if not self.Portfolio.Invested:

if self.roc.Current.Value < -0.01:

if self.nextEntryTime <= self.Time:

self.Invested = self.SetHoldings(self.btcusd, 1)

self.Log("BUY USDTUSD @" + str(usdt_price))

self.entryPrice = usdt_price

if self.entryPrice * 0.01 < usdt_price:

self.Liquidate()

self.Log("SELL USDTUSD @" + str(usdt_price))

self.nextEntryTime = self.Time + self.period