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 -1.322 Tracking Error 0.19 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 |
import pandas as pd, numpy as np owner = 'marcdemers' repo = 'test_fetch' path = 'test_file_0101.csv' url = 'https://api.github.com/repos/{owner}/{repo}/contents/{path}'.format(owner=owner, repo=repo, path=path) TOKEN = '1261aabaf38c3ea45aba6dbd20b320ae8668751b' headers = { 'accept': 'application/vnd.github.v3.raw', 'authorization': 'token {}'.format(TOKEN), "user-agent": "PyGithub/Python" } class CustomDataClass(PythonData): '''Custom Data Class''' def GetSource(self, config, date, isLiveMode): if isLiveMode: raise ValueError("live not implemented") subscription = SubscriptionDataSource("https://raw.githubusercontent.com/marcdemers/test_fetch/main/test_file_0101.csv", SubscriptionTransportMedium.RemoteFile, FileFormat.Csv, headers # Commenting out headers here will make the Subscription work ) return subscription def Reader(self, config, line, date, isLiveMode): #TEST 2020-01-01 0.027 0.027 0.027 0.027 1 # if not (line.strip() and line[2].isdigit()): return None bar = CustomDataClass() bar.Symbol = config.Symbol try: data = line.split(',') symbol_str = data[0] bar.Symbol = symbol_str bar.Time = datetime.strptime(data[1], "%Y-%m-%d") bar.Value = data[5] bar["Open"] = float(data[2]) bar["High"] = float(data[3]) bar["Low"] = float(data[4]) bar["Close"] = float(data[5]) bar["Volume"] = float(data[6]) except ValueError: # Do nothing return None return bar class TestGithub(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) # inclusive self.SetEndDate(2020, 1, 3) # inclusive self.SetCash(100000) # Set Strategy Cash resp = self.Download(url, headers) self.Debug(resp) # works! symb1 = self.AddData(CustomDataClass, "TEST", Resolution.Daily).Symbol symb2 = self.AddData(CustomDataClass, "TEST2", Resolution.Daily).Symbol symb3 = self.AddData(CustomDataClass, "TEST3", Resolution.Daily).Symbol def OnData(self, slice): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: slice: Slice object keyed by symbol containing the stock data ''' self.Debug(slice.Time) self.Debug(slice.Keys)