Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    useRTH as an option on IB getData feed

    General Code/Help
    2
    5
    1833
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ealvarpe
      ealvarpe last edited by

      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,
              rtbar=False,
              what="TRADES",
              useRTH = True,
              sessionstart=datetime.time(9, 30),
              sessionend=datetime.time(16, 00), 
              tz="EST5EDT")
          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.

      1 Reply Last reply Reply Quote 0
      • ealvarpe
        ealvarpe last edited by

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

        1 Reply Last reply Reply Quote 0
        • B
          backtrader administrators last edited by

          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

          1 Reply Last reply Reply Quote 0
          • ealvarpe
            ealvarpe last edited by

            And how should I use it from backtracker?

            1 Reply Last reply Reply Quote 0
            • B
              backtrader administrators last edited by

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

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors