From 74cf8e4cea68fe4f854288a5b0873194f78c28a4 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Wed, 4 Dec 2024 11:16:16 -0800 Subject: [PATCH] Set default start and end date for daily data inside of method body instead of in the parameter list so that the current date is updated every call --- daily_data.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/daily_data.py b/daily_data.py index 6db405c..1f36c6d 100644 --- a/daily_data.py +++ b/daily_data.py @@ -3,13 +3,18 @@ from pandas import concat, DataFrame from ohlc import ohlc -def get_daily_data(symbol: str, start_date: datetime = datetime.today() - timedelta(days = 365), - end_date: datetime = datetime.today()) -> DataFrame: +def get_daily_data(symbol: str, start_date: datetime = None, end_date: datetime = None) -> DataFrame: + + if start_date is None: + start_date = datetime.today() - timedelta(days = 365) + if end_date is None: + end_date = datetime.today() + daily_data = ohlc(symbol = symbol, start_date = start_date, end_date = end_date) """ The daily bar is not available for the current day until after market close. - It must be calculated using intraday (e.g., 5-minute) bars while the market is open. + It must be calculated using intraday bars while the market is open. """ today = datetime.today().date() if today not in daily_data['Date'].values: