Fully automated futures trading

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

  1. lore

    lore

    I painstakingly went through the list. The EUREX futures are the hardest since there are so many of them. I couldn't find any of the bond futures on the list. Does that mean U.S. traders cannot trade the bund, schatz, bono, buxl, etc?
    Is there some way to test what instruments are permitted in IB without actually placing a trade? I guess I can try trading in the paper trading account and see if I get a regulatory restriction error?
     
    Last edited: Jan 22, 2023
    #3631     Jan 22, 2023
  2. newbunch

    newbunch

    I trade European interest rates and bonds, so they are tradable at IB by US investors.

    It looks like foreign government debt futures are regulated by the SEC rather than the CFTC: "Foreign government debt obligations: Debt obligations of a foreign government must be designated as an exempted security by the U.S. Securities and Exchange Commission under SEC Rule 3a12-8 before a futures contract or option thereon can be offered or sold in the United States. Government debt instruments issued by the following countries have been designated by the SEC as exempted securities: United Kingdom, Canada, Japan, Australia, France, New Zealand, Austria, Denmark, Finland, the Netherlands, Switzerland, Germany, Italy, Ireland, Spain, Mexico, Brazil, Argentina, Venezuela, Belgium, and Sweden." https://www.cftc.gov/International/ForeignMarketsandProducts/foreignproducts.html

    To test whether a product is tradable or under regulatory restriction, in TWS I just pull up a quote and then preview an order or check margin impact and a red box within the window appears if I can't trade it (regulator restriction, insufficient margin, etc.). Not sure how to do this programmatically, but I'm sure there's a way.
     
    #3632     Jan 22, 2023
    lore likes this.
  3. lore

    lore

    Thanks again! That was very helpful. It worked as you said. Interestingly, it doesn't restrict you in a paper trading account. You can purchase anything there, or so it appears.
     
    #3633     Jan 22, 2023
    newbunch likes this.
  4. 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?
     
    #3634     Feb 23, 2023
    tgibson11 and Kernfusion like this.
  5. Maybe they turned something on? I'll have a look when I get a chance.

    Rob
     
    #3635     Feb 23, 2023
  6. newbunch

    newbunch

    That's strange. Only yesterday I was working on this.

    Just reran the script and for contracts without data I get, for example: "Error 162, reqId 29312: Historical Market Data Service error message:No market data permissions for CDE FUT, contract: Future(symbol='TSE60', lastTradeDateOrContractMonth='202303', multiplier='200.0', exchange='CDE')"

    My code, using ib_insync:
    ib.reqHistoricalData(FuturesContract, endDateTime='', durationStr='10 D', barSizeSetting='5 mins', whatToShow='MIDPOINT', useRTH=False, formatDate=1)

    I'd love to hear how you got it to work so I can do the same.
     
    #3636     Feb 23, 2023
  7. That's the code I'm using:

    ib.reqMarketDataType(3)
    contract = Contract()
    contract = Future("K200M", "202303", "KSE")
    ib.qualifyContracts(contract)

    bars = ib.reqHistoricalData(contract, endDateTime='', durationStr='1 D', barSizeSetting='5 secs',whatToShow='TRADES', useRTH=True, formatDate=1)
     
    #3637     Feb 23, 2023
    Elder and newbunch like this.
  8. Your code seems to work for me, even if I don't have a data subscription:
    [BarData(date=datetime.datetime(2023, 2, 9, 2, 0), open=1248.6, high=1249.25, low=1247.65, close=1248.05, volume=-1.0, average=-1.0, barCount=-1),
    BarData(date=datetime.datetime(2023, 2, 9, 2, 5), open=1248.05, high=1248.25, low=1247.2, close=1247.2, volume=-1.0, average=-1.0, barCount=-1),
    BarData(date=datetime.datetime(2023, 2, 9, 2, 10), open=1247.2, high=1247.5, low=1247.2, close=1247.3, volume=-1.0, average=-1.0, barCount=-1),
    BarData(date=datetime.datetime(2023, 2, 9, 2, 15), open=1247.3, high=1247.8, low=1247.25, close=1247.8, volume=-1.0, average=-1.0, barCount=-1),
    BarData(date=datetime.datetime(2023, 2, 9, 2, 20), open=1247.8, high=1248.25, low=1247.8, close=1248.05, volume=-1.0, average=-1.0, barCount=-1),
    BarData(date=datetime.datetime(2023, 2, 9, 2, 25), open=1248.05, high=1248.05, low=1247.8, close=1247.9, volume=-1.0, average=-1.0, barCount=-1),
    BarData(date=datetime.datetime(2023, 2, 9, 2, 30), open=1247.9, high=1248.3, low=1247.85, close=1248.15, volume=-1.0, average=-1.0, barCount=-1),
    BarData(date=datetime.datetime(2023, 2, 9, 2, 35), open=1248.15, high=1248.25, low=1247.9, close=1247.95, volume=-1.0, average=-1.0, barCount=-1),
    ...
     
    #3638     Feb 23, 2023
    newbunch likes this.
  9. newbunch

    newbunch

    Now that is strange. Are you using Gateway or TWS? I am using TWS.
     
    #3639     Feb 23, 2023
  10. I use TWS as well.
    A few months ago I opened a ticket with IB because I couldn't get prices for European ETFs (for which I pay). Maybe to fix that issue they created a new one...

    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.
     
    #3640     Feb 23, 2023