From 2d6231354f74d5da9eda3871212693ea1f86557d Mon Sep 17 00:00:00 2001 From: moshferatu Date: Mon, 21 Oct 2024 09:11:04 -0700 Subject: [PATCH] Force start and end date parameters to the beginning and end of the day respectively --- ohlc/ohlc.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ohlc/ohlc.py b/ohlc/ohlc.py index 2246c32..d1f90da 100644 --- a/ohlc/ohlc.py +++ b/ohlc/ohlc.py @@ -3,7 +3,13 @@ from datetime import datetime from iqfeed import get_daily_data, get_historical_data, minutes as to_minutes def ohlc(symbol: str, minutes: int = None, start_date: datetime = None, end_date: datetime = None): + start_date = start_date or datetime.today() + end_date = end_date or datetime.today() + + start_date = datetime.combine(start_date, datetime.min.time()) + end_date = datetime.combine(end_date, datetime.max.time()) + if minutes is None: - return get_daily_data(symbol, start_date, end_date or datetime.today()) + return get_daily_data(symbol, start_date, end_date) else: - return get_historical_data(symbol, interval = to_minutes(minutes), start_date = start_date, end_date = end_date or datetime.today()) \ No newline at end of file + return get_historical_data(symbol, interval = to_minutes(minutes), start_date = start_date, end_date = end_date) \ No newline at end of file