From bc3b4729af1afc06207d7114047a113ed2eeb3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Rodr=C3=ADguez=20Chatruc?= Date: Thu, 23 Jan 2020 17:50:14 -0300 Subject: [PATCH] Summary's largest loss can no longer be negative --- backtester/backtester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backtester/backtester.py b/backtester/backtester.py index 8be3967..0d90e07 100644 --- a/backtester/backtester.py +++ b/backtester/backtester.py @@ -182,7 +182,7 @@ class Backtest: win_number = np.sum(wins) loss_number = total_trades - win_number win_pct = (win_number / total_trades) * 100 - largest_loss = np.max(costs) + largest_loss = max(0, np.max(costs)) avg_profit = np.mean(-costs) avg_pl = np.mean(daily_returns) total_pl = (df['totals']['capital'].iloc[-1] / self._strategy.initial_capital) * 100