refactor
This commit is contained in:
parent
f67b6b8ebd
commit
256ad67742
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user