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.Data import SubscriptionDataSource
from QuantConnect.Python import PythonData
from datetime import date, timedelta, datetime
import decimal
import numpy as np
import math
import json
import csv

class CustomDataAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2008, 1, 8)
        self.SetEndDate(2014, 7, 25)
        self.SetCash(100000)

        # Define the symbol and "type" of our generic data:
        self.AddData(AlphaVantageVIX, "VIX")


    def OnData(self, data):

        if "VIX" not in data:
            self.Log("NOT DATA")
            return

        #self.today.NiftyPrice = data["NIFTY"].Close
        self.Log(str(data["VIX"].Close))
        

class AlphaVantageVIX(PythonData):
    def GetSource(self, config, date, isLiveMode):
        #Data with oldest data at the top
        return SubscriptionDataSource("http://monktonenterprises.com/daily_VIX_reversed.csv", SubscriptionTransportMedium.RemoteFile);
        #Data with newest data at the top
        #return SubscriptionDataSource("http://monktonenterprises.com/daily_VIX.csv", SubscriptionTransportMedium.RemoteFile);

    def Reader(self, config, line, date, isLiveMode):
        if not (line.strip() and line[0].isdigit()): return None

        index = AlphaVantageVIX();
        index.Symbol = config.Symbol

        try:
            # Example File Format:
            # Date,       Open       High        Low       Close     Volume      Turnover
            # 2011-09-13  7792.9    7799.9     7722.65    7748.7    116534670    6107.78
            data = line.split(',')
            index.Time = datetime.strptime(data[0], "%Y-%m-%d")
            index.Value = decimal.Decimal(data[4])
            index["Open"] = float(data[1])
            index["High"] = float(data[2])
            index["Low"] = float(data[3])
            index["Close"] = float(data[4])

        except ValueError:
                # Do nothing
                return None

        return index