Skip to content

Commit 1ee0450

Browse files
committed
Plot absolute PnL when relative_equity is disabled
1 parent 9c2b8e1 commit 1ee0450

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

β€Žbacktesting/_plotting.pyβ€Ž

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,15 @@ def _plot_pl_section():
438438
fig = new_indicator_figure(y_axis_label="Profit / Loss", height=80)
439439
fig.add_layout(Span(location=0, dimension='width', line_color='#666666',
440440
line_dash='dashed', level='underlay', line_width=1))
441-
trade_source.add(trades['ReturnPct'], 'returns')
441+
if relative_equity:
442+
pl = trades['ReturnPct']
443+
pl_tooltip = '@returns{+0.[000]%}'
444+
pl_format = '0.[00]%'
445+
else:
446+
pl = trades['PnL']
447+
pl_tooltip = '@returns{$ 0,0}'
448+
pl_format = '$ 0.0 a'
449+
trade_source.add(pl, 'returns')
442450
size = trades['Size'].abs()
443451
size = np.interp(size, (size.min(), size.max()), (8, 20))
444452
trade_source.add(size, 'marker_size')
@@ -455,9 +463,9 @@ def _plot_pl_section():
455463
tooltips = [("Size", "@size{0,0}")]
456464
if 'count' in trades:
457465
tooltips.append(("Count", "@count{0,0}"))
458-
set_tooltips(fig, tooltips + [("P/L", "@returns{+0.[000]%}")],
466+
set_tooltips(fig, tooltips + [("P/L", pl_tooltip)],
459467
vline=False, renderers=[r1])
460-
fig.yaxis.formatter = NumeralTickFormatter(format="0.[00]%")
468+
fig.yaxis.formatter = NumeralTickFormatter(format=pl_format)
461469
return fig
462470

463471
def _plot_volume_section():

0 commit comments

Comments
Β (0)