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

This commit is contained in:
moshferatu 2024-12-04 11:16:16 -08:00
parent cc223be00b
commit 74cf8e4cea

View File

@ -3,13 +3,18 @@ from pandas import concat, DataFrame
from ohlc import ohlc from ohlc import ohlc
def get_daily_data(symbol: str, start_date: datetime = datetime.today() - timedelta(days = 365), def get_daily_data(symbol: str, start_date: datetime = None, end_date: datetime = None) -> DataFrame:
end_date: datetime = datetime.today()) -> 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) 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. 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() today = datetime.today().date()
if today not in daily_data['Date'].values: if today not in daily_data['Date'].values: