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
-0.74
Tracking Error
0.141
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
# region imports
from AlgorithmImports import *

class Algorithm(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2010, 12, 30)  # Set Start Date
        self.SetEndDate(2022, 4, 21)
        self.SetCash(1000000)  # Set Strategy Cash

        self.spy = self.AddEquity('SPY' , Resolution.Daily).Symbol
        self.SetBenchmark(self.spy)

        # Adding Custom Data
        # The resolution will tell us how often the algorithm calls the custom data
        self.symbol = self.AddData(HeliosPropData, "HLOS", Resolution.Daily).Symbol # You have to specify a random ticker symbol for your data like "MUSKTWTS"

    def OnData(self, data):
        '''onPropData = data.ContainsKey(self.symbol).Value
        self.Log("Data Added " +  str(onPropData) + "!!")'''
        if data.ContainsKey(self.symbol):
            value = data[self.symbol].Value
            self.Log("Data Added: " + str(value))

        '''if self.symbol in data:
            alpha_score = data[self.symbol].Value
            self.Log("Added Value: " + str(alpha_score))'''

# This class is no longer a part of the QCAlgorithm Class so you won't be able to access the helper methods
class HeliosPropData(PythonData):
    def GetSource(self, config, date, isLive):
        source = "https://raw.githubusercontent.com/sankalpbhatia20/helios-quantconnect/main/SP500_30.csv?token=GHSAT0AAAAAAB2JTI44V5U2TCVKS3SWCARGY2VVZUA"

        return SubscriptionDataSource(source, SubscriptionTransportMedium.RemoteFile)
    
    def Reader(self, config, line, date, isLive):
        if not (line.strip() and line[0].isdigit()):
            return None

        data = line.split(',')
        prop_data = HeliosPropData()

        try:
            prop_data.Symbol = config.Symbol
            prop_data.Time = datetime.strptime(data[0] , '%Y-%m-%d') # Can lead to look-ahead bias
            prop_data.Value = float(data[1]) # Always a decimal value
            #self.Log(str(float(data[1])))

        except ValueError:
            return None

        return prop_data