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 clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")

from System import *
from QuantConnect import *
from QuantConnect.Data import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Python import PythonQuandl
from QuantConnect.Data.Custom import Quandl
import datetime


class QuandlVix(PythonQuandl):
    '''Custom quandl data type for setting customized value column name. Value column is used for the primary trading calculations and charting.'''
    def __init__(self):
        # Define ValueColumnName: cannot be None, Empty or non-existant column name
        # If ValueColumnName is "Close", do not use PythonQuandl, use Quandl:
        # self.AddData[QuandlFuture](self.crude, Resolution.Daily)
        self.ValueColumnName = "VIX Close"
        self.close = "VIX Close"
        pass


class QuandlHistoryPerformanceIssueExample(QCAlgorithm):
    def Initialize(self):

        self.SetStartDate(2013,10,7)   #Set Start Date
        self.SetEndDate(2013,10,11)     #Set End Date
        self.SetCash(100000)          #Set Strategy Cash
        
        self.spy = self.AddEquity("SPY", Resolution.Daily)
        self.aapl = self.AddEquity("AAPL", Resolution.Daily)
        self.spy.SetDataNormalizationMode(DataNormalizationMode.SplitAdjusted)
        self.aapl.SetDataNormalizationMode(DataNormalizationMode.SplitAdjusted)

        self.AddData(QuandlVix, 'CBOE/VIX', Resolution.Daily)
        self.AddData[Quandl]('CBOE/VXV', Resolution.Daily)


    def OnData(self, data):

        now = self.Time

        # Test 1 using Quandl history
        history = self.History(["SPY", "CBOE/VXV"], 3, Resolution.Daily)
        vix_history = self.History(["CBOE/VIX"], 3, Resolution.Daily)
        
        # Test 2 using no history at all
        # history = None
        
        # Test 3 using SPY and AAPL history
        # history = self.History('SPY', 3, Resolution.Daily)
        # history = self.History('AAPL', 3, Resolution.Daily)
        
        self.Log('Date: %s' % self.Time)
        '''
        Notes:
        1) I cannot access to Quandl prices with self.Securities['CBOE/VXV'].Open.
            Only Close works.
        2) To access all Quandl prices, I should use self.History
        Questions:
            - Why self.History is so slow
            - Can I convert Vix Open to Open
            - Can I make self.Securities['CBOE/VIX'].Open works.
        '''