Skip to content

Commit 9e7475b

Browse files
authored
Merge pull request #181 from alpacahq/data_v2
Smal fixes (data source, date format)
2 parents 0ba1604 + 8cd258c commit 9e7475b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

alpaca_backtrader_api/alpacastore.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def __init__(
128128
self.conn = Stream(api_key,
129129
api_secret,
130130
base_url,
131+
data_stream_url=data_url,
131132
data_feed=data_feed)
132133
self.instrument = instrument
133134
self.method = method
@@ -440,7 +441,8 @@ def _make_sure_dates_are_initialized_properly(self, dtbegin, dtend,
440441
if not dtend:
441442
dtend = pd.Timestamp('now', tz=NY)
442443
else:
443-
dtend = pd.Timestamp(pytz.timezone('UTC').localize(dtend))
444+
dtend = pd.Timestamp(pytz.timezone('UTC').localize(dtend)) if \
445+
not dtend.tzname() else dtend
444446
if granularity == Granularity.Minute:
445447
calendar = trading_calendars.get_calendar(name='NYSE')
446448
while not calendar.is_open_on_minute(dtend):
@@ -454,7 +456,8 @@ def _make_sure_dates_are_initialized_properly(self, dtbegin, dtend,
454456
delta = timedelta(days=days)
455457
dtbegin = dtend - delta
456458
else:
457-
dtbegin = pd.Timestamp(pytz.timezone('UTC').localize(dtbegin))
459+
dtbegin = pd.Timestamp(pytz.timezone('UTC').localize(dtbegin)) if \
460+
not dtbegin.tzname() else dtbegin
458461
while dtbegin > dtend:
459462
# if we start the script during market hours we could get this
460463
# situation. this resolves that.

0 commit comments

Comments
 (0)