Skip to content

Commit ab17cbf

Browse files
authored
Auto-scale Y-axis for PL chart when zooming kernc#356
1 parent 5ca9a59 commit ab17cbf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: backtesting/_plotting.py

+3
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ def _plot_pl_section():
391391
returns_short = np.where(trades['Size'] < 0, trades['ReturnPct'], np.nan)
392392
size = trades['Size'].abs()
393393
size = np.interp(size, (size.min(), size.max()), (8, 20))
394+
ohlcv_index_trade_close_arr = np.empty(source.data['index'][-1]+1,dtype=float)
395+
ohlcv_index_trade_close_arr[trade_source.data['index']] = trades['ReturnPct']
396+
source.add(ohlcv_index_trade_close_arr,'return_pct')
394397
trade_source.add(returns_long, 'returns_long')
395398
trade_source.add(returns_short, 'returns_short')
396399
trade_source.add(size, 'marker_size')

0 commit comments

Comments
 (0)