docstr: Test mean_return_by_quantile
docstr_tok: ["Test","mean_return_by_quantile"]
code: def test_mean_return_by_quantile(
      self, daily_rets, factor, bins, by_group, expected_data
  ):
      """
      Test mean_return_by_quantile
      """
      tickers = ["A", "B", "C", "D", "E", "F"]
  
      factor_groups = {"A": 1, "B": 1, "C": 1, "D": 2, "E": 2, "F": 2}
  
      price_data = [
          [
              daily_rets[0] ** i,
              daily_rets[1] ** i,
              daily_rets[2] ** i,
              daily_rets[3] ** i,
              daily_rets[4] ** i,
              daily_rets[5] ** i,
          ]
          for i in range(1, 5)
      ]  # 4 days
  
      start = "2015-1-11"
      factor_end = "2015-1-13"
      price_end = "2015-1-14"  # 1D fwd returns
  
      price_index = date_range(start=start, end=price_end)
      price_index.name = "date"
      prices = DataFrame(
          index=price_index, columns=tickers, data=price_data
      )
  
      factor_index = date_range(start=start, end=factor_end)
      factor_index.name = "date"
      factor = DataFrame(
          index=factor_index, columns=tickers, data=factor
      ).stack()
  
      factor_data = get_clean_factor_and_forward_returns(
          factor,
          prices,
          groupby=factor_groups,
          quantiles=None,
          bins=bins,
          periods=(1,),
      )
  
      mean_quant_ret, std_quantile = mean_return_by_quantile(
          factor_data,
          by_date=False,
          by_group=by_group,
          demeaned=False,
          group_adjust=False,
      )
  
      expected = DataFrame(
          index=mean_quant_ret.index.copy(),
          columns=mean_quant_ret.columns.copy(),
          data=expected_data,
      )
      expected.index.name = "factor_quantile"
  
      assert_frame_equal(mean_quant_ret, expected)
  
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, Int64Index, Index, DatetimeIndex, Timedelta
  from pandas.tseries.offsets import BDay, Day, CDay
  from pandas.util.testing import assert_frame_equal, assert_series_equal
  from ..performance import factor_information_coefficient, mean_information_coefficient, mean_return_by_quantile, quantile_turnover, factor_rank_autocorrelation, factor_returns, factor_alpha_beta, cumulative_returns, factor_weights, common_start_returns, average_cumulative_return_by_quantile
  from ..utils import get_forward_returns_columns, get_clean_factor_and_forward_returns
label_desc: Use image node_id 3 for calling the PerformanceTestCase obj's underlying member method code with example usage: obj.test_mean_return_by_quantile(daily_rets, factor, bins, by_group, expected_data) without return types