From fd785598aa715d0dd13191944c44703b091790d2 Mon Sep 17 00:00:00 2001 From: Marco D'Ambros Date: Thu, 17 Oct 2024 23:51:17 +0200 Subject: [PATCH] added timeout from env variable to ib client when making request. Fixed a small bug in logging when subscribing to bars in IB. --- .../adapters/interactive_brokers/client/market_data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nautilus_trader/adapters/interactive_brokers/client/market_data.py b/nautilus_trader/adapters/interactive_brokers/client/market_data.py index 82c52d912909..9105fa42ebf9 100644 --- a/nautilus_trader/adapters/interactive_brokers/client/market_data.py +++ b/nautilus_trader/adapters/interactive_brokers/client/market_data.py @@ -14,6 +14,7 @@ # ------------------------------------------------------------------------------------------------- import functools +import os from collections.abc import Callable from decimal import Decimal from inspect import iscoroutinefunction @@ -109,7 +110,7 @@ async def _subscribe( """ if not (subscription := self._subscriptions.get(name=name)): self._log.info( - f"Creating and registering a new Subscription instance for {subscription}", + f"Creating and registering a new Subscription instance for {name}", ) req_id = self._next_req_id() if subscription_method == self.subscribe_historical_bars: @@ -390,7 +391,8 @@ async def get_historical_bars( return [] self._log.debug(f"reqHistoricalData: {request.req_id=}, {contract=}") request.handle() - return await self._await_request(request, timeout, default_value=[]) + ib_timeout = int(os.environ.get("IB_REQUEST_TIMEOUT", timeout)) + return await self._await_request(request, ib_timeout, default_value=[]) else: self._log.info(f"Request already exist for {request}") return []