RQAlpha BUG Issue#219
Pingback https://github.com/ricequant/rqalpha/issues/219 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-53
portfolio = result_dict["portfolio"]
benchmark_portfolio = result_dict.get("benchmark_portfolio")
print portfolio.index
print benchmark_portfolio.index
by 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 convert DatetimeIndex type index to Python Datetime type. For example: modify rqalpha/rqalpha/mod/rqalpha_mod_sys_analyser/plot.py, line 152 ax.plot(portfolio["unit_net_value"] - 1.0, label=_(u"strategy"), alpha=1, linewidth=2, color=red) to ax.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.