Skip to content

Commit a268bbc

Browse files
author
Shlomi Kushchi
authored
Merge pull request #317 from alpacahq/avoid_changing_date_as_ints
fix_daily_bar_date for polygon data type fix
2 parents e87ac0d + d84675e commit a268bbc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

alpaca_trade_api/polygon/rest.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ def fix_daily_bar_date(date, timespan):
8080
so basically this method will add 1 day (if 'to' is not today, we don't
8181
have today's data until tomorrow) to the 'to' field
8282
"""
83-
if timespan == 'day':
84-
date = dateutil.parser.parse(date)
85-
today = datetime.datetime.utcnow().date()
86-
if today != date.date():
87-
date = date + datetime.timedelta(days=1)
88-
date = date.date().isoformat()
83+
if not isinstance(date, int):
84+
if timespan == 'day':
85+
date = dateutil.parser.parse(date)
86+
today = datetime.datetime.utcnow().date()
87+
if today != date.date():
88+
date = date + datetime.timedelta(days=1)
89+
date = date.date().isoformat()
8990
return date
9091

9192

0 commit comments

Comments
 (0)