Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
from QuantConnect.Python import PythonQuandl
from datetime import datetime, timedelta

class RollingWindowAlgorithm(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2018,1,1)
        self.SetEndDate(2018,3,1)
        self.SetCash(25000)
        vix = 'CBOE/VIX'
        vxv = 'CBOE/VXV'
        self.AddData(QuandlVix, vix, Resolution.Daily)
        self.AddData[Quandl](vxv, Resolution.Daily)
        self.AddEquity("SPY", Resolution.Hour)
        self.vix_ema = self.EMA(vix, 10, Resolution.Daily, Field.Close)
        self.vxv_ema = self.EMA(vxv, 10, Resolution.Daily)
        self.PlotIndicator("Data", self.vix_ema, self.vxv_ema)
        # self.SetWarmUp(timedelta(10)) # Warm up 10 days of data.

    def OnData(self, data):
        
        if not (self.vix_ema.IsReady and self.vxv_ema.IsReady): return 
        if not (data.ContainsKey("SPY")): return 
        self.Log("SPY " + str(data["SPY"].Value) + "VIX "+ str(self.vix_ema.Current.Value) + " VXV " + str(self.vxv_ema.Current.Value))

class QuandlVix(PythonQuandl):
    def __init__(self):
        self.ValueColumnName = "VIX Close"
        self.Close = "VIX Close" 
        pass