Been stuck on this for a while. All future market data permissions are enabled on our account, however when I try request historical bar data for the current futures contract for MES I get 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)
Result (works fine):
<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>
However when I try for historical data with the same contract:
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")
I get the message from IB:
Historical Market Data Service error message:No market data permissions for GLOBEX FUT
Am I doing anything clearly wrong? I'm using IBPY2
To receive historical data from the Trader Workstation API for exchange-traded instruments (stocks, futures, options, etc), its necessary to have live data permissions for that instrument setup in your IB account.
http://interactivebrokers.github.io/tws-api/historical_data.html
It is possible to receive 10-15 minute delayed streaming data without the live data subscriptions for those instruments.
The number 3 with the function call tws.reqMarketDataType(3)
indicates that delayed data will be requested by the function tws.reqMktData(897,contract,"",False)
. Live data, the default, would be indicated by the number 1.
http://interactivebrokers.github.io/tws-api/delayed_data.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.