Hi!

I am trying to deploy a backtest on quantconnect platform based on the trading signals created by ML algorithms I have developed.

Due to the logistics and limitations on computing resources, I have already run the algorithm and have it as a .json file containing the hourly buy/sell signal for every hour between 2018 and 2023. 

This would be an example of my .json file

276007_1711187575.jpg

Following is my code for data loading and backtest execution. When I run the backtest, no trade occurs and I get an error message stating “Runtime Error: 'list' object is not callable”. 

I have been looking at tutorials and online resources to resolve the issue, but I am stuck. Any help will be greatly appreciated!

#CODE FOR EXTERNAL DATA LOADING
class ADA(PythonData):
    def __init__(self):
        self.Signal = ""
    def GetSource(self, config, date, isLiveMode: False):
        url = "URL_TO_MY_DROPBOX_FOR_JSON"
        return SubscriptionDataSource(url, SubscriptionTransportMedium.RemoteFile)
    def Reader(self, config, line, date, isLiveMode: False):
        if not (line.strip() and line.startswith("{")):
            return None
        try:
            data = json.loads(line)
            signal = TradingSignal()
            signal.Symbol = config.Symbol
            signal.Time = datetime.strptime(data['Time'], "%Y-%m-%dT%H:%M:%SZ")
            signal.Value = 0 
            signal["Signal"] = data['Signal']  
            return signal
        except ValueError:
            return None
            
#CODE FOR BACKTEST
class Algorirthm1(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 1)
        self.SetEndDate(2023, 6, 30)
        self.SetCash("BUSD", 1000000)
        self.SetBrokerageModel(BrokerageName.Binance, AccountType.Cash)

        self.symbols = ["BTCBUSD", "ETHBUSD", "XRPBUSD", "ADABUSD", "EOSBUSD"]
        self.symbolData = {}
        
        # Add Crypto Assets and corresponding custom data
        for symbol in self.symbols:
            crypto = self.AddCrypto(symbol, Resolution.Hour, Market.Binance).Symbol
        resolution = Resolution.Daily
        self.AddData(BTC, "BTCBUSD", resolution)
        self.AddData(ADA, "ADABUSD", resolution)
        self.AddData(ETH, "ETHBUSD", resolution)
        self.AddData(XRP, "XRPBUSD", resolution)
        self.AddData(EOS, "EOSBUSD", resolution)
        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.Every(timedelta(minutes=1440)), self.Liquidate())
    def OnData(self, data):
        self.Plot("Data Chart", self.symbol, self.Securities[self.symbol].Close)
        for symbol in self.symbols:
            self.Debug(symbol, data[symbol])
            self.SetHoldings(symbol, 1.0 / len(self.symbols))
            if data.ContainsKey(symbol) and data[symbol] is not None:
                trading_signal = data[symbol].Signal
                if trading_signal == "buy":
                    self.SetHoldings(symbol, 1.0 / len(self.symbols))  # Equally distribute cash among symbols
                elif trading_signal == "sell" and self.Portfolio[symbol].Invested:
                    self.Liquidate(symbol)