def Initialize(self):

        self.SetStartDate(2020, 1, 1)

        self.SetCash(2500)

        self.UniverseSettings.Resolution = Resolution.Daily

        self.UniverseSettings.Leverage = 2.0

        self.AddUniverse(self.SelectionFilter)

        self.rsi = {}

        self.symbol_data = {}


 

    def SelectionFilter(self, coarse):

        sorted_vol = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)

        filtered = [x.Symbol for x in sorted_vol if x.Price > 50]

        return filtered[:1]


 

    def OnSecuritiesChanged(self, changes):

        self.Log(f"OnSecuritiesChanged({self.Time})::{changes}")

       

        for security in changes.RemovedSecurities:

            symbol = security.Symbol

            if symbol in self.symbol_data:

                self.Liquidate(symbol)

                self.Debug(f"Liquidated {symbol} at {self.Securities[symbol].Price}")

                del self.symbol_data[symbol]

                del self.rsi[symbol]


 

        for security in changes.AddedSecurities:

            symbol = security.Symbol

            self.symbol_data[symbol] = security

            self.rsi[symbol] = self.RSI(symbol, 14, Resolution.Daily)

       

    def OnData(self, data):

        for symbol, rsi in self.rsi.items():

            if symbol in data and data[symbol] is not None:

                current_price = data[symbol].Price

                rsi_value = rsi.Current.Value


 

                if not self.Securities[symbol].Invested and (rsi_value < 30 or (rsi_value > 50 and rsi_value < 70)):

                    self.SetHoldings(symbol, 1)

                    self.Debug(f"Bought {symbol} at {current_price} with RSI {rsi_value}")


 

                elif self.Securities[symbol].Invested and (rsi_value > 70 or (rsi_value > 30 and rsi_value < 50)):

                    self.Liquidate(symbol)

                    self.Debug(f"Liquidated {symbol} at {current_price} with RSI {rsi_value}")


I wrote this simple strategy, filtering securities by volume, then buying them, when rsi has a certain value and selling them when a new security takes its place or if rsi reaches a certain value. The problem appeared when I tried to set leverage for my trades, as I was getting the exact same results in the backtest, as if I was trading with no leverage