显示回测结果。
(price_data, indicators, signals, blotter)
| 5 | from quantdigger.widgets.mplotwidgets import widgets, mplots |
| 6 | |
| 7 | def plot_result(price_data, indicators, signals, blotter): |
| 8 | """ |
| 9 | 显示回测结果。 |
| 10 | """ |
| 11 | try: |
| 12 | blotter.create_equity_curve_dataframe() |
| 13 | print blotter.output_summary_stats() |
| 14 | |
| 15 | fig = plt.figure() |
| 16 | frame = widgets.MultiWidgets(fig, |
| 17 | price_data, |
| 18 | 50 # 窗口显示k线数量。 |
| 19 | ) |
| 20 | |
| 21 | # 添加k线 |
| 22 | kwindow = widgets.CandleWindow("kwindow", price_data, 100, 50) |
| 23 | frame.add_widget(0, kwindow, True) |
| 24 | # 交易信号。 |
| 25 | signal = mplots.TradingSignalPos(None, price_data, signals, lw=2) |
| 26 | frame.add_indicator(0, signal) |
| 27 | |
| 28 | # 添加指标 |
| 29 | k_axes, = frame |
| 30 | for indic in indicators: |
| 31 | indic.plot(k_axes) |
| 32 | frame.draw_widgets() |
| 33 | |
| 34 | fig2 = plt.figure() |
| 35 | ax = fig2.add_axes((0.1, 0.1, 0.9, 0.9)) |
| 36 | ax.plot(blotter.equity_curve.equity) |
| 37 | plt.show() |
| 38 | |
| 39 | except Exception, e: |
| 40 | print(e) |
nothing calls this directly
no test coverage detected