Skip to content

Commit 20a9d15

Browse files
committed
Merge pull request ranaroussi#55 from miguelvm/master
Fixed timezone issues when using a local timezone in algorithm
1 parent 8d74f58 commit 20a9d15

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

qtpylib/algo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@ def _tick_handler(self, tick, stale_tick=False):
709709
self.ticks = self._thread_safe_merge(symbol, self.ticks, self_ticks) # assign back
710710
else:
711711
self.ticks = self._update_window(self.ticks, tick)
712-
bars = tools.resample(self.ticks, self.resolution)
712+
# bars = tools.resample(self.ticks, self.resolution)
713+
bars = tools.resample(self.ticks, self.resolution, tz=self.timezone)
713714

714715
if len(bars.index) > self.tick_bar_count > 0 or stale_tick:
715716
self.record_ts = tick.index[0]

qtpylib/tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ def resample_ticks(data, freq=1000, by='last'):
557557
# force same last timestamp to all symbols before resampling
558558
if sync_last_timestamp:
559559
last_row = data[data['symbol']==sym][-1:]
560-
last_row.index = pd.to_datetime(data.index[-1:], utc=True)
560+
# last_row.index = pd.to_datetime(data.index[-1:], utc=True)
561+
last_row.index = data.index[-1:]
561562
if "last" not in data.columns:
562563
last_row["open"] = last_row["close"]
563564
last_row["high"] = last_row["close"]

0 commit comments

Comments
 (0)