def req_hist_data_async(self, *req_list: [object]):
"""
Concurrently downloads historical market data for multiple requests.
"""
ibparms_list = (self._hist_data_req_to_args(req) for req in req_list)
bars_list = await asyncio.gather(*(
self.reqHistoricalDataAsync(*ibparms)
for ibparms in ibparms_list))
df_list = [ib_insync.util.df(bars) for bars in bars_list]
xchg_tz_list = await asyncio.gather(*(
self.hist_data_req_timezone(req) for req in req_list))
blk_list = []
for req, df, xchg_tz in zip(req_list, df_list, xchg_tz_list):
_logger.debug(df.iloc[:3])
if req.BarSize[-1] in ('d', 'W', 'M'): # not intraday
dl_tz = xchg_tz # dates without timezone, init with xchg_tz.
else:
dl_tz = pytz.UTC
blk = MarketDataBlock(df, symbol=req.Symbol, datatype=req.DataType,
barsize=req.BarSize, tz=dl_tz)
blk.tz_convert(xchg_tz)
blk_list.append(blk)
return blk_list
评论列表
文章目录