Overall Statistics
Total Trades
87
Average Win
20.43%
Average Loss
-3.08%
Compounding Annual Return
27.386%
Drawdown
51.500%
Expectancy
2.813
Net Profit
1166.100%
Sharpe Ratio
0.841
Probabilistic Sharpe Ratio
17.689%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
6.63
Alpha
0.131
Beta
1.4
Annual Standard Deviation
0.36
Annual Variance
0.13
Information Ratio
0.617
Tracking Error
0.293
Treynor Ratio
0.216
Total Fees
$5030.15
#take the paper "Leverage For The Long Run", use a 200 SMA on SPY to generate weekly buy/sell signals to either go long 3x leveraged assets or cash.

class LeverageForTheLongRunDiversifiedWeekly(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2010,3, 1)  #Set Start Date
        self.SetEndDate(2020,8,20)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash
        self.spy = self.AddEquity("SPY", Resolution.Daily)
        self.Securities["SPY"].SetDataNormalizationMode(DataNormalizationMode.Raw);
        self.tqqq = self.AddEquity("TQQQ", Resolution.Hour)
        self.shy = self.AddEquity("SHY", Resolution.Hour)
        self.sma = self.SMA("SPY", 200, Resolution.Daily)
        self.SetWarmUp(200)      # warm up the indicator
        self.Settings.FreePortfolioValuePercentage = 0.05
        
        # Rebalancing logic
        self.rebal = 1                              # Rebalance every 1 week
        self.rebalTimer = self.rebal - 1            # Initialize to trigger first week
        self.flag1 = 0                              # Flag to initate trades
        
        # Increment rebalance timer at every week start
        self.Schedule.On(self.DateRules.WeekStart("SPY"), self.TimeRules.AfterMarketOpen("SPY", 60), self.Rebalance)
        
    def OnData(self, data):
        
        if not self.sma.IsReady: return
        if data.ContainsKey("SPY") == False: return     # make sure we have data for trading symbols
        if data.ContainsKey("TQQQ") == False: return
        if data.ContainsKey("SHY") == False: return
        
        if self.flag1 == 1:                     
            if data[self.spy.Symbol].Close > self.sma.Current.Value:
                self.SetHoldings("TQQQ", 1, True)
                self.Debug("long equities")
                self.rebalTimer = 0     # Reset rebalance timer
            if data[self.spy.Symbol].Close < self.sma.Current.Value:
                self.SetHoldings("SHY", 1, True)
                self.Debug("go to cash")
                self.rebalTimer = 0     # Reset rebalance timer
        self.flag1 = 0          
        
    def Rebalance(self):
        self.rebalTimer +=1
        if self.rebalTimer == self.rebal:
            self.flag1 = 1