Skip to content

Commit e342f24

Browse files
committed
chore: changed marketdata_history_by_id type hint
1 parent ffabce2 commit e342f24

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ibind/client/ibkr_client_mixins/marketdata_mixin.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime
2-
from typing import Union, TYPE_CHECKING, List, Dict
2+
from typing import Union, TYPE_CHECKING, List, Dict, Hashable
33

44
from ibind.base.rest_client import Result
55
from ibind.client.ibkr_definitions import snapshot_by_id
@@ -193,7 +193,7 @@ def marketdata_history_by_symbol(
193193

194194
def marketdata_history_by_conids(
195195
self: 'IbkrClient',
196-
conids: Union[List[str], Dict[str, str]],
196+
conids: Union[List[str], Dict[Hashable, str]],
197197
period: str = '1min',
198198
bar: str = '1min',
199199
outside_rth: bool = True,
@@ -207,7 +207,7 @@ def marketdata_history_by_conids(
207207
For each conid provided, it queries the marketdata history for the specified symbols. The results are then cleaned up and unified. Due to this grouping and post-processing, this method returns data directly without the Result dataclass.
208208
209209
Parameters:
210-
conids (OneOrMany[str]): A list of conids to get market data for.
210+
conids (Union[List[str], Dict[Hashable, str]]): A list of conids to get market data for.
211211
exchange (str, optional): Returns the exchange you want to receive data from.
212212
period (str): Overall duration for which data should be returned. Default to 1w. Available time period– {1-30}min, {1-8}h, {1-1000}d, {1-792}w, {1-182}m, {1-15}y.
213213
bar (str): Individual bars of data to be returned. Possible values– 1min, 2min, 3min, 5min, 10min, 15min, 30min, 1h, 2h, 3h, 4h, 8h, 1d, 1w, 1m.
@@ -221,23 +221,23 @@ def marketdata_history_by_conids(
221221
"""
222222

223223
if not isinstance(conids, dict):
224-
# In case conids aren't a symbol->conid dict, generate a dummy conid->conid dict in order to preserve the functionality. In such case, the 'symbol' variable actually is a 'conid'.
224+
# In case conids aren't a hashable->conid dict, generate a dummy conid->conid dict in order to preserve the functionality. In such case, the 'key' variable actually is a 'conid'.
225225
conids = {conid: conid for conid in conids}
226226

227227
static_params = {'period': period, 'bar': bar, 'outside_rth': outside_rth, 'start_time': start_time}
228-
requests = {symbol: {'kwargs': {'conid': conid} | static_params} for symbol, conid in conids.items()}
228+
requests = {key: {'kwargs': {'conid': conid} | static_params} for key, conid in conids.items()}
229229

230230
# when there is only one conid, we avoid running in parallel
231231
if run_in_parallel and len(conids) > 1:
232232
# /iserver/marketdata/history accepts 5 concurrent requests in theory, but sometime throttles above 4
233233
market_history_responses = execute_in_parallel(self.marketdata_history_by_conid, requests=requests, max_workers=4)
234234
else:
235235
market_history_responses = {}
236-
for symbol, request in requests.items():
236+
for key, request in requests.items():
237237
try:
238-
market_history_responses[symbol] = self.marketdata_history_by_conid(**request['kwargs'])
238+
market_history_responses[key] = self.marketdata_history_by_conid(**request['kwargs'])
239239
except Exception as e:
240-
market_history_responses[symbol] = e
240+
market_history_responses[key] = e
241241

242242
results = cleanup_market_history_responses(market_history_responses, raise_on_error=raise_on_error)
243243

0 commit comments

Comments
 (0)