Backfilling Historical Data with IQFeed
How to backfill historical data into a backtesting database in AmiBroker using IQFeed
Although you can use Polygon data to import into Amibroker, IQFeed is a better choice, simply because it's so much faster.
There's a IQFeed plugin for Amibroker, so simply create a database and point to IQFeed, and away you go.
For my backtesting database, I have a specific way I like to perform backfills.
It's tempting to check the Wait for Backfill checkbox for every backtest you run, but I do something different.
Instead of backfilling as part of every backtest I run, I leave that box UNchecked.
I have a specific AFL file I use for backfilling everything in the database. I run this only periodically, when needed.
Remember, this is the backtesting database - you don't necessarily need the most up to date data every time you run a backtest.
Here's a summary of what I do:
- All my analysis windows for backtests and explorations have the Wait for Backfill checkbox disabled
- I manually disconnect the datafeed for most operations
- When I want to backfill the database, I wait until after hours, Reconnect the datafeed, and backfill all symbols using my
backfill_only.aflscript (see below) - Once it's complete, I manually disconnect the datafeed again
Here's the backfill_only.afl script I use - basically it does nothing:
Buy = 0;
Sell = 0;
Short = 0;
Cover = 0;
Filter = 0;
I save this to a backfill_only.apx file with the following settings saved:
- Wait for Backfill checked
- Apply To All Symbols
- Range: 1 Recent Bar(s)
To populate 10 years of 1 minute bar data for all US stocks in a new Amibroker database takes around 2 hours.
To do an incremental backfill of an existing database takes significantly less time.
Here's a video explaining my setup and this procedure: