Can someone help me please. When I run the back test my code makes one trade and that is all. How do I make it so that when my initial trade closes. Then it starts to scan for another trade to meet the criteria 

 

from datetime import timedelta
from AlgorithmImports import *
class BullPutSpreadStrategy(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2020, 1, 1)
        self.set_end_date(2023, 12, 1)
        self.set_cash(50000)
        option = self.add_option("SPY", Resolution.MINUTE)
        self.symbol = option.symbol
        option.set_filter(self.universe_func)
        self.credit_received = 0.0
        self.current_option_strategy = None
        self.spy = self.add_equity("SPY", Resolution.HOUR).symbol
        self.sma = self.sma(self.spy, 200, Resolution.HOUR)
    def universe_func(self, universe: OptionFilterUniverse) -> OptionFilterUniverse:
        return universe.include_weeklys().strikes(-1, 1).expiration(timedelta(days=1), timedelta(days=7))
    def on_data(self, slice: Slice) -> None:
        if not self.sma.is_ready:
            return
        if self.current_option_strategy is not None:
            self.check_stop_loss()
            return
        if self.securities[self.spy].price <= self.sma.current.value:
            return
        chain = slice.option_chains.get(self.symbol, None)
        if not chain:
            return
        expiry = min([x.Expiry for x in chain])
        puts = [i for i in chain if i.Expiry == expiry and i.right == OptionRight.PUT]
        if len(puts) == 0:
            return
        puts = sorted(puts, key=lambda x: abs(x.greeks.delta + 0.35))
        short_put = puts[0]
        lower_strike_puts = [p for p in puts if p.strike < short_put.strike]
        if not lower_strike_puts:
            return
        long_put = min(lower_strike_puts, key=lambda x: x.strike)
        option_strategy = OptionStrategies.bull_put_spread(self.symbol, short_put.strike, long_put.strike, expiry)
        self.current_option_strategy = option_strategy
        self.credit_received = short_put.bid_price - long_put.ask_price
        self.buy(option_strategy, 1)
    def check_stop_loss(self):
        current_float_loss = self.securities[self.symbol].holdings.unrealized_profit - self.credit_received
        if current_float_loss <= -1.5 * self.credit_received:
            self.liquidate(self.current_option_strategy)
            self.credit_received = 0.0
            self.current_option_strategy = None