Overall Statistics
Total Trades
158
Average Win
0.06%
Average Loss
-0.01%
Compounding Annual Return
14.494%
Drawdown
9.600%
Expectancy
3.921
Net Profit
25.272%
Sharpe Ratio
1.366
Probabilistic Sharpe Ratio
62.599%
Loss Rate
22%
Win Rate
78%
Profit-Loss Ratio
5.29
Alpha
0.151
Beta
0.01
Annual Standard Deviation
0.112
Annual Variance
0.012
Information Ratio
-0.057
Tracking Error
0.296
Treynor Ratio
15.556
Total Fees
$177.45
# Inspired by thhttps://www.quantconnect.com/terminal/#3f7518ec0cc8cd17698cd8995834bd7b-Tabe theory here:
# https://seekingalpha.com/article/4299701-leveraged-etfs-for-long-term-investing

class MultidimensionalTransdimensionalPrism(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 12, 1)               # Earliest start date for all ETFs in universe 2/1/10
        #self.SetStartDate(2020, 3, 30)
        self.SetEndDate(2020, 7, 30)
        self.SetCash(100000) 
        self.AddEquity("TAIL", Resolution.Hour)    # 3x QQQ
        self.AddEquity("SWAN", Resolution.Hour)     # 3x 20yr Treasury
        #self.AddEquity("UST", Resolution.Hour)     # 3x 10yr Treasury
        #self.AddEquity("TLT", Resolution.Hour)     # 3x 20yr Treasury
        #self.AddEquity("IEF", Resolution.Hour)     # 3x 20yr Treasury
        self.AddEquity("Vixm", Resolution.Hour)    # 2x VIX
        #self.tkr = ["TQQQ", "UBT", "UST", "VXX"]
        self.tkr = ["TAIL", "SWAN"]
        
        self.rebal = 1                              # Rebalance every 2 weeks
        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("SWAN"), self.TimeRules.AfterMarketOpen("SWAN", 150), self.Rebalance)
        #self.Schedule.On(self.DateRules.EveryDay("UST"), self.TimeRules.AfterMarketOpen("UST", 150), self.Rebalance)
 

    def OnData(self, data):
        # If ready to rebalance, set each holding at 1/3
        if self.flag1 == 1:                     
            for stock in self.tkr:
                if stock == "TAIL":
                    weight = 0.25
                else:
                    weight = 0.75
                self.SetHoldings(stock, weight)
            self.rebalTimer = 0                     # Reset rebalance timer
        self.flag1 = 0          
        
    def Rebalance(self):
        self.rebalTimer +=1
        if self.rebalTimer == self.rebal:
            self.flag1 = 1