Amibroker Database Diagnostic Report
A script to verify your Amibroker database health.
When backfilling your Amibroker database with IQFeed (or however you choose to backfill), it's hard to verify exactly what data was backfilled across all symbols.
Even when the backfill "completes" successfully, it's good to have a way to verify that it actually completed with no issues.
That's what this AFL script is for.
How to Run
- Open the Analysis window in Amibroker
- Load the diagnostic script
- Configure these settings:
- Wait for Backfill: unchecked
- Periodicity: 1-minute
- Apply To: All Symbols
- Range: 1 Recent Bar
- Click Explore
Report Mode
The script has a Report Mode parameter with two options:
-
WELL_KNOWN_SYMBOLS (default) - Only reports on a handful of commonly traded symbols: SPY, AAPL, MSFT, VOO, QQQ, and VXX. This is a quick sanity check to verify your database is healthy.
-
COMPREHENSIVE - Reports on every symbol in your database. Use this for a full audit, but expect it to take several minutes on large databases.
Understanding the Results
The results are sorted by Quality Score (worst first) so problem symbols appear at the top. Each symbol gets one row with these fields:
Date Range
- First Bar - Date/time of the first bar in the database for this symbol
- Last Bar - Date/time of the most recent bar
- Days Spanned - Calendar days between first and last bar
Gap Analysis
- Max Gap (Days) - Largest gap between consecutive bars (highlighted orange if >5 days)
- Gap Start / Gap End - When the largest gap occurred
- 2nd Gap (Days) - Second largest gap (useful if the max gap is a known market closure)
- Large Gaps (>5d) - Count of gaps exceeding 5 days (highlighted orange if any, red if >5)
- Recent Gaps - Large gaps in the last 5 trading days (red if any exist)
Bar Counts
- Bar Count - Total number of bars for this symbol
- Bars/Day - Average bars per calendar day
- Bars (1yr) - Bars in the most recent year
- RTH Bars - Regular trading hours bars (9:30 AM - 4:00 PM)
- Ext Bars - Extended hours bars (pre-market and after-hours)
Data Quality
- Est Missing % - Estimated percentage of missing bars compared to expected (green <5%, orange 5-20%, red >20%)
- Quality Score - Overall score from 0-100 (green 80+, orange 50-79, red <50)
- Last Bar Age - Days since the last bar (orange >1 day, red >5 days)
What to Look For
Healthy symbols will have:
- Quality Score of 80+
- Max Gap around 2-3 days (normal weekends)
- Last Bar Age under 1 day (from your most recent backfill)
- Low or zero Recent Gaps
Problem indicators:
- Quality Score below 50 for commonly traded symbols (MSFT, AAPL, SPY, etc)
- Large gaps during trading weeks (check Gap Start/End dates)
- Recent Gaps > 0 suggests ongoing backfill issues
- Last Bar Age > 5 days means the symbol isn't updating
Important Note
There are plenty of symbols that don't trade frequently and will naturally have large gaps and fewer bars than others.
Just because you see symbols with a low bar count relative to other symbols doesn't mean there's a problem with your database. Thinly traded stocks, recently IPO'd companies, and symbols with limited float will all show fewer bars.
Troubleshooting Common Issues
If you find symbols for commonly traded stocks that you're certain you're missing data for, the easiest thing to do is create a new database and backfill the entire thing from scratch.
The way the IQFeed backfill works is it looks at the most recent bar in your database and backfills from that point to the most recent available bar.
So if you find that you're missing data OLDER than a certain date, a new backfill on that symbol won't help.