Add starting date parameter for which to retrieve the best entry times for the purpose of backtesting on historical data
This commit is contained in:
parent
e0d1783715
commit
477afffefa
@ -1,9 +1,9 @@
|
||||
from database.backtest import backtest_results
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def best_entry_times(lookback_period: int = 10):
|
||||
end_date = datetime.now().replace(hour = 0, minute = 0, second = 0, microsecond = 0)
|
||||
start_date = end_date - timedelta(days = lookback_period)
|
||||
def best_entry_times(date: datetime = datetime.now(), days_to_look_back: int = 10):
|
||||
end_date = date.replace(hour = 0, minute = 0, second = 0, microsecond = 0)
|
||||
start_date = end_date - timedelta(days = days_to_look_back)
|
||||
|
||||
backtest = backtest_results('SPX', '10 Delta Iron Condor', start_date = start_date, end_date = end_date)
|
||||
backtest['Entry Time'] = backtest['Entry Time'].dt.time
|
||||
|
@ -2,4 +2,4 @@ from backtesting import best_entry_times
|
||||
|
||||
print(best_entry_times())
|
||||
|
||||
print(best_entry_times(lookback_period = 30)) # Days.
|
||||
print(best_entry_times(days_to_look_back = 30)) # Days.
|
Loading…
Reference in New Issue
Block a user