hmm, I just tried Coffee (KC), for which I don't have a subscription, and reqHistoricalData worked, but only after adding reqMarketDataType(3). I've never tried it before, so can't say if it always worked or it's something new..
I also did this last summer for a bunch of ICE markets for which I didn't have a subscription and it worked for me as well then, for what it's worth.
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.
@newbunch 's code works for me. It probably shows trades and not midpoints but it doesn't raise an error
Wow! 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 Here is a complete code snippet (copied from @younggotti but added the imports & initialization bits). I'm using S&P 500 micro contract here - I have zero IB data subscriptions: Code: 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) This is huge if it continues to work, and isn't just a mistake!
Perhaps it depends on the build. I am on TWS: Build 10.19.1k, Jan 23, 2023 5:13:03 PM I try not to update the build unless something goes wrong, and since I was testing it purely out of curiosity, I won't be upgrading just to test this.
I also wanted to add that if I use reqMarketDataType(1) it fails for the usual reason... Just to preempt anyone wondering if that CME example works for me because of the free non-professional US futures data package (I don't have it).
The solution of using delayed data type to obtain both streaming and historical data was raised in this thread by @Kernfusion back in June 2022. Link here. Whilst Kernfusion uses a data stream to collect data, I have been using reqMarketDataType(3) together with reqHistoricalData() to obtain historical data for ICE and EUREX markets ever since Kernfusion's post set me on the right path. KH