被困在这个问题上一段时间了。我们的帐户启用了所有未来市场数据权限,但是当我尝试为 MES 的当前期货合约请求历史柱数据时,我得到了Market Data Service error message:No market data permissions for GLOBEX FUT
。
contract = Contract()
contract.m_symbol = "MES"
contract.m_secType = "FUT"
contract.m_exchange = "GLOBEX"
contract.m_currency = "USD"
contract.m_expiry = "20200918"
contract.m_includeExpired = True
contract.m_multiplier = "5"
tws.reqMarketDataType(3)
tws.reqMktData(897,contract,"",False)
结果(工作正常):
<tickPrice tickerId=897, field=67, price=3083.5, canAutoExecute=-1> <tickPrice tickerId=897, field=68, price=3083.25, canAutoExecute=0> <tickPrice tickerId=897, field=72, price=3096.75, canAutoExecute=0> <tickPrice tickerId=897, field=73, price=3027.5, canAutoExecute=0> <tickPrice tickerId=897, field=75, price=3059.5, canAutoExecute=0> <tickPrice tickerId=897, field=76, price=3043.0, canAutoExecute=0>
但是,当我尝试使用相同合约的历史数据时:
contract = Contract()
contract.m_symbol = "MES"
contract.m_secType = "FUT"
contract.m_exchange = "GLOBEX"
contract.m_currency = "USD"
contract.m_expiry = "20200918"
contract.m_includeExpired = True
contract.m_multiplier = "5"
tws.reqMarketDataType(3)
tws.reqHistoricalData(50, contract=contract, endDateTime=strftime("%Y%m%d %H:%M:%S"), durationStr ="30 D", barSizeSetting = "1 day", whatToShow="TRADES", formatDate=1, useRTH= "1")
我收到来自 IB 的消息:
历史市场数据服务错误消息:GLOBEX FUT 没有市场数据权限
我做错什么了吗?我正在使用 IBPY2