Beispiel #1
0
def plot_turnover_table(autocorrelation_data, quantile_turnover):
    turnover_table = pd.DataFrame()
    for period in sorted(quantile_turnover.keys()):
        for quantile, p_data in quantile_turnover[period].iteritems():
            turnover_table.loc[f"Quantile {quantile} Mean Turnover",
                               f"{period}"] = p_data.mean()

    auto_corr = pd.DataFrame()
    for period, p_data in autocorrelation_data.iteritems():
        auto_corr.loc["Mean Factor Rank Autocorrelation",
                      f"{period}"] = p_data.mean()

    print("Turnover Analysis")
    plotting_utils.print_table(turnover_table.apply(lambda x: x.round(3)))
    plotting_utils.print_table(auto_corr.apply(lambda x: x.round(3)))
Beispiel #2
0
def plot_quantile_statistics_table(factor_data: pd.DataFrame,
                                   by_group: bool = False):
    """
    分位统计量
    """
    grouper = ["factor_quantile"]
    if by_group:
        grouper.append("group")
    quantile_stats = factor_data.groupby(grouper).agg(
        ["min", "max", "mean", "std", "count"])["factor"]
    quantile_stats["count %"] = (quantile_stats["count"] /
                                 quantile_stats["count"].sum() * 100)

    print("Quantiles Statistics")
    plotting_utils.print_table(quantile_stats)
Beispiel #3
0
def plot_information_table(ic_data):
    """
    IC 统计量
    """
    ic_summary_table = pd.DataFrame()
    ic_summary_table["IC Mean"] = ic_data.mean()
    ic_summary_table["IC std."] = ic_data.std()
    ic_summary_table["Risk-Adjusted IC (IR)"] = ic_data.mean() / ic_data.std()
    t_stat, p_value = stats.ttest_1samp(ic_data, 0)
    ic_summary_table["t-stat (IC)"] = t_stat
    ic_summary_table["p-value (IC)"] = p_value
    ic_summary_table["IC Skew"] = stats.skew(ic_data)
    ic_summary_table["IC Kurtosis"] = stats.kurtosis(ic_data)

    print("Information Analysis")
    plotting_utils.print_table(ic_summary_table.apply(lambda x: x.round(3)).T)
Beispiel #4
0
def plot_returns_table(alpha_beta, mean_ret_quantile,
                       mean_ret_spread_quantile):
    """
    打印因子收益表, 需要输入因子的 alpha, beta, 分位收益情况
    """
    returns_table = pd.DataFrame()
    returns_table = returns_table.append(alpha_beta)
    returns_table.loc["Mean Period Wise Return Top Quantile (bps)"] = (
        mean_ret_quantile.iloc[-1] * DECIMAL_TO_BPS)
    returns_table.loc["Mean Period Wise Return Bottom Quantile (bps)"] = (
        mean_ret_quantile.iloc[0] * DECIMAL_TO_BPS)
    returns_table.loc["Mean Period Wise Spread (bps)"] = (
        mean_ret_spread_quantile.mean() * DECIMAL_TO_BPS)

    print("Returns Analysis")
    plotting_utils.print_table(returns_table.apply(lambda x: x.round(3)))