Overall Statistics
import numpy as np
from datetime import timedelta

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017, 1, 1)
        self.SetEndDate(2018, 2, 1)
        self.SetCash(10000)
        self.symbol = "BTCUSD"
        self.fast_ma_period = 50
        self.slow_ma_period = 200
        self.SetWarmUp(timedelta(days= 50))        
        Crypto = self.AddCrypto(self.symbol, Resolution.Hour).Symbol
        
        self.FastMA = self.SMA(Crypto, self.fast_ma_period, Resolution.Hour)
        self.FastMAValues = RollingWindow[Decimal](2)
        
        self.SlowMA = self.SMA(Crypto, self.slow_ma_period, Resolution.Hour)
        self.SlowMAValues = RollingWindow[Decimal](2)
    
    def OnData(self, data):
        if self.IsWarmingUp: return
        self.FastMAValues.Add(self.FastMA.Current.Value)
        self.SlowMAValues.Add(self.SlowMA.Current.Value)
        if self.FastMAValues.IsReady and self.SlowMAValues.IsReady:
            if self.FastMAValues[1] <= self.SlowMAValues[1]:
                if not self.Portfolio.Invested and self.Portfolio.CashBook["BTC"].Amount == 0:
                        self.Buy("BTCUSD", 2)
            else:
                if self.Portfolio.CashBook["BTC"].Amount > 0:
                    self.Liquidate("BTCUSD")