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

useRTH as an option on IB getData feed

  • Has someone used the useRTH option when trying to get a data feed live from IB?

    Even when I cannot find this option on the Backtrader Docs it´s for sure an option that the IB API support (the idea is to request a feed only pushing prices on Regular Trading Hours, so we can play on getting or not prices during outside hours).

    I´ve tried setting this value to True and False and the result is the same: I always get the prices outside the Regular Trading Hours.

    The way I´m using it is:

    datakwargs = dict(
            timeframe=bt.TimeFrame.Ticks, compression=1,
            useRTH = True,
            sessionstart=datetime.time(9, 30),
            sessionend=datetime.time(16, 00), 
        data0 = ibstore.getdata(dataname="SPY-STK-SMART-USD", **datakwargs)

    How can I do to avoid prices on outside hours? The curious thing is that when connecting, the backfilling is done only on historical data from regular trading hours. The problem is only happening on live data.

  • Looking into the source code the option seems to be only for Historical Data request. Is this an option on the live feed?

  • administrators

    It's not a direct option in the IB API. Theoretically you can add this call to switch to frozen data after a close: IB API - reqmarketdatatype

  • And how should I use it from backtracker?

  • administrators

    It's not implemented. You might be adding the call to a fork of yours, until it may be looked into.

Log in to reply