Can you help me make this code run live on trade station 

 

class BullCreditSpread(QCAlgorithm):
    def initialize(self):
        self.set_cash(500)
        self.spy = self.add_equity("SPY", Resolution.HOUR)
        self.spy_option = self.add_option("SPY")
        self.spy_option.set_filter(self.weekly_filter)
        self.sma = self.sma("SPY", 50, Resolution.HOUR)
        self.has_position = False
        self.spy_price = None  # Initialize spy_price
        self.schedule.on(self.date_rules.every(DayOfWeek.MONDAY), self.time_rules.at(10, 0), self.trade_options)
    def weekly_filter(self, universe):
        return universe.include_weeklys().strikes(-5, 5).expiration(0, 7)
    def on_data(self, slice):
        if not self.sma.is_ready:
            return
        if self.securities.contains_key("SPY"):
            self.spy_price = self.securities["SPY"].price
    def trade_options(self):
        if self.spy_price is None:  # Check if spy_price is set
            return
        if self.spy_price > self.sma.current.value:
            chain = self.current_slice.option_chains.get(self.spy_option.Symbol)
            if chain is None:
                return
            contracts = sorted(chain, key=lambda x: abs(x.greeks.delta - 0.35))
            if len(contracts) == 0:
                return
            short_option = contracts[0]
            long_options = [x for x in chain if x.strike < short_option.strike and x.expiry == short_option.expiry]
            if not long_options:
                return
            long_option = sorted(long_options, key=lambda x: x.strike, reverse=True)[0]
            if not self.has_position:
                spread = OptionStrategies.bull_put_spread(self.spy_option.Symbol, short_option.strike, long_option.strike, short_option.expiry)
                self.buy(spread, 1)
                self.has_position = True
    def CheckStopLoss(self):
       # Calculate the current floating loss
       current_float_loss = self.Securities[self.symbol].Holdings.UnrealizedProfit - self.credit_received
       # Check if the floating loss exceeds # times the credit received
       if current_float_loss <= -1.2 * self.credit_received:
           # Close the current option strategy trade
           self.Liquidate(self.current_option_strategy)
           # Reset the credit received
           self.credit_received = 0.0
    def CheckTakeProfit(self):
       # Calculate the current floating profit
       current_float_profit = self.Securities[self.symbol].Holdings.UnrealizedProfit
       # Check if the floating loss exceeds # times the credit received
       if current_float_profit >= .75 * self.credit_received:
           # Close the current option strategy trade
           self.Liquidate(self.current_option_strategy)
           # Reset the credit received
           self.credit_received = 0.0
    def on_order_event(self, orderEvent):
        if orderEvent.status == OrderStatus.FILLED:
            self.has_position = False