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
Probabilistic 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
-10.582
Tracking Error
0.139
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
from AlgorithmImports import *


class Testnifty(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2020, 11, 1)  # Set Start Date
        self.SetEndDate(2020, 11, 30)  # Set End Date
        self.SetCash(100000)  # Set Strategy Cash
        #self.AddEquity("SPY", Resolution.Minute)
        nifty = self.AddData(Nifty, "NIFTY", Resolution.Daily).Symbol

        self.logCount=0

    def OnData(self, data):
        """OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
            Arguments:
                data: Slice object keyed by symbol containing the stock data
        """
        #if not data.ContainsKey("NIFTY"): return
        if self.logCount > 20:return # print 20 minutes of data
        self.Log(" Open:{0} | High:{1} | Low:{2} | Close:{3}".format(data["NIFTY"].Open,data["NIFTY"].High,data["NIFTY"].Low,data["NIFTY"].Close))
        self.logCount +=1

class Nifty(PythonData):
    '''NIFTY Custom Data Class'''
    def GetSource(self, config, date, isLiveMode):
        return SubscriptionDataSource("https://www.dropbox.com/s/2u4pkqh751fizf0/final.csv?dl=1", SubscriptionTransportMedium.RemoteFile)

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

        # New Nifty object
        index = Nifty()
        index.Symbol = config.Symbol

        try:
            # Example File Format:
            # Symbol    Date       Time    Open       High        Low       Close
            # NIFTY     2011-09-13  09.01   7792.9    7799.9     7722.65    7748.7

            data = line.split(',')
            data[1]=data[1]+data[2] # Concatinating Date and time 
            index.Time = datetime.strptime(data[1], "%Y%m%d%H%M%S")
            index.EndTime = index.Time + timedelta(days=1)
            index.Value = data[6]
            index["Open"] = float(data[3])
            index["High"] = float(data[4])
            index["Low"] = float(data[5])
            index["Close"] = float(data[6])


        except ValueError:
                # Do nothing
                return None

        return index