Overall Statistics
class FrameworkAlgorithm(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2019, 1, 1)   
        self.SetEndDate(2020, 4, 13)    
        self.SetCash(10000)           
            
        # Add securities
        self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.tlt = self.AddEquity("TLT", Resolution.Daily).Symbol
        
        # Setup highest high indicator
        lookback = 252
        self.highest_high = self.MAX(self.spy, lookback, Resolution.Daily, Field.High)
        self.SetWarmup(lookback, Resolution.Daily)
        
        
    def OnData(self, data):
        if not data.Bars.ContainsKey("SPY"):
            return
        
        # First entry
        if not self.Portfolio.Invested:
            self.SetHoldings("SPY", 0.60)
            self.SetHoldings("TLT", 0.40)
            return
        
        # Calculate hwm and drawdown
        hwm = self.highest_high.Current.Value
        drawdown = (data.Bars["SPY"].Close - hwm) / hwm

        # Rebalancing        
        if drawdown < -0.10:
            self.SetHoldings("SPY", 0.60)
            self.SetHoldings("TLT", 0.40)