RQAlpha is really a effective tool for price back-testing.
I found something wrong when using command # rqalpha plot someresult.pkl to plot my back-testing result. It came out a blank window. I tried to solve this problem and found something interesting.
in rqalpha/rqalpha/mod/rqalpha_mod_sys_analyser/plot.py, line 52-53
Hello, RQAlpha Team
RQAlpha is really a effective tool for price back-testing.
I found something wrong when using command
# rqalpha plot someresult.pkl
to plot my back-testing result. It came out a blank window. I tried to solve this problem and found something interesting.in
rqalpha/rqalpha/mod/rqalpha_mod_sys_analyser/plot.py
, line 52-53by printing portfolio.index and benchmark_portfolio.index , I found an unreasonable difference.
According to https://github.com/pandas-dev/pandas/issues/8614 says, matplotlib can not plotting when DatetimeIndex is created by pandas > 0.15 .
I found a temporary way to solve this problem. and finally plotting was working functionally.
Use
index.to_pydatetime()
to explicitly convertDatetimeIndex
type index to PythonDatetime
type.For example: modify
rqalpha/rqalpha/mod/rqalpha_mod_sys_analyser/plot.py
, line 152ax.plot(portfolio["unit_net_value"] - 1.0, label=_(u"strategy"), alpha=1, linewidth=2, color=red)
toax.plot(index.to_pydatetime(),portfolio["unit_net_value"] - 1.0, label=_(u"strategy"), alpha=1, linewidth=2, color=red)
Although it is not the best way to solve this problem, I know you can find the best one finally. And I hope these information may help you.
Thanks.