Fully automated futures trading

Discussion in 'Journals' started by globalarbtrader, Feb 11, 2015.

  1. newbunch

    newbunch

    Changing reqMarketDataType to 3 or 4 did not solve the problem for me.
     
    #3641     Feb 23, 2023
  2. Kernfusion

    Kernfusion

    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..
     
    #3642     Feb 24, 2023
  3. VMatthijs

    VMatthijs

    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.
     
    #3643     Feb 24, 2023
  4. 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.
     
    #3644     Feb 24, 2023
  5. @newbunch 's code works for me. It probably shows trades and not midpoints but it doesn't raise an error
     
    #3645     Feb 24, 2023
  6. tgibson11

    tgibson11

    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!
     
    #3646     Feb 24, 2023
  7. newbunch

    newbunch

    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.
     
    #3647     Feb 24, 2023
  8. I'm using 10.19.1k too, so the different behaviour doesn't depend on different builds
     
    #3648     Feb 24, 2023
  9. tgibson11

    tgibson11

    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).
     
    #3649     Feb 24, 2023
  10. KevinBB

    KevinBB

    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
     
    #3650     Feb 24, 2023
    Kernfusion likes this.