docstr: Assert that assets appear at correct times during a backtest, with
  correctly-adjusted close price values.
docstr_tok: ["Assert","that","assets","appear","at","correct","times","during","a","backtest",",","with","correctly-adjusted","close","price","values","."]
code: def _test_assets_appear_on_correct_days(self, test_name, chunks):
      """
      Assert that assets appear at correct times during a backtest, with
      correctly-adjusted close price values.
      """
  
      if chunks == "all_but_one_day":
          chunks = (
              self.dates.get_loc(self.last_asset_end)
              - self.dates.get_loc(self.first_asset_start)
          ) - 1
      elif chunks == "custom_iter":
          chunks = []
          st = np.random.RandomState(12345)
          remaining = self.dates.get_loc(
              self.last_asset_end
          ) - self.dates.get_loc(self.first_asset_start)
          while remaining > 0:
              chunk = st.randint(3)
              chunks.append(chunk)
              remaining -= chunk
  
      def initialize(context):
          p = attach_pipeline(Pipeline(), "test", chunks=chunks)
          p.add(USEquityPricing.close.latest, "close")
  
      def handle_data(context, data):
          results = pipeline_output("test")
          date = get_datetime().normalize()
          for asset in self.assets:
              # Assets should appear iff they exist today and yesterday.
              exists_today = self.exists(date, asset)
              existed_yesterday = self.exists(
                  date - self.trading_day, asset
              )
              if exists_today and existed_yesterday:
                  latest = results.loc[asset, "close"]
                  self.assertEqual(
                      latest, self.expected_close(date, asset)
                  )
              else:
                  self.assertNotIn(asset, results.index)
  
      before_trading_start = handle_data
  
      algo = TradingAlgorithm(
          initialize=initialize,
          handle_data=handle_data,
          before_trading_start=before_trading_start,
          data_frequency="daily",
          get_pipeline_loader=lambda column: self.pipeline_loader,
          start=self.first_asset_start,
          end=self.last_asset_end,
          env=self.env,
      )
  
      # Run for a week in the middle of our data.
      algo.run(self.data_portal)
  
imports: from os.path import dirname, join, realpath
  from nose_parameterized import parameterized
  import numpy
  from numpy import arange, full_like, nan
  import pandas
  from pandas import DataFrame, date_range, Series, Timestamp
  from catalyst.algorithm import TradingAlgorithm
  from catalyst.api import attach_pipeline, pipeline_output, get_datetime
  from catalyst.errors import AttachPipelineAfterInitialize, PipelineOutputDuringInitialize, NoSuchPipeline
  from catalyst.lib.adjustment import MULTIPLY
  from catalyst.pipeline import Pipeline
  from catalyst.pipeline.data import USEquityPricing
  from catalyst.pipeline.loaders.frame import DataFrameLoader
  from catalyst.testing.fixtures import WithDataPortal, CatalystTestCase
  from catalyst.utils.calendars import get_calendar
label_desc: Use image node_id 10 for calling the ClosesOnly obj's underlying member method code with example usage: obj._test_assets_appear_on_correct_days(test_name, chunks) without return types