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

Can't trade commodity (XAUUSD) on IB paper account

  • Some test codes:

    cerebro = bt.Cerebro()
    ibstore = bt.stores.IBStore(
        host = '',
        port = 7497,
        _debug = True,
    ) = ibstore.getbroker()
    data = ibstore.getdata(
        dataname = 'XAUUSD',
        sectype = 'CMDTY',


    • doesn't invoke next()'s of A_Strategy at all, only its __init__().
    • doesn't print out the OHLC information.

    But for example 'EUR.USD-CASH-IDEALPRO' works well, invokes the strategy properly, and prints out OHLC information from IB.

  • administrators

    @yangnw said in Can't trade commodity (XAUUSD) on IB paper account:

    sectype = 'CMDTY',

    CMDTY is not a supported security type. The platform doesn't know what to do with it. The known types are listed in the documentation: Docs - Data Feeds Reference under IBData.

  • Thanks. Is it possible to implement its support? Its request signature is exactly the same as STK, the only difference probably lies in how to parse the received messages, etc. in tickPrice() and tickSize(). It would be greatly appreciated.

  • administrators

    This will be looked into.

  • Quick fix, though in no way tested:

    • in stores/, lines 725, 751 and 836, add 'CMDTY', etc. if contract.m_secType in ['CASH', 'CFD', 'CMDTY']: ..
    • when defining the data feed, use full kwargs, etc.
    data = ibstore.getdata(
        dataname = 'XAUUSD',
        sectype = 'CMDTY',
        exchange = "SMART",
        currency = "USD",

Log in to reply