def compute_top_minus_index_spread(mean_returns,
                                market_index):
    """
    Computes the difference between the mean returns of
    two quantiles. Optionally, computes the standard error
    of this difference.
    Parameters
    ----------
    mean_returns : pd.DataFrame
        DataFrame of mean period wise returns by quantile.
        MultiIndex containing date and quantile.
        See mean_return_by_quantile.
    market_index: pd.DataFrame
    Returns
    -------
    mean_return_difference : pd.Series

    """
    mean_return_difference = mean_returns.xs(mean_returns.index.levels[0].max(),
                                             level='factor_quantile')-market_index
    
    # tmp=pd.merge(mean_returns.xs(mean_returns.index.levels[0].max(),level='factor_quantile'),
    #             )

    return mean_return_difference