Skip to content

Commit

Permalink
Bug fix in ib_streamer.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
petioptrv committed Aug 20, 2020
1 parent ae80be3 commit 50a72d7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions algotradepy/streamers/ib_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def bars_update(

if not previously_requested:
ib_contract = self._to_ib_contract(contract=contract)
ib_duration = self._get_bars_duration_str(bar_size=bar_size)
ib_duration = self._get_bars_subscription_duration_str(
bar_size=bar_size
)
ib_bar_size = self._to_ib_bar_size(bar_size=bar_size)
bars = self._ib_conn.reqHistoricalData(
contract=ib_contract,
Expand Down Expand Up @@ -226,7 +228,7 @@ def _cancel_bars_subscription(
self._ib_conn.cancelHistoricalData(bars=bars)
del self._bars_subscriptions[contract]

def _get_bars_duration_str(self, bar_size: timedelta) -> str:
def _get_bars_subscription_duration_str(self, bar_size: timedelta) -> str:
self._validate_bar_size(bar_size=bar_size)

if bar_size == timedelta(seconds=1):
Expand All @@ -236,7 +238,7 @@ def _get_bars_duration_str(self, bar_size: timedelta) -> str:
elif bar_size <= timedelta(minutes=1):
duration_str = "60 S"
elif timedelta(minutes=1) < bar_size < timedelta(hours=1):
duration_str = "1 H"
duration_str = "3600 S"
elif timedelta(hours=1) <= bar_size < timedelta(days=1):
duration_str = "1 D"
elif timedelta(days=1):
Expand Down

0 comments on commit 50a72d7

Please sign in to comment.