IB backfills, was: Saving foreign quotations data


I want AmiBroker to save quotations data that were received from TWS by the SetForeign function, but it truncates it. Below is a step-by-step reproduction of the issue:

  1. Add 2 new tickers: A and AA
  2. Select ticker A to see its chart
  3. IB plug-in starts backfilling the ticker A data (180 days)
  4. When the backfill is complete, run the SetForeign("AA") function in the ticker A chart window
  5. IB plug-in starts backfilling the ticker AA data (180 days)
  6. When the 2nd backfill is completed, close AmiBroker
  7. Close TWS
  8. Open AmiBroker and select ticker A - you will see 180 days of the ticker A quotations data saved locally
  9. Select ticker AA - you will see only the last 20 days of the ticker AA quotations data. Where're the others?

If I run the Database Purify Tool, immediately before closing AmiBroker in step 6, both tickers will have 180 days of data in step 9. I assume that Database Purify Tool runs some function that tells AmiBroker to save all quotations data. I'm looking for this function to automatically call it from the AFL code or OLE Automation inside of the AFL code.

Who can help?


Interactive Brokers backfills are limited in length. To get more data you have to request data in chunks and do it once at a time because IB does not allow to run too many backfills at once. To backfill all symbols you have to use feature especially designed for IB to slow down backfill request to IB limits. It is all described in the guide
http://www.amibroker.com/guide/h_ib.html (scroll down to " BACKFILLING ALL SYMBOLS AT ONCE")

Dear Tomasz,

Thank you for your reply!

Kindly read the question in the first message again. The question is not only about IB backfills. It is about how to transfer (in other words, save) all quotations data from the AmiBroker cache (RAM) to the local database (HDD) without running the Database Purify Tool. Because after the SetForeign() function, AmiBroker saves data incompletely - instead of 180 days it saves only 20 days of quotations data.

Do the step-by-step reproduction in the first message to better understand the issue.

The real-time window cannot be used for backfills of foreign quotations data instead of the SetForeign() function, because there is no AFL function to add and remove tickers to it from the AFL code.


Data are automatically transfered when they are used (accessed). So any access including chart or analysis would do that. For example just run any Analysis (Scan/Exploration/Backtest - whatever) over all symbols.

1 Like