Overall Statistics
Total Trades
1157
Average Win
1.78%
Average Loss
-0.28%
Compounding Annual Return
50.982%
Drawdown
45.400%
Expectancy
3.331
Net Profit
9437.558%
Sharpe Ratio
1.606
Probabilistic Sharpe Ratio
78.691%
Loss Rate
41%
Win Rate
59%
Profit-Loss Ratio
6.29
Alpha
0.339
Beta
1.851
Annual Standard Deviation
0.395
Annual Variance
0.156
Information Ratio
1.728
Tracking Error
0.275
Treynor Ratio
0.343
Total Fees
$53838.72
Estimated Strategy Capacity
$6600.00
# found on QuantConnect 
# Inspired by the theory here:
# https://seekingalpha.com/article/4299701-leveraged-etfs-for-long-term-investing
# https://www.quantconnect.com/forum/discussion/7708/using-levered-etfs-in-ira-10-years-24-cagr-1-56-sharpe/p1
# 3x Long TQQQ TMF and UGLD. Using a QQQ SMA200 to determine allocations.

class TQQQTMFUGLwithQQQtimer(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2010, 3, 1)
        #self.SetEndDate(2010, 1, 1)
        self.SetCash(100000) 
        self.qqq = self.AddEquity("QQQ", Resolution.Hour)
        self.tlt = self.AddEquity("TLT", Resolution.Hour)
        self.AddEquity("TQQQ", Resolution.Hour)    # 3x QQQ
        self.AddEquity("TYD", Resolution.Hour)    # 3x 10 yr Treasury
        self.AddEquity("TMF", Resolution.Hour)      # 3x 20yr Treasury
        self.qqqstd = self.STD("QQQ", 100, Resolution.Daily)
        self.tltstd = self.STD("TLT", 100, Resolution.Daily)
        self.SetWarmUp(100)      # warm up the indicator
        self.Schedule.On(self.DateRules.WeekStart("QQQ"), self.TimeRules.AfterMarketOpen("QQQ", 30), self.Rebalance)
        self.SetRiskManagement(MaximumUnrealizedProfitPercentPerSecurity(0.2))

    def OnData(self, data):
        if data.ContainsKey("QQQ") == False: return     # make sure we have data for trading symbols
        if data.ContainsKey("TQQQ") == False: return
        if data.ContainsKey("TLT") == False: return
    
    def Rebalance(self):
        if self.qqqstd.Current.Value < self.tltstd.Current.Value:
            self.SetHoldings("TQQQ", 1)
            self.SetHoldings("TMF", 0)
            self.SetHoldings("TYD", 0)
            self.Debug("Bullish - TQQQ 100%")
        else:
            self.SetHoldings("TQQQ", 0.5)
            self.SetHoldings("TMF", 0.25)
            self.SetHoldings("TYD", 0.25)
            self.Debug("Bearish - TQQQ 50%, TMF 25%, TYD 25%")