MCPcopy Index your code
hub / github.com/QuantFans/quantdigger / plot_result

Function plot_result

quantdigger/demo/plotting.py:7–40  ·  view source on GitHub ↗

显示回测结果。

(price_data, indicators, signals, blotter)

Source from the content-addressed store, hash-verified

5from quantdigger.widgets.mplotwidgets import widgets, mplots
6
7def 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)

Callers

nothing calls this directly

Calls 6

add_widgetMethod · 0.95
add_indicatorMethod · 0.95
draw_widgetsMethod · 0.95
output_summary_statsMethod · 0.80
plotMethod · 0.45

Tested by

no test coverage detected