Overall Statistics
Total Trades
3911
Average Win
0.47%
Average Loss
-0.63%
Compounding Annual Return
5.541%
Drawdown
57.300%
Expectancy
0.100
Net Profit
194.290%
Sharpe Ratio
0.483
Probabilistic Sharpe Ratio
0.906%
Loss Rate
37%
Win Rate
63%
Profit-Loss Ratio
0.75
Alpha
0.037
Beta
0.352
Annual Standard Deviation
0.135
Annual Variance
0.018
Information Ratio
-0.081
Tracking Error
0.172
Treynor Ratio
0.185
Total Fees
$26410502.63
class VentralParticlePrism(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2000, 7, 22)  # Set Start Date
        self.SetEndDate(2020, 7, 22)
        self.SetCash(250000000)  # Set Strategy Cash
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddEquity("QQQ", Resolution.Minute)
        self.AddEquity("TQQQ", Resolution.Minute)
        self.AddEquity("UVXY", Resolution.Minute)
        self.AddEquity("TLT", Resolution.Minute)
        self.vma = self.SMA("QQQ", 365, Resolution.Daily, Field.Volume)

        self.vmaSlope = MomentumPercent(12)
        
        self.BuyThreshold = ((self.vma.Current.Value)*(-0.123))*100
        self.SellThreshold = ((self.vma.Current.Value)*(-0.1))*100

        self.Schedule.On(
            self.DateRules.EveryDay("QQQ"),
            self.TimeRules.AfterMarketOpen("QQQ", 7),
            self.Derp)
        #Whenever I raise the number of minutes to anything over 10,
        #it buys and sells once every single trading day throughout
        #the entire backtest. I don't understand this at all.
        
        self.SetWarmup(365)
        
    def OnData(self, data):
        if self.IsWarmingUp:
            return
        self.vmaSlope.Update(self.Time, self.vma.Current.Value)
        
    
    def Derp(self):
        if not self.vmaSlope.IsReady:
            return

        if (self.vmaSlope.Current.Value >= self.SellThreshold):
            self.Liquidate("QQQ")                
            self.SetHoldings("UVXY", 0)  
            self.SetHoldings("TLT", 0.01)

        if not self.Securities["QQQ"].Invested:
            if self.vmaSlope.Current.Value <= self.BuyThreshold:
                self.SetHoldings("TLT", 0)
                self.SetHoldings("QQQ", 1)
                self.SetHoldings("UVXY", 0)

            #self.Short == False
            #self.Long == True
        
        #if self.vmaSlope.Current.Value >= self.SellThreshold:
        #    self.Liquidate("TQQQ")
        #    self.Liquidate("QQQ")
            #self.Long == False
            #self.Short == True
            
            #self.market or limit order for UVXY equal to 10% of total portfolio value
        
    #def GimmeHedge(self):
        #if not self.vmaSlope.IsReady:
            #return
        #if self.Short == True:
            #self.SetHoldings("UVXY", 0.15)