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

Function plot_summary

quantdigger/widgets/mplotwidgets/stock_plot.py:195–288  ·  view source on GitHub ↗
(fig, exit_profit, entry_best, entry_worst, entry_nbar_best, entry_nbar_worst, 
                    exit_nbar_best, exit_nbar_worst, profits_more, risks, NBAR)

Source from the content-addressed store, hash-verified

193
194
195def plot_summary(fig, exit_profit, entry_best, entry_worst, entry_nbar_best, entry_nbar_worst,
196 exit_nbar_best, exit_nbar_worst, profits_more, risks, NBAR):
197 fig.canvas.set_window_title(u'��ͼ����')
198 ax11 = fig.add_subplot(3, 2, 1)
199 ax12 = fig.add_subplot(3, 2, 2)
200 ax21 = fig.add_subplot(3, 2, 3)
201 ax22 = fig.add_subplot(3, 2, 4)
202 ax31 = fig.add_subplot(3, 2, 5)
203 ax32 = fig.add_subplot(3, 2, 6)
204 #plt.subplots_adjust(left=0, right=1)
205
206 # Profits Distribution
207 shift = pd.Series([0]*len(exit_profit[exit_profit<=0]))
208 temp = pd.concat([shift, exit_profit[exit_profit>0]])
209 temp.index = range(len(temp))
210 temp.plot(ax=ax11, grid=False, use_index=False, style="r", label=u'ӯ��')
211 ax11.fill_between(range(len(temp)), [0]*len(temp), temp.tolist(), facecolor='r')
212 temp = 0 - exit_profit[exit_profit<=0]
213 ax11.plot(temp, 'y', label=u'����')
214 ax11.fill_between(range(len(temp)), [0]*len(temp), temp.tolist(), facecolor='y')
215 ax11.plot(entry_worst, 'b', label=u'���ƫ��')
216 ax11.axhline(color='black')
217 ax11.legend(prop=font, loc='upper left').get_frame().set_alpha(0.5)
218
219
220 # Profits Distribution Bins
221 #exit_profit.hist(ax=ax12, bins=50, normed=True, color='r')
222 #n, bins = np.histogram(exit_profit.tolist(), 50, normed=True)
223 #ax12.plot([0, 0], [0, max(n)], color='y', linewidth=2)
224 #ax12.grid(False)
225 exit_profit.plot(ax=ax12, kind='kde', color='b', label="")
226 binwidth = abs(exit_profit.min()/9)
227 bins = np.arange(exit_profit.min(), exit_profit.max() + binwidth, binwidth)
228 ax12.hist(exit_profit[exit_profit>0], bins=bins, color = 'red' , normed=False, label=u'ӯ���ֲ�')
229 ax12.hist(exit_profit[exit_profit<0], bins=bins, color = 'y' , normed=False, label=u'����ֲ�')
230 plot_contribution(ax12, bins, exit_profit, 'bo--')
231 ax12.legend(prop=font, loc='upper left').get_frame().set_alpha(0.5)
232 #ax12.set_yscale('log')
233
234 # MAE
235 MAE = entry_worst.reindex(exit_profit[exit_profit>0].index)
236 MAE.order().plot(ax=ax21,style='r', grid=False, use_index=False, label=u'�����ƫ��')
237 exit_profit[exit_profit<0].plot(ax=ax21, style='y', grid=False, use_index=False, label=u'����ֲ�')
238 worst = MAE.min()
239 print u"�����ƫ��: %s" % worst
240 bb = exit_profit[exit_profit<0]
241 aa = [worst]*len(bb)
242 ax21.fill_between(range(len(exit_profit[exit_profit<0])), aa, bb, where=bb<aa, color='red')
243 ax21.set_ylim((min(exit_profit.min(), MAE.min())-10), 0)
244 ax21.legend(prop=font, loc='upper left').get_frame().set_alpha(0.5)
245
246 # Potential Profits When Lose
247 temp = entry_best.reindex(exit_profit[exit_profit<0].index)
248 ax22.plot(temp.tolist(), color='r', label=u"����ӯ��" )
249 ax22.fill_between(range(len(temp)), temp.tolist(), [0]*len(temp), facecolor='r')
250 ax22.plot(temp.order().tolist(), color='b', label=u"��������ӯ��" )
251 ax22.plot(exit_profit[exit_profit<0].tolist(), color='y', label=u'ʵ�ʿ���')
252 ax22.set_ylim((min(exit_profit.min(), MAE.min())-10, temp.max()+10))

Callers 1

summary_analyzeFunction · 0.85

Calls 5

plot_contributionFunction · 0.85
add_subplotMethod · 0.80
mapFunction · 0.50
plotMethod · 0.45
orderMethod · 0.45

Tested by

no test coverage detected