For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Generating proper dataname for Crude Oil Futures with the certain expiration date



  • Hi.

    I am new in backtrader. I am trading with Interactive Brokers and I am stuck with generating proper dataname for Crude Oil Futures with the certain expiration date.

    The lines below works fine for different forex data:
    ibstore = bt.stores.IBStore(host='127.0.0.1', port=7496, clientId=35)
    data = ibstore.getdata(dataname='EUR.USD-CASH-IDEALPRO')

    But when I try to generate dataname for futures, according any of the templates below. Does anybody was able to generate dataname for Crude oil futures that works? What is my mistake?

    TICKER-YYYYMM-EXCHANGE # Future
    TICKER-YYYYMM-EXCHANGE-CURRENCY # Future
    TICKER-YYYYMM-EXCHANGE-CURRENCY-MULT # Future
    TICKER-FUT-EXCHANGE-CURRENCY-YYYYMM-MULT # Future

    #This line does not work.
    data = ibstore.getdata(dataname='CL-FUT-NYMEX-USD-202001')

    I got the same error, even if I try ibtest instead of my code.

    C:\Work\Advisors\BackTrader\backtrader-master\samples\ibtest>python ibtest.py --port 4002 --data0 CL-201912-NYMEX --timeframe Days Server Version: 76 TWS Time at connection:20191202 19:41:06 PST -------------------------------------------------- Strategy Created -------------------------------------------------- Datetime, Open, High, Low, Close, Volume, OpenInterest, SMA ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:cashfarm> ***** STORE NOTIF: <error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:cashhmds> ***** STORE NOTIF: <error id=16777216, errorCode=200, errorMsg=No security definition has been found for the request>
    ***** STORE NOTIF: Ambiguous contract: none/multiple answers received ***** DATA NOTIF: DISCONNECTED

    Thank you.


  • administrators

    See this: https://interactivebrokers.github.io/tws-api/basic_contracts.html#fut

    For example the section which says:

    Occasionally, you can expect to have more than a single future contract for the same underlying with the same expiry. To rule out the ambiguity, the contract's multiplier can be given as shown below:
    

    I can only suggest that your are VERY specific on the definition and use the more verbose form (and the debugging option in either the store or ibtest)

    • TICKER-FUT-EXCHANGE-CURRENCY-YYYYMM-MULT

Log in to reply
 

});