docstr: Test get_clean_factor_and_forward_returns with and intraday factor
  and holidays
docstr_tok: ["Test","get_clean_factor_and_forward_returns","with","and","intraday","factor","and","holidays"]
code: def test_get_clean_factor_and_forward_returns_5(self):
      """
      Test get_clean_factor_and_forward_returns with and intraday factor
      and holidays
      """
      tickers = ["A", "B", "C", "D", "E", "F"]
  
      factor_groups = {"A": 1, "B": 2, "C": 1, "D": 2, "E": 1, "F": 2}
  
      price_data = [
          [
              1.10**i,
              0.50**i,
              3.00**i,
              0.90**i,
              0.50**i,
              1.00**i,
          ]
          for i in range(1, 20)
      ]  # 19 days = 18 + 1 fwd returns
  
      factor_data = [
          [3, 4, 2, 1, nan, nan],
          [3, nan, nan, 1, 4, 2],
          [3, 4, 2, 1, nan, nan],
      ] * 6  # 18 days
  
      start = "2017-1-12"
      factor_end = "2017-2-10"
      price_end = "2017-2-13"  # 1D (business day) fwd returns
      holidays = ["2017-1-13", "2017-1-18", "2017-1-30", "2017-2-7"]
      holidays = [Timestamp(d) for d in holidays]
  
      price_index = date_range(start=start, end=price_end, freq="B")
      price_index.name = "date"
      price_index = price_index.drop(holidays)
  
      today_open = DataFrame(
          index=price_index + Timedelta("9h30m"),
          columns=tickers,
          data=price_data,
      )
      today_open_1h = DataFrame(
          index=price_index + Timedelta("10h30m"),
          columns=tickers,
          data=price_data,
      )
      today_open_1h += today_open_1h * 0.001
      today_open_3h = DataFrame(
          index=price_index + Timedelta("12h30m"),
          columns=tickers,
          data=price_data,
      )
      today_open_3h -= today_open_3h * 0.002
      prices = concat(
          [today_open, today_open_1h, today_open_3h]
      ).sort_index()
  
      factor_index = date_range(start=start, end=factor_end, freq="B")
      factor_index.name = "date"
      factor_index = factor_index.drop(holidays)
      factor = DataFrame(
          index=factor_index + Timedelta("9h30m"),
          columns=tickers,
          data=factor_data,
      ).stack()
  
      factor_data = get_clean_factor_and_forward_returns(
          factor,
          prices,
          groupby=factor_groups,
          quantiles=4,
          periods=(1, 2, 3),
      )
  
      expected_idx = factor.index.rename(["date", "asset"])
      expected_cols = [
          "1h",
          "3h",
          "1D",
          "factor",
          "group",
          "factor_quantile",
      ]
      expected_data = [
          [0.001, -0.002, 0.1, 3.0, 1, 3],
          [0.001, -0.002, -0.5, 4.0, 2, 4],
          [0.001, -0.002, 2.0, 2.0, 1, 2],
          [0.001, -0.002, -0.1, 1.0, 2, 1],
          [0.001, -0.002, 0.1, 3.0, 1, 3],
          [0.001, -0.002, -0.1, 1.0, 2, 1],
          [0.001, -0.002, -0.5, 4.0, 1, 4],
          [0.001, -0.002, 0.0, 2.0, 2, 2],
          [0.001, -0.002, 0.1, 3.0, 1, 3],
          [0.001, -0.002, -0.5, 4.0, 2, 4],
          [0.001, -0.002, 2.0, 2.0, 1, 2],
          [0.001, -0.002, -0.1, 1.0, 2, 1],
      ] * 6  # 18  days
      expected = DataFrame(
          index=expected_idx, columns=expected_cols, data=expected_data
      )
      expected["group"] = expected["group"].astype("category")
  
      assert_frame_equal(factor_data, expected)
  
      inferred_holidays = factor_data.index.levels[0].freq.holidays
      assert sorted(holidays) == sorted(inferred_holidays)
  
file_path: alphalens/alphalens/tests/test_utils.py
imports: from __future__ import division
  from unittest import TestCase
  from parameterized import parameterized
  from numpy import nan
  from pandas import Series, DataFrame, date_range, MultiIndex, Timedelta, Timestamp, concat
  from pandas.util.testing import assert_frame_equal, assert_series_equal
  from ..utils import get_clean_factor_and_forward_returns, compute_forward_returns, quantize_factor
label_desc: Use image node_id 9 for calling the UtilsTestCase obj's underlying member method code with example usage: obj.test_get_clean_factor_and_forward_returns_5() without return types