code: def _test_before_trading_start(
      self, test_name, num_days, freq, emission_rate
  ):
      params = factory.create_simulation_parameters(
          num_days=num_days,
          data_frequency=freq,
          emission_rate=emission_rate,
      )
  
      def fake_benchmark(self, dt):
          return 0.01
  
      with patch.object(
          BenchmarkSource, "get_value", self.fake_minutely_benchmark
      ):
          algo = BeforeTradingAlgorithm(sim_params=params, env=self.env)
          algo.run(FakeDataPortal(self.env))
  
          self.assertEqual(
              len(algo.perf_tracker.sim_params.sessions), num_days
          )
  
          bts_minutes = days_at_time(
              params.sessions, time(8, 45), "US/Eastern"
          )
  
          self.assertTrue(
              bts_minutes.equals(
                  pd.DatetimeIndex(algo.before_trading_at)
              ),
              "Expected %s but was %s."
              % (params.sessions, algo.before_trading_at),
          )
  
imports: from datetime import time
  import pandas
  from mock import patch
  from nose_parameterized import parameterized
  from six.moves import range
  from catalyst import TradingAlgorithm
  from catalyst.gens.sim_engine import BEFORE_TRADING_START_BAR
  from catalyst.finance.performance import PerformanceTracker
  from catalyst.finance.asset_restrictions import NoRestrictions
  from catalyst.gens.tradesimulation import AlgorithmSimulator
  from catalyst.sources.benchmark_source import BenchmarkSource
  from catalyst.test_algorithms import NoopAlgorithm
  from catalyst.testing.fixtures import WithDataPortal, WithSimParams, WithTradingEnvironment, CatalystTestCase
  from catalyst.utils import factory
  from catalyst.testing.core import FakeDataPortal
  from catalyst.utils.calendars.trading_calendar import days_at_time
label_desc: Use image node_id 3 for calling the TestTradeSimulation obj's underlying member method code with example usage: obj._test_before_trading_start(test_name, num_days, freq, emission_rate) and returns: int