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

class StockDataSourceUniverseAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2015, 3, 18)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash

        self.AddUniverse(StockDataSource, "my-stock-data-source", Resolution.Daily, self.FilterFunction)

    def FilterFunction(self, data):
        list = []
        for item in data:
            for symbol in item["Symbols"]:
                list.append(symbol)
        return list

class StockDataSource(PythonData):

    def GetSource(self,
         config: SubscriptionDataConfig,
         date: datetime,
         isLive: bool) -> SubscriptionDataSource:
        return SubscriptionDataSource("https://www.dropbox.com/s/7xe7lfac52mdfpe/custom-universe.json?dl=1", 
                                      SubscriptionTransportMedium.RemoteFile,
                                      FileFormat.UnfoldingCollection)

    def Reader(self,
         config: SubscriptionDataConfig,
         line: str,
         date: datetime,
         isLive: bool) -> BaseData:
        
        objects = []
        data = json.loads(line)

        for datum in data:
            stocks = StockDataSource()
            stocks.Symbol = config.Symbol

            stocks.Time = datetime.strptime(datum["Date"], "%Y%m%d")
            stocks.EndTime = stocks.Time + timedelta(1)
            stocks["Symbols"] = datum["Symbols"]
            objects.append(stocks)

        return BaseDataCollection(objects[-1].EndTime, config.Symbol, objects)