(exit_profits, entry_bests, entry_worsts, entry_nbar_bests, entry_nbar_worsts,
exit_nbar_bests, exit_nbar_worsts, profits_mores, risks, colors, names, NBAR)
| 346 | |
| 347 | |
| 348 | def plot_compare(exit_profits, entry_bests, entry_worsts, entry_nbar_bests, entry_nbar_worsts, |
| 349 | exit_nbar_bests, exit_nbar_worsts, profits_mores, risks, colors, names, NBAR): |
| 350 | fig = plt.figure(facecolor='white') |
| 351 | fig.canvas.set_window_title(u'��ͼ����һ') |
| 352 | ax11 = fig.add_subplot(3, 2, 1) |
| 353 | ax12 = fig.add_subplot(3, 2, 2) |
| 354 | ax21 = fig.add_subplot(3, 2, 3) |
| 355 | ax22 = fig.add_subplot(3, 2, 4) |
| 356 | ax31 = fig.add_subplot(3, 2, 5) |
| 357 | ax32 = fig.add_subplot(3, 2, 6) |
| 358 | #plt.subplots_adjust(left=0, right=1) |
| 359 | for i in range(len(exit_profits)): |
| 360 | nm = names[i] |
| 361 | exit_profit = exit_profits[i] |
| 362 | entry_best = entry_bests[i] |
| 363 | entry_worst = entry_worsts[i] |
| 364 | entry_nbar_best = entry_nbar_bests[i] |
| 365 | entry_nbar_worst = entry_nbar_worsts[i] |
| 366 | exit_nbar_best = exit_nbar_bests[i] |
| 367 | exit_nbar_worst = exit_nbar_worsts[i] |
| 368 | profits_more = profits_mores[i] |
| 369 | risk = risks[i] |
| 370 | c = colors[i] |
| 371 | |
| 372 | # Profits Distribution |
| 373 | shift = pd.Series([0]*len(exit_profit[exit_profit<=0])) |
| 374 | temp = pd.concat([shift, exit_profit[exit_profit>0]]) |
| 375 | temp.index = range(len(temp)) |
| 376 | temp.plot(ax=ax11, grid=False, use_index=False, style=c, label=u'%sӯ��'%nm) |
| 377 | temp = 0 - exit_profit[exit_profit<=0] |
| 378 | ax11.plot(temp.tolist(), c, label=u'%s����'%nm) |
| 379 | ax11.plot(entry_worst.tolist(), c, label=u'%s���ƫ��'%nm) |
| 380 | #ax11.set_xscale('log') |
| 381 | |
| 382 | |
| 383 | # Profits Distribution Bins |
| 384 | #exit_profit.hist(ax=ax12, bins=50, normed=True, color=c) |
| 385 | #exit_profit.plot(ax=ax12, kind='kde', color='b', label="") |
| 386 | #ax12.legend(prop=font, loc='upper left').get_frame().set_alpha(0.5) |
| 387 | a = np.histogram(exit_profit.tolist(), 50, normed=True) |
| 388 | n = pd.Series(a[0]) |
| 389 | bins = pd.Series(a[1][:-1]) |
| 390 | temp = bins[bins>0] |
| 391 | ax12.plot(temp.tolist(), n.reindex(temp.index).tolist(), c, label=u'%sӯ���ֲ�'%nm) |
| 392 | temp = bins[bins<0] |
| 393 | ax12.plot(temp.tolist(), n.reindex(temp.index).tolist(), '%s--'%c, label=u'%s����ֲ�'%nm) |
| 394 | ax12.legend(prop=font, loc='upper left').get_frame().set_alpha(0.5) |
| 395 | |
| 396 | |
| 397 | # MAE |
| 398 | MAE = entry_worst.reindex(exit_profit[exit_profit>0].index) |
| 399 | MAE.order().plot(ax=ax21,style=c, grid=False, use_index=False, label=u'%s�����ƫ��'%nm) |
| 400 | exit_profit[exit_profit<0].plot(ax=ax21, style='%s--'%c, grid=False, use_index=False, label=u'%s����ֲ�'%nm) |
| 401 | |
| 402 | # Potential Profits When Lose |
| 403 | temp = entry_best.reindex(exit_profit[exit_profit<0].index) |
| 404 | ax22.plot(temp.tolist(), c, label=u"%s����ӯ��" % nm) |
| 405 | ax22.plot(temp.order().tolist(), '%s--'%c, label=u"%s��������ӯ��" % nm) |
no test coverage detected