code: def run(self):
      orders = self.alpaca.list_orders(status="open")
      for order in orders:
          self.alpaca.cancel_order(order.id)
  
      # Wait for market to open.
      print("Waiting for market to open...")
      self.awaitMarketOpen()
      print("Market opened.")
      while True:
          # Figure out when the market will close so we can prepare to sell beforehand.
          clock = self.alpaca.get_clock()
          closingTime = clock.next_close.replace(
              tzinfo=datetime.timezone.utc
          ).timestamp()
          currTime = clock.timestamp.replace(
              tzinfo=datetime.timezone.utc
          ).timestamp()
          self.timeToClose = closingTime - currTime
  
          if self.timeToClose < (60 * 2):
              # Close all positions when 2 minutes til market close.  Any less and it will be in danger of not closing positions in time.
  
              print("Market closing soon.  Closing positions.")
  
              threads = []
              positions = self.alpaca.list_positions()
              for position in positions:
                  if position.side == "long":
                      orderSide = "sell"
                  else:
                      orderSide = "buy"
                  qty = abs(int(float(position.qty)))
                  respSO = []
                  tSubmitOrder = threading.Thread(
                      target=self.submitOrder(
                          qty, position.symbol, orderSide, respSO
                      )
                  )
                  tSubmitOrder.start()
                  threads.append(
                      tSubmitOrder
                  )  # record thread for joining later
  
              for x in threads:  #  wait for all threads to complete
                  x.join()
  
              # Run script again after market close for next trading day.
              print("Sleeping until market close (15 minutes).")
              time.sleep(60 * 15)
  
          else:
              self.trade()
              last_equity = float(self.alpaca.get_account().last_equity)
              cur_time = time.time()
              self.equities.append([cur_time, last_equity])
              time.sleep(self.time_interval)
  
imports: from __future__ import annotations
  import datetime
  import threading
  import time
  import alpaca_trade_api
  import gym
  import numpy
  import pandas
  import torch
  from finrl.meta.data_processors.processor_alpaca import AlpacaProcessor
  from finrl.meta.paper_trading.common import AgentPPO
label_desc: Use image node_id 3 for calling the PaperTradingAlpaca obj's underlying member method code with example usage: obj.run() without return types