我正在使用 Python 和 ib_insync 来使用 Interactive brokers API,我正在尝试获取未来期权合约的 Bid、Ask、AskSize 等市场数据,但是当在股票代码上转换此合约时,我得到“没有安全定义已找到请求”,即使我之前分配了此属性。
# using Future from ib_insync has the same problem
# contract = Future('ES',"20190315",'GLOBEX')
contract = Contract()
contract.symbol = "ES"
contract.secType = "FOP"
contract.exchange = "GLOBEX"
contract.currency = "USD"
contract.lastTradeDateOrContractMonth = "20190315"
contract.strike = 2900
contract.right = "C"
contract.multiplier = "50"
result =[]
result.append(contract)
ib.reqMarketDataType(3)
ib.qualifyContracts(*result)
ticker = ib.reqMktData(contract,"",False,False)
ib.sleep(3)
ticker
输出:
Error 200, reqId 26: No security definition has been found for the request, contract: Contract(secType='FOP', symbol='ES', lastTradeDateOrContractMonth='20190315', strike=2900, right='C', multiplier='50', exchange='GLOBEX', currency='USD')
Unknown contract: Contract(secType='FOP', symbol='ES', lastTradeDateOrContractMonth='20190315', strike=2900, right='C', multiplier='50', exchange='GLOBEX', currency='USD')