Home Documentation Changelog Paper Trading Download Scanner
Strategy Overview

Dividend Capture Scanner v8

Developed by Andrew D.

A systematic approach to collecting dividend income by timing stock purchases around ex-dividend dates.

🔍
Step 1
Find a Good Stock
  • A company announces it will pay a dividend
  • The tool automatically identifies good capture candidates based on four key qualities:
  • High yield: the higher the dividend yield, the more the trade is worth the risk. Candidates are ranked by yield percentage
  • Fast rebound: how quickly the stock historically climbs back to its pre-ex-date price. The faster it recovers, the sooner your capital is free
  • Healthy trend: stocks drifting downward are flagged, since the price may not recover after the dividend
  • Plenty of liquidity: lots of daily trading volume makes it easy to get in and out. Thinly-traded names are flagged
  • Solid quality: a stock you would be comfortable holding for a while in case the price takes time to bounce back
Rebound time is the most important factor. The stock that climbs back to the price you paid the fastest is ranked the highest.
🛒
Step 2
Buy Before the Ex-Dividend Date
  • You buy the stock before the cutoff date to qualify for the dividend
📅
Step 3
Ex-Dividend Date Passes
  • You officially receive the dividend
  • The stock price typically drops around this time
💰
Step 4
Sell the Stock
  • You sell once the price recovers
If the dividend received is more than the price drop, you profit
📊
Step 5
Track the Result
  • Record the trade: what was bought, when, how much capital deployed, and the outcome
Download dividend_scanner_v8.py
Latest version. New in v8: the visual calendar is saved with the date in its filename (rotation_calendar_YYYYMMDD.html), matching the daily CSV and Excel files, so each day's plan is kept as a record.
1
One-time setup
Install the required Python packages. Only needed once.
pip install yfinance pandas requests lxml openpyxl
2
Navigate to the project folder
Open PowerShell or Command Prompt and go to the folder where you saved the scanner. The path below is just an example. Replace it with your actual folder location.
cd "C:\Users\YourName\Documents\stock scanner"
3
Run the scanner
Scans roughly 576 stocks (the S&P 500 plus high-yield names, CEFs, and preferreds). Takes about 1 to 2 minutes to complete.
python dividend_scanner_v8.py
4
Review the output
The ranked shortlist prints in the terminal and is saved in the same folder in two formats: a dated CSV and a formatted Excel file with a bold locked header and sized columns, ready to read.
candidates_YYYYMMDD.csv candidates_YYYYMMDD.xlsx rotation_calendar_YYYYMMDD.html
5
Optional: run it automatically every morning
Windows can start the scanner for you each day, so there is nothing to remember. Download the helper script below, save it in the same folder as the scanner, and register the daily task once (this example uses 8:00 AM). Each day's output is saved to a dated log file in a logs folder, alongside the usual CSV. The computer needs to be on at the scheduled time.
Download run_daily.ps1
schtasks /create /tn "DividendScannerDaily" /tr "powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"C:\Users\YourName\Documents\stock scanner\run_daily.ps1\"" /sc daily /st 08:00
To check that the task is set up and see when it will run next:
schtasks /query /tn "DividendScannerDaily"
The kill switch: pause or resume the morning run any time with one command.
schtasks /change /tn "DividendScannerDaily" /disable
schtasks /change /tn "DividendScannerDaily" /enable
Tip: All filter thresholds (minimum yield, price range, volume, ex-date window) are set at the top of dividend_scanner_v8.py and can be adjusted at any time.
1
Load the Stock List
Getting started
The scanner starts with the S&P 500, the 500 largest US companies (think Apple, Coca-Cola, Johnson and Johnson). On its own, the S&P 500 rarely has stocks paying 8% or more, so the scanner also adds high-yield income names: REITs, BDCs, closed-end funds, and preferreds. This is where the highest yields usually live. The list stays current automatically.
S&P 500 plus high-yield names REITs, BDCs, CEFs, preferreds Always current
2
Look Up Each Stock
Pulling live data
For every stock, the tool checks Yahoo Finance for the upcoming ex-dividend date, the dividend amount, the current price, how many shares trade daily, and how volatile the stock is.
Yahoo Finance Ex-dividend date Price and volume
3
Check if the Stock is a Good Candidate
Applying the filters
Each stock must pass four checks. If it fails any one of them, it is skipped.
Ex-dividend date
Within the next 30 days
Dividend yield
At least 3% per year
Daily trading volume
100,000+ shares per day (thin ones flagged)
Stock price
Between $5 and $500
Does the stock pass all four checks?
It must pass all four to move forward
No - Skip
Move on to the next stock
Yes - Keep it
4
Measure the Rebound Time
The key metric
When a stock pays a dividend, its price usually drops by about that amount the same day. The real question is: how long does it take to climb back to the price you paid? The scanner looks at the last two years of history and, for each past ex-dividend date, measures how many trading days the stock took to recover. It reports both the average and the worst case. If a past dividend never recovered within 60 trading days, the worst case shows ">60" so that risk is never hidden. A faster rebound means your money is freed up sooner. The same history is also used to find each stock's best entry point: the scanner tests buying 1 to 20 trading days before the ex-date and reports the number of days that has worked best. And it measures the drop ratio, which is how much of the dividend the price actually gives up on the ex-date. Below 1.0 means it drops less than the dividend, which is where the capture profit comes from.
Average rebound days Worst-case rebound How often it recovers Best day to buy in Real ex-date drop Based on 2 years of history
5
Score and Rank Each Stock
Putting it all together
Each stock gets a score that rewards the best use of your money over time. The idea is continuous rotation: hold a stock through the dividend, sell once it is back to even or better, then move the same money straight into the next upcoming dividend. So a high yield that also rebounds quickly scores best, because that capital can be put to work again sooner. Past dividends that never recovered are charged at the full 60-day wait, so unreliable stocks honestly score lower. The trend check uses total-return prices, so big payers are not unfairly marked as falling, and a downward trend or thin trading lowers the score.
Higher yield = higher rank Faster rebound = higher rank Downtrend lowers the score After-tax figures included
6
Show the Morning Shortlist
Ready to review
The top candidates are displayed in a ranked table and saved to a file so you can review and compare them each day. Each row shows the yield, the average and worst-case rebound, the best entry timing, the real ex-date drop, the trend, the after-tax dividend per 100-share lot (shown at two tax rates, 35% and 25%), and the overall score. The scanner also builds a Rotation Plan: a trade calendar that rolls one pot of capital (default $50,000, adjustable) from one dividend into the next. It buys on each stock's best entry day, sells at its average rebound, and shows the estimated net dollars per trade after tax (at both rates) and any financing fee, with running totals. The plan prints below the shortlist, is saved as a second sheet in the Excel file, and is also saved as a dated rotation_calendar_YYYYMMDD.html, a colour-coded month-grid calendar that opens in any browser.
#TickerPriceAnnual YieldAvg RebWorst RebRecoveredBest EntryDrop RatioTrendAfterTax35/100AfterTax25/100Score
1KRG$28.844.02%4.918100%1d1.49Up$18.85$21.7522.1
2HBAN$16.843.68%3.417100%3d0.94Mixed$10.08$11.6322.0
3DOC$20.475.96%1.510100%10d0.86Up$6.61$7.6321.5
4O$62.115.23%1.18100%15d0.69Up$17.60$20.3121.1
Printed in terminal Saved as a file Rotation Plan sheet Run each morning
7
Place Trades via IBKR
Coming soon - Stage 2
Once account access is set up, the scanner will connect directly to Interactive Brokers to check live prices and place trades without leaving the tool. The first step is paper trading: the whole strategy runs on simulated money until the real results match the predictions. The full plan is on the Paper Trading page.
Interactive Brokers Live prices Place orders Trade history
Why Yahoo Finance and not Dividend.com?
Dividend.com does not offer a public API. Their data can only be accessed by visiting their website, and automatically pulling data from it (called scraping) is unreliable and against most sites' terms of service. Yahoo Finance provides the same dividend calendar data through a clean, free connection, making it the better starting point.
Why is Interactive Brokers not connected yet?
Interactive Brokers does have an API, but we are waiting for access to be enabled on the account. Once that is done, the strategy runs on simulated money first; see the Paper Trading page for the step-by-step plan.
A note on taxes
Because these trades are held only days, the profit is a short-term gain taxed at your ordinary income rate, not the lower long-term capital-gains rate. The exact rate depends on deductions and the year's tax rules, so the scanner shows every after-tax figure at two rates side by side: 35% as the conservative estimate and 25% as the optimistic one. Both can be changed at the top of the script.
Loading stocks
Looking up data
Filtering
Decision
Ranking and output
Coming soon