sentisignal.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:sentisignal 作者: jonathanmanfield 项目源码 文件源码
def plot_inf_res(df, symbols=[], plot_top=0, time_shift=0):

    if len(symbols) > 0:
        df = df.loc[symbols]

    if plot_top > 0:
        idx = df.groupby(level=0)['INFORMATION_SURPLUS_PCT'].max().sort_values(ascending=False).index
        df = df.reindex(index=idx, level=0)[0:(time_shift+1)*plot_top]

    grouped = df.groupby(level=0)
    ax = plt.figure()
    first = True
    for i, group in grouped:
        if first:
            ax = group.plot(x='SHIFT', y='INFORMATION_SURPLUS_PCT', label=str(i))
            first = False
        else:
            group.plot(ax=ax, x='SHIFT', y='INFORMATION_SURPLUS_PCT', label=str(i))

    plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=1.0)
    ax.set_xlabel('Time-shift of sentiment data (days) with financial data')
    ax.set_ylabel('Information Surplus %')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号