diff --git a/cycles/backtest.py b/cycles/backtest.py index cad4a5f..e146d86 100644 --- a/cycles/backtest.py +++ b/cycles/backtest.py @@ -31,7 +31,8 @@ class Backtest: """ Runs the backtest using provided entry and exit strategy functions. - The method iterates over the main DataFrame (self.df), simulating trades based on the entry and exit strategies. It tracks balances, drawdowns, and logs each trade, including fees. At the end, it returns a dictionary of performance statistics. + The method iterates over the main DataFrame (self.df), simulating trades based on the entry and exit strategies. + It tracks balances, drawdowns, and logs each trade, including fees. At the end, it returns a dictionary of performance statistics. Parameters: - entry_strategy: function, determines when to enter a trade. Should accept (self, i) and return True to enter. @@ -48,6 +49,7 @@ class Backtest: self.current_date = self.df['timestamp'].iloc[i] + # check if we are in buy/sell position if self.position == 0: if entry_strategy(self, i): self.handle_entry()