code: def __init__(
      self,
      algo,
      sim_params,
      data_portal,
      clock,
      benchmark_source,
      restrictions,
      universe_func,
  ):
      # ==============
      # Simulation
      # Param Setup
      # ==============
      self.sim_params = sim_params
      self.env = algo.trading_environment
      self.data_portal = data_portal
      self.restrictions = restrictions
  
      # ==============
      # Algo Setup
      # ==============
      self.algo = algo
  
      # ==============
      # Snapshot Setup
      # ==============
  
      # This object is the way that user algorithms interact with OHLCV data,
      # fetcher data, and some API methods like `data.can_trade`.
      self.current_data = self._create_bar_data(universe_func)
  
      # We don't have a datetime for the current snapshot until we
      # receive a message.
      self.simulation_dt = None
  
      self.clock = clock
  
      self.benchmark_source = benchmark_source
  
      # =============
      # Logging Setup
      # =============
  
      # Processor function for injecting the algo_dt into
      # user prints/logs.
      def inject_algo_dt(record):
          if "algo_dt" not in record.extra:
              record.extra["algo_dt"] = self.simulation_dt
  
      self.processor = Processor(inject_algo_dt)
  
file_path: catalyst/catalyst/gens/tradesimulation.py
imports: from contextlib2 import ExitStack
  from logbook import Logger, Processor
  from pandas.tslib import normalize_date
  from catalyst.protocol import BarData
  from catalyst.utils.api_support import ZiplineAPI
  from six import viewkeys
  from catalyst.gens.sim_engine import BAR, SESSION_START, SESSION_END, MINUTE_END, BEFORE_TRADING_START_BAR
  from catalyst.constants import LOG_LEVEL
label_desc: Use image node_id 1 to create a new AlgorithmSimulator object from inherited base classes: object with example: obj = AlgorithmSimulator(algo, sim_params, data_portal, clock, benchmark_source, restrictions, universe_func)