Skip to content

Commit 8cd258c

Browse files
committed
datetime format fix
1 parent 86e49d4 commit 8cd258c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

alpaca_backtrader_api/alpacastore.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ def _make_sure_dates_are_initialized_properly(self, dtbegin, dtend,
441441
if not dtend:
442442
dtend = pd.Timestamp('now', tz=NY)
443443
else:
444-
dtend = pd.Timestamp(pytz.timezone('UTC').localize(dtend))
444+
dtend = pd.Timestamp(pytz.timezone('UTC').localize(dtend)) if \
445+
not dtend.tzname() else dtend
445446
if granularity == Granularity.Minute:
446447
calendar = trading_calendars.get_calendar(name='NYSE')
447448
while not calendar.is_open_on_minute(dtend):
@@ -455,7 +456,8 @@ def _make_sure_dates_are_initialized_properly(self, dtbegin, dtend,
455456
delta = timedelta(days=days)
456457
dtbegin = dtend - delta
457458
else:
458-
dtbegin = pd.Timestamp(pytz.timezone('UTC').localize(dtbegin))
459+
dtbegin = pd.Timestamp(pytz.timezone('UTC').localize(dtbegin)) if \
460+
not dtbegin.tzname() else dtbegin
459461
while dtbegin > dtend:
460462
# if we start the script during market hours we could get this
461463
# situation. this resolves that.

0 commit comments

Comments
 (0)