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

Trade with IB paper account that not subscribed to Live Data



  • Hi backtraders,

    I manage to backtest my strategy using IB Live account (port-7497).
    But when trying to run my strategy on the paper account I'm getting below message:
    *****STORE NOTIF:<error id=16777217, errorCode=10168, errorMsg=Requested market data is not subscribed. Delayed market data is not enabled>

    I'm using the test code that in
    https://github.com/mementum/backtrader/blob/master/samples/ibtest/ibtest.py

    End getting below error:
    <error id=16777217, errorCode=10168, errorMsg=Requested market data is not subscribed. Delayed market data is not enabled

    Any idea how can I run it even if if i'm not subscribed - to run it on delayed data..

    Thanks,
    Arik



  • @arikenig
    I'm using below arguments:
    ibtest.py --port 7497 --data0 AAPL-STK-SMART-USD --resample --timeframe Seconds --broker --trade

    and below is the full output:
    
    --------------------------------------------------
    Strategy Created
    --------------------------------------------------
    Timezone from ContractDetails: EST (Eastern Standard Time)
    Datetime, Open, High, Low, Close, Volume, OpenInterest, SMA
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfuture.nj>
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:hfarm>
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfarm.nj>
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:eufarm>
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:jfarm>
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfuture>
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:cashfarm>
    ***** STORE NOTIF: <error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfarm>
    ***** STORE NOTIF: <error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:euhmds>
    ***** STORE NOTIF: <error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:ushmds.nj>
    ***** STORE NOTIF: <error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:fundfarm>
    ***** STORE NOTIF: <error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:ushmds>
    ***** STORE NOTIF: <error id=-1, errorCode=2158, errorMsg=Sec-def data farm connection is OK:secdefnj>
    ***** DATA NOTIF: DELAYED
    ***** STORE NOTIF: <error id=16777217, errorCode=10168, errorMsg=Requested market data is not subscribed. Delayed market data is not enabled>
    


  • I faced the same issue, and I may be wrong but to work on delayed data one would need to modify the code and add a call to function IBApi::EClient::reqMarketDataType with a parameter : 3 before subscribing to market data
    See IB API doc : https://interactivebrokers.github.io/tws-api/delayed_data.html

    I think it may be possible to modify the code with just a few lines to add but I haven't fully investigated it.

    Instead, I moved my paper account TWS on the same computer that run the real account TWS (data can then be shared, see : https://ibkr.info/node/1719)



  • Thanks EMR for your comment,

    I searched where backtrader use reqMarketDataType & added a breakpoint there
    I checked the flow of the test strategy and I don't see that it call ...Python38\site-packages\ib\ext\EClientSocket.py - method: reqMarketDataType
    I've also opened both Live & paper in my machine but still getting the same error - errorCode=10168, errorMsg=Requested market data is not subscribed
    which after that it not continue.
    I'm expecting to get into next method but it stucked in load data:
    below the stack that it never get out of it:

    _load, ibdata.py:446
    load, feed.py:479
    next, feed.py:407
    _runnext, cerebro.py:1542
    runstrategies, cerebro.py:1298
    run, cerebro.py:1127
    runstrategy, ibtest.py:336
    <module>, ibtest.py:558
    

    It never exit line 1506 in cerebro.py file:

    code_text
    ```        while d0ret or d0ret is None:


  • @arikenig The problem for using delayed data is that reqMarketDataType is NOT called, and that it should be called before subscribing to a delayed data feed.
    If you have a live account, it is much much simpler to run your paper TWS (or gateway) on the same machine. Just take care to point to the paper TWS ! (port)
    It is strange that you still have an error when both your live and paper account run on the same computer.
    Do you also have on your live account delayed data for the instrument you try to trade on your paper account ?
    Have you parametrized data feed sharing from your live toward your paper account ? This is something you have to setup. From the previous given IBKR.info link :
    "2. Market data mirroring and sharing user selection
    On the Client Portal, those functions are present in the section: Settings -> Account Settings -> Configure (gear) icon"

    If you still have delayed data in your paper account, you will notice it in the API logs (you have to search the item in the TWS menu to display them, they are something like encrypted on disk)


Log in to reply
 

});