这个跟参数多少没有关系,这个是pyqt的问题,最好出一个不需要ui交易的版本,
qt实在是呵呵哒
大部分情况是TWS API的问题,你要看log信息,才知道怎么改
最后发现还是req的问题:
self.client.reqHistoricalData(
self.reqid,
ib_contract,
'',# end_str, workaround
duration,
bar_size,
bar_type,
0,
1,
False,
[]
)
endDateTime, The request's end date and time (the empty string indicates current present moment).
买好包 wrote:
继续请教一下,ib的连续合约MHI,HSI是否只支持半年内的数据下载?怎么找更长时间的呢?
ibkr理论上最大只有180天,你看源码里面有注释
def query_history(self, req: HistoryRequest) -> List[BarData]:
"""查询历史数据"""
self.history_req = req
self.reqid += 1
ib_contract: Contract = generate_ib_contract(req.symbol, req.exchange)
if req.end:
end: datetime = req.end
end_str: str = end.strftime("%Y%m%d %H:%M:%S")
else:
end: datetime = datetime.now(self.local_tz)
end_str: str = ""
delta: timedelta = end - req.start
days: int = min(delta.days, 180) # IB 只提供6个月数据
Exception in thread Thread-15 (run):
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/ibapi/client.py", line 263, in run
self.decoder.interpret(fields)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/ibapi/decoder.py", line 1296, in interpret
handleInfo.processMeth(self, iter(fields))
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/ibapi/decoder.py", line 519, in processHistoricalDataMsg
self.wrapper.historicalData(reqId, bar)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/vnpy_ib/ib_gateway.py", line 619, in historicalData
symbol=self.history_req.symbol,
AttributeError: 'NoneType' object has no attribute 'symbol'