Overall Statistics
Total Trades
1570
Average Win
0.40%
Average Loss
-0.29%
Compounding Annual Return
14.775%
Drawdown
20.000%
Expectancy
0.950
Net Profit
875.660%
Sharpe Ratio
1.206
Probabilistic Sharpe Ratio
74.330%
Loss Rate
19%
Win Rate
81%
Profit-Loss Ratio
1.39
Alpha
0.101
Beta
0.255
Annual Standard Deviation
0.105
Annual Variance
0.011
Information Ratio
0.166
Tracking Error
0.161
Treynor Ratio
0.496
Total Fees
$1931.10
Estimated Strategy Capacity
$5400000.00
Lowest Capacity Asset
TLT SGNKIKYGE9NP
# Trading based on CBOE vix-vxv ratio

from QuantConnect.Data.Custom.CBOE import *

class VirtualRedDogfish(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2005, 1, 1)
        self.SetCash(100000) 
       
        self.AddEquity("QQQ", Resolution.Minute).Symbol
        self.AddEquity("TLT", Resolution.Minute).Symbol
        self.AddEquity("VXX", Resolution.Minute).Symbol
        self.AddEquity("SPY", Resolution.Minute).Symbol
        self.AddEquity("TQQQ", Resolution.Minute).Symbol
        self.AddEquity("TMF", Resolution.Minute).Symbol
        self.AddEquity("UVXY", Resolution.Minute).Symbol
        self.AddEquity("SVXY", Resolution.Minute).Symbol

        self.vix = 'CBOE/VIX'
        self.vxv = 'CBOE/VXV'
       
        self.AddData(QuandlVix, self.vix, Resolution.Daily)
        self.AddData(Quandl, self.vxv, Resolution.Daily)
       
        self.SetWarmUp(100, Resolution.Daily)
       
        self.vix_sma = self.SMA(self.vix, 1, Resolution.Daily)
        self.vxv_sma = self.SMA(self.vxv, 1, Resolution.Daily)
        self.ratio = IndicatorExtensions.Over(self.vxv_sma, self.vix_sma)
       
        self.spySMA = self.SMA("SPY", 100, Resolution.Daily)
        
        self.Schedule.On(self.DateRules.WeekStart("SPY"), self.TimeRules.AfterMarketOpen("SPY", 10), 
            self.Trade)
       
       
    def Trade(self):
        if not (self.vix_sma.IsReady or self.vxv_sma.IsReady or self.ratio.IsReady): 
            return
        if self.spySMA is None or not self.spySMA.IsReady: 
            return

        if self.spySMA.Current.Value < self.Securities["SPY"].Price:
            if self.ratio.Current.Value < .923:
                
                self.SetHoldings("VXX", 0.4)
                self.SetHoldings("TMF", 0.0)
                self.SetHoldings("TLT", 0.0)
                self.SetHoldings("TQQQ", 0.0)
                self.SetHoldings("QQQ", 0.6)
            else:
                self.SetHoldings("VXX", 0)
                self.SetHoldings("TMF", 0.0)
                self.SetHoldings("TLT", 0.4)
                self.SetHoldings("TQQQ", 0.0)
                self.SetHoldings("QQQ", 0.6)
               
        else:
            if self.ratio.Current.Value <= .923:
                
                self.SetHoldings("VXX", 0.4)
                self.SetHoldings("TMF", 0.)
                self.SetHoldings("TLT", 0.3)
                self.SetHoldings("TQQQ", 0.)
                self.SetHoldings("QQQ", 0.3)
            else:
                self.SetHoldings("VXX", 0)
                self.SetHoldings("TMF", 0)
                self.SetHoldings("TLT", 0.5)
                self.SetHoldings("TQQQ", 0)
                self.SetHoldings("QQQ", 0.5)
                
    
    
class QuandlVix(PythonQuandl):
   
    def __init__(self):
        self.ValueColumnName = "Close"