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 %')
评论列表
文章目录