Skip to content

Commit

Permalink
Bars data streaming bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
petioptrv committed Aug 21, 2020
1 parent 3712bab commit 74ef8a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions algotradepy/streamers/ib_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def bars_update(
for func_, kwargs_ in funcs_dict_.items():
func_(bar_s, **kwargs_)

while len(bars_) != 0:
bars_.pop()
while len(bars_) != 1:
bars_.pop(0)

previously_requested = contract in self._bars_subscriptions

Expand Down
3 changes: 3 additions & 0 deletions tests/streamers/test_ib_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ def update(bar):
assert latest is not None
assert latest.name > datetime.now() - bar_size - timedelta(seconds=10)

prev = latest.copy()
latest = None
streamer.sleep(bar_size.seconds)

assert latest is not None
assert latest.name > datetime.now() - bar_size
assert latest.name > prev.name


def test_cancel_bars_data(streamer):
Expand Down

0 comments on commit 74ef8a7

Please sign in to comment.