Skip to content

Commit 9286232

Browse files
committed
ENH: Plot trade duration lines when plot_pl=True
Fixes #714
1 parent 5e72e7b commit 9286232

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

backtesting/_plotting.py

+4
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ def _plot_pl_section():
435435
trade_source.add(size, 'marker_size')
436436
if 'count' in trades:
437437
trade_source.add(trades['count'], 'count')
438+
trade_source.add(trades[['EntryBar', 'ExitBar']].values.tolist(), 'lines')
439+
trade_source.add([[0, r] for r in trades['ReturnPct'].values], 'returns_both')
440+
fig.multi_line(xs='lines', ys='returns_both',
441+
source=trade_source, color='#bbb', line_width=1)
438442
r1 = fig.scatter('index', 'returns_long', source=trade_source, fill_color=cmap,
439443
marker='triangle', line_color='black', size='marker_size')
440444
r2 = fig.scatter('index', 'returns_short', source=trade_source, fill_color=cmap,

0 commit comments

Comments
 (0)