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

Function plot_contribution

quantdigger/widgets/mplotwidgets/stock_plot.py:465–492  ·  view source on GitHub ↗

docstring for plot_contribution

(ax, bins, v, style)

Source from the content-addressed store, hash-verified

463
464
465def plot_contribution(ax, bins, v, style):
466 '''docstring for plot_contribution'''
467 ctri = np.array(range(len(bins)-1))
468 ymin, ymax = ax.get_ylim()
469 for i in range(len(bins)-1):
470 t = v[bins[i]<=v]
471 t = t[t<bins[i+1]]
472 ctri[i] = t.sum()
473 x = [(bins[i]+bins[i+1])/2 for i in range(len(bins)-1)]
474 nx, ny = ax_normed_data(x, ctri, ymax)
475 ax.plot(nx, ny, style)
476
477 losex = []
478 losey = []
479 winx = []
480 winy = []
481 for i in range(len(x)):
482 if x[i]<0:
483 losex.append(x[i])
484 losey.append(ctri[i])
485 else:
486 winx.append(x[i])
487 winy.append(ctri[i])
488 losey = [i for i in accumulate(losey[::-1])]
489 losey = losey[::-1]
490 winy = [i for i in accumulate(winy)]
491 nx, ny = ax_normed_data(x, np.array(losey+winy), ymax)
492 ax.plot(nx, ny, 'k')
493
494
495def plot_summary2(fig, rtn, entry_best, data_win, data_lose, exit_profit,

Callers 2

plot_summaryFunction · 0.85
plot_summary2Function · 0.85

Calls 3

ax_normed_dataFunction · 0.85
accumulateFunction · 0.85
plotMethod · 0.45

Tested by

no test coverage detected