pandas、plot笔记
def decorateAx(ax, xs, ys):
def x_fmt_func(x, pos=None):
idx = np.clip(int(x + 0.5), 0, len(xs) - 1)
return xs[idx]
idx_pxy = np.arange(len(xs))
ax.plot(idx_pxy, ys, color="green", linewidth=1, linestyle="-")
ax.plot(ax.get_xlim(), [0, 0], color="blue", linewidth=0.5, linestyle="--")
ax.xaxis.set_major_formatter(mtk.FuncFormatter(x_fmt_func))
ax.grid(True)
return
df1_t = df1[['Pnl','TraderA']]
df1_t_piv = df1_t.pivot(index=df1_t.index, columns = df1_t['TraderA'], values=df1_t['Pnl'])
df1_t_piv[-100:].cumsum().plot()
decorateAx(ax2, df1_t_piv.index[-100:], df1_t_piv[-100:].cumsum())
dfx= dfx.set_index('TraderId')
df1_traders = df1.loc[ [i_TraderA in ['Dlp', 'ZZCF'] for i_TraderA in df1['TraderA']], :]
df1_traders['Pnl'].cumsum().plot()