Changing reqMarketDataType to 3 or 4 did not solve the problem for me.The strange thing is that reqHistoricalData works if I set reqMarketDataType as 3 or 4. If I set it as 1 or 2 I get the "No market data permissions" error.
Changing reqMarketDataType to 3 or 4 did not solve the problem for me.The strange thing is that reqHistoricalData works if I set reqMarketDataType as 3 or 4. If I set it as 1 or 2 I get the "No market data permissions" error.
I notice that @newbunch is requesting MIDPOINT whereas @younggotti is using TRADES.
I believe that MIDPOINT only works for currencies, not for futures and stocks.
Sorry for the OT, but I was hoping someone could help me on this.
My understanding was that through IB's API it's possible to get historical price data only for instruments for which I have a paid data subscription. I also thought that, for instruments for which I don't pay, the only kind of data I could get was a price snapshot through ib.reqMktData(contract, snapshot = True), after setting ib.reqMarketDataType(3).
But now I realized that reqHistoricalData works also on exchanges for which I don't pay for data, and it works with daily data but also with 5secs data.
What am I missing?
from ib_insync import Future
from ib_insync import IB
ib = IB()
ib.connect("127.0.0.1", 7496)
ib.reqMarketDataType(3)
contract = Future("MES", "202303", "CME")
ib.qualifyContracts(contract)
bars = ib.reqHistoricalData(contract, endDateTime='', durationStr='1 M', barSizeSetting='1 day', whatToShow='TRADES',
useRTH=True, formatDate=1)
print(bars)
Perhaps it depends on the build. I am on TWS: Build 10.19.1k, Jan 23, 2023 5:13:03 PMWow!
I can confirm this is working for me too, at least with TWS...have not tried with the Gateway.
Edit: also wanted to add that I have definitely tried this before (a couple years ago, not recently), and it didn't work.
I'm using TWS version: Build 10.21.1o, Feb 14, 2023 5:00:24 PM
I'm using 10.19.1k too, so the different behaviour doesn't depend on different buildsPerhaps it depends on the build. I am on TWS: Build 10.19.1k, Jan 23, 2023 5:13:03 PM