Force start and end date parameters to the beginning and end of the day respectively
This commit is contained in:
parent
6d3490fa4f
commit
2d6231354f
10
ohlc/ohlc.py
10
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())
|
||||
return get_historical_data(symbol, interval = to_minutes(minutes), start_date = start_date, end_date = end_date)
|
Loading…
Reference in New Issue
Block a user