code: def test_repair_bad_stock_split(self):
      # Stocks that split in 2022 but no problems in Yahoo data,
      # so repair should change nothing
      good_tkrs = [
          "AMZN",
          "DXCM",
          "FTNT",
          "GOOG",
          "GME",
          "PANW",
          "SHOP",
          "TSLA",
      ]
      good_tkrs += ["AEI", "GHI", "IRON", "LXU", "NUZE", "RSLS", "TISI"]
      good_tkrs += ["BOL.ST", "TUI1.DE"]
      intervals = ["1d", "1wk", "1mo", "3mo"]
      for tkr in good_tkrs:
          for interval in intervals:
              dat = yf.Ticker(tkr, session=self.session)
              tz_exchange = dat.fast_info["timezone"]
  
              _dp = os.path.dirname(__file__)
              df_good = dat.history(
                  start="2020-01-01",
                  end=_dt.date.today(),
                  interval=interval,
                  auto_adjust=False,
              )
  
              repaired_df = dat._fix_bad_stock_split(
                  df_good, interval, tz_exchange
              )
  
              # Expect no change from repair
              df_good = df_good.sort_index()
              repaired_df = repaired_df.sort_index()
              for c in [
                  "Open",
                  "Low",
                  "High",
                  "Close",
                  "Adj Close",
                  "Volume",
              ]:
                  try:
                      self.assertTrue(
                          (
                              repaired_df[c].to_numpy()
                              == df_good[c].to_numpy()
                          ).all()
                      )
                  except:
                      print(f"tkr={tkr} interval={interval} COLUMN={c}")
                      df_dbg = df_good[[c]].join(
                          repaired_df[[c]],
                          lsuffix=".good",
                          rsuffix=".repaired",
                      )
                      f_diff = (
                          repaired_df[c].to_numpy()
                          != df_good[c].to_numpy()
                      )
                      print(
                          df_dbg[
                              f_diff
                              | _np.roll(f_diff, 1)
                              | _np.roll(f_diff, -1)
                          ]
                      )
                      raise
  
      bad_tkrs = [
          "4063.T",
          "ALPHA.PA",
          "AV.L",
          "CNE.L",
          "MOB.ST",
          "SPM.MI",
      ]
      bad_tkrs.append(
          "LA.V"
      )  # special case - stock split error is 3 years ago! why not fixed?
      for tkr in bad_tkrs:
          dat = yf.Ticker(tkr, session=self.session)
          tz_exchange = dat.fast_info["timezone"]
  
          _dp = os.path.dirname(__file__)
          interval = "1d"
          fp = os.path.join(
              _dp,
              "data",
              tkr.replace(".", "-")
              + "-"
              + interval
              + "-bad-stock-split.csv",
          )
          if not os.path.isfile(fp):
              interval = "1wk"
              fp = os.path.join(
                  _dp,
                  "data",
                  tkr.replace(".", "-")
                  + "-"
                  + interval
                  + "-bad-stock-split.csv",
              )
          df_bad = _pd.read_csv(fp, index_col="Date")
          df_bad.index = _pd.to_datetime(df_bad.index, utc=True)
  
          repaired_df = dat._fix_bad_stock_split(
              df_bad, "1d", tz_exchange
          )
  
          fp = os.path.join(
              _dp,
              "data",
              tkr.replace(".", "-")
              + "-"
              + interval
              + "-bad-stock-split-fixed.csv",
          )
          correct_df = _pd.read_csv(fp, index_col="Date")
          correct_df.index = _pd.to_datetime(correct_df.index)
  
          repaired_df = repaired_df.sort_index()
          correct_df = correct_df.sort_index()
          for c in [
              "Open",
              "Low",
              "High",
              "Close",
              "Adj Close",
              "Volume",
          ]:
              try:
                  self.assertTrue(
                      _np.isclose(
                          repaired_df[c], correct_df[c], rtol=5e-6
                      ).all()
                  )
              except AssertionError:
                  print(f"tkr={tkr} COLUMN={c}")
                  # print("- repaired_df")
                  # print(repaired_df)
                  # print("- correct_df[c]:")
                  # print(correct_df[c])
                  # print("- diff:")
                  # print(repaired_df[c] - correct_df[c])
                  raise
  
      # Had very high price volatility in Jan-2021 around split date that could
      # be mistaken for missing stock split adjustment. And old logic did think
      # column 'High' required fixing - wrong!
      sketchy_tkrs = ["FIZZ"]
      intervals = ["1wk"]
      for tkr in sketchy_tkrs:
          for interval in intervals:
              dat = yf.Ticker(tkr, session=self.session)
              tz_exchange = dat.fast_info["timezone"]
  
              _dp = os.path.dirname(__file__)
              df_good = dat.history(
                  start="2020-11-30",
                  end="2021-04-01",
                  interval=interval,
                  auto_adjust=False,
              )
  
              repaired_df = dat._fix_bad_stock_split(
                  df_good, interval, tz_exchange
              )
  
              # Expect no change from repair
              df_good = df_good.sort_index()
              repaired_df = repaired_df.sort_index()
              for c in [
                  "Open",
                  "Low",
                  "High",
                  "Close",
                  "Adj Close",
                  "Volume",
              ]:
                  try:
                      self.assertTrue(
                          (
                              repaired_df[c].to_numpy()
                              == df_good[c].to_numpy()
                          ).all()
                      )
                  except AssertionError:
                      print(f"tkr={tkr} interval={interval} COLUMN={c}")
                      df_dbg = df_good[[c]].join(
                          repaired_df[[c]],
                          lsuffix=".good",
                          rsuffix=".repaired",
                      )
                      f_diff = (
                          repaired_df[c].to_numpy()
                          != df_good[c].to_numpy()
                      )
                      print(
                          df_dbg[
                              f_diff
                              | _np.roll(f_diff, 1)
                              | _np.roll(f_diff, -1)
                          ]
                      )
                      raise
  
imports: from .context import yfinance
  from .context import session_gbl
  import unittest
  import os
  import datetime
  import pytz
  import numpy
  import pandas
label_desc: Use image node_id 11 for calling the TestPriceRepair obj's underlying member method code with example usage: obj.test_repair_bad_stock_split() without return types