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

IB Live Trading Backfilling larger period ?



  • Based on the documentation, during live trading, the program initially can backfill data for the maximum possible duration defined in IB historical limitation(eg. for 1min bar the max duration is 1day). What if the min period in indicators requires more than that(say in my case 2 days lookback on the 1min bar).

    1. Instead of waiting for the system run for one more day of getting enough data from LIVE, is there any way the let the system backfill a larger period(eg. 2day duration hist data on 1 min bar, this meant having to send two times of historical data requests to IB)?
    2. If there is no direct solution to question 1, I guess using "backfill_from" is one possible solution( eg.
      ibstore.getdata(......backfill_from = data0........), where data0 is some locally stored data feeds). However, what if the latest bar in data0 is still 2days or even further away from current, can the program backfill such gap?

  • administrators

    backfill_from is there to address the limitation in backfilling. If you don't have enough data to close the gap to be small enough the code won't go backwards backfilling.



  • @backtrader Thank you for much for clarifying that. I have one more question, for the build in backfill_start, particularly on 1 min bar.
    When I start running the program at Jan 29 10:00 am US/Eastern the backfill period went from Jan29 might night to Jan29 9:59 am. However, any data before regular market hours (9:30) am is relatively meaningless(for most strategies). So ideally the backfilling period I am looking for at 10:00 am Jan 29, is 10:00 am ~ 3:59 pm Jan 28 and 9:30 am to 9:59 am Jan 29.
    In such a case, I would consider using my own historical data (say every 1 min bar in trading hours till 3:59 pm Jan 28), but when backfilling the gap, is there any way to limit backfilling only on regular market hours? (in this case only backfill 9:30-9:59 Jan 29)


  • administrators

    You can try setting useRTH to True which tells InteractiveBrokers to use only Regular Trading Hours (Docs - Data Feed Reference), but if your problem is the calculation of the backfilling periods, you are in desperate need of custom code.



  • @backtrader I really appreciate the answer, I think "useRTH" would work, sorry I missed that variable in the documentation. One last thing about this backfilling I wish to point out or get confirmed is that I feel the default time zone on backfill_from has been set to UTC-1. My settings: TWS is @ us-Pacific, ContractDetails @ us-Eastern, getdata(tz=us-Pacific), the local historical data stored for backfill_from is timestamped@us-Pacific, however, the histData does not line up with the LIVE feeds until I manually it by adding +7 hours on the timestamps.
    Thanks again for all the help, I have been using your package for 2 months, really a great platform, saved a lot of time for me while building out my strategy.


Log in to reply
 

});