backtrader_addons icon indicating copy to clipboard operation
backtrader_addons copied to clipboard

backtrader_addons/analyzers/trade_list.py : float division by zero

Open FGU1 opened this issue 4 years ago • 0 comments

Ab-trader, first of all, thanks for the addons !

I noticed that backtrader_addons/analyzers/trade_list.py can give a divide by 0 error :

line 78, in notify_trade pbar = pnl / barlen ZeroDivisionError: float division by zero

I guess this happen when entry and exit occur in the same bar. Looks like checking barlen for 0 value would be safer

FGU1 avatar Jul 28 '20 17:07 FGU1