Finance · Data Science · Automation

Dividend Stock Analyzer

Comprehensive Python-based system for analyzing dividend-paying stocks and generating professional investment reports

Python Pandas NumPy Matplotlib yFinance API python-docx SciPy Jupyter Notebooks

Skills Demonstrated

Financial Data Engineering Multi-Factor Scoring API Integration Decision Tree Logic Report Automation Scenario Modelling
November 2025
Version 1.0.0
7 stocks tested · 100+ metrics
English

Project Overview

The Dividend Stock Analyzer is an end-to-end data science pipeline that automates the evaluation of dividend-paying stocks for long-term investment. It analyzes multiple dimensions—dividend strength, business quality, risk profile, valuation, and long-term return scenarios—to generate professional Word reports with buy/hold/avoid recommendations.

9 Analysis Steps
100+ Metrics Analyzed
20+ Visualizations
7 Page Reports

The Problem

Long-term dividend investors face several challenges:

⏱️

Time-Consuming Analysis

Manually analyzing dividend safety, quality metrics, valuation, and risk factors takes 4-6 hours per stock

📊

Scattered Data Sources

Financial data spread across multiple websites, requiring manual consolidation and calculation

🎯

Inconsistent Evaluation

Subjective analysis without standardized criteria leads to biased investment decisions

The Solution

A fully automated Python pipeline that downloads financial data, performs comprehensive analysis across 7 dimensions, and generates professional investment reports in under 5 minutes per stock.

🤖

Automated Data Collection

Fetches 60+ years of price data, dividend history, and financial statements from Yahoo Finance API

🧮

Multi-Factor Scoring

Evaluates 100+ metrics across dividend safety, quality, risk, and valuation with a 0-100 point system

📄

Professional Reports

Generates 7-page Word documents with color-coded recommendations, visualizations, and investment thesis

Decision Tree Logic

Hybrid system: strict deal-breakers eliminate risky stocks, weighted scoring ranks suitable candidates

🔄

Reusable Framework

Change one ticker variable to analyze any stock—all outputs automatically update

📈

Scenario Analysis

Projects 3-year and 10-year returns under bull/base/bear scenarios with probability assessments

Technical Implementation

Tech Stack

Python 3.8+ Pandas NumPy Matplotlib Seaborn yFinance API python-docx SciPy Jupyter Notebooks

9-Step Analysis Pipeline

1

Data Collection

Automated download of 60+ years of price data, complete dividend history, and 5+ years of financial statements (income, balance sheet, cash flow). Includes data validation and error handling for API failures.

2

Dividend Analysis

Calculates 8 dividend metrics: current yield, 5/10-year CAGR, payout ratio, FCF coverage, payment history, and dividend cuts. Generates safety score (0-100) weighted across 6 components.

3

Quality Assessment

Evaluates business fundamentals across 4 categories: Profitability (ROE, margins), Growth (revenue/earnings CAGR), Financial Health (debt ratios, liquidity), and Competitive Position. Includes sector-specific adjustments for financial companies.

4

Risk Quantification

Measures volatility (annualized standard deviation), beta, maximum drawdown, Value at Risk (VaR 95%), and Sharpe ratio. Classifies risk level as LOW/MEDIUM/HIGH based on scoring thresholds.

5

Classification

Categorizes stocks into 6 types: Dividend Aristocrat, Quality Dividend Stock, Suitable, Trading Stock, Speculative, or Avoid. Uses dividend history, quality score, and volatility metrics to determine long-term suitability.

6

Valuation Analysis

Calculates fair value using 3 methods: P/E ratio (vs 5-year average), Dividend Discount Model (Gordon Growth), and Price-to-Free-Cash-Flow. Computes margin of safety: (Fair Value - Price) / Fair Value × 100.

7

Scenario Analysis

Projects total returns under three scenarios: Bull (25% probability), Base (50% probability), Bear (25% probability). Calculates 3-year and 10-year expected returns with probability of positive outcomes.

8

Final Recommendation

Two-stage decision tree: (1) Deal-breaker checks (yield < 1%, quality < 40, speculative classification, dividend cuts), (2) Weighted scoring (Dividend 30pts + Quality 30pts + Risk 20pts + Valuation 20pts). Generates STRONG BUY/BUY/HOLD/WAIT/AVOID with confidence score.

9

Report Generation

Automatically creates professional 7-page Word document with color-coded recommendations, key metrics dashboard, component breakdowns, scenario projections, and investment thesis. Includes visualization appendix with 7 charts.

Results & Validation

Tested on 7 stocks across Consumer Defensive, Healthcare, Financial Services, and Technology sectors. The system successfully identified 1 BUY opportunity, 3 HOLD positions, and correctly filtered out 3 unsuitable stocks.

🏦 BAC - Bank of America

Financial Services

BUY - Score 74.5

Undervalued with 65% margin of safety

💊 JNJ - Johnson & Johnson

Healthcare

HOLD - Score 67.5

Quality dividend payer, fairly valued

🥤 KO - Coca-Cola

Consumer Defensive

HOLD - Score 58.9

Dividend sustainability concerns

🧴 PG - Procter & Gamble

Consumer Defensive

HOLD - Score 64.8

Stable but not compelling value

📱 AAPL - Apple

Technology

AVOID - Score 53.0

Dividend yield < 1% (deal breaker)

💳 AXP - American Express

Financial Services

AVOID - Score 57.2

Yield too low for dividend portfolio

⛽ CVX - Chevron

Energy

AVOID - Score 62.4

Speculative classification (deal breaker)

Distribution: 0 STRONG BUY, 1 BUY (14%), 3 HOLD (43%), 0 WAIT, 3 AVOID (43%). This realistic distribution demonstrates the system's selectivity—not every blue-chip stock makes the cut for dividend investing.

Challenges & Solutions

Challenge 1: Sector-Specific Metrics

Standard profitability metrics (gross margin, operating margin) don't apply to financial companies like banks and insurance firms.

Solution: Implemented conditional logic to use alternative metrics for financial services: ROE instead of gross margins, cash ratio instead of current ratio, regulatory capital adequacy checks. Result: Bank of America accurately scored and recommended as BUY.

Challenge 2: Data Quality & Validation

Yahoo Finance API occasionally returns incomplete data, missing fields, or incorrect historical values.

Solution: Built comprehensive validation checks in data collection step: verify date ranges, check for null values, flag outliers, validate data consistency. Added error handling with graceful degradation—analysis continues with available data and notes limitations in report.

Challenge 3: Balancing Strictness vs Flexibility

Initial criteria were too strict—all 10 test stocks returned HOLD or AVOID, with no BUY recommendations.

Solution: Iteratively adjusted thresholds based on realistic market conditions: lowered minimum yield from 2% to 1%, changed "Trading Stock" from deal-breaker to warning. This allowed high-quality cyclical stocks (like banks) to pass screening while maintaining conservative standards.

Challenge 4: Report Automation at Scale

Generating professional Word documents with consistent formatting, dynamic content, and embedded visualizations required precise control over document structure.

Solution: Used python-docx library with custom helper functions for standardized table creation, cell formatting, and color-coding. Created modular page generation functions that handle edge cases (missing data, very long text). Result: Consistent 7-page reports with professional appearance across all stocks.

Key Takeaways

Future Enhancements (v1.1.0+)

🏭

Sector-Specific Criteria

Add tailored thresholds for Energy, Utilities, REITs, and Telecommunications to improve classification accuracy

📊

Batch Analysis Dashboard

Web interface to analyze 10-20 stocks simultaneously with comparison matrix and sector benchmarking

🌍

International Support

Extend to international exchanges with currency conversion, different accounting standards, and country risk factors

View Full Project Code

All code, data, and documentation available on GitHub

Sample Reports View Repository
Note: This is a portfolio project using publicly available financial data via the Yahoo Finance API. All scores, valuations, and recommendations are generated programmatically for demonstration purposes and do not constitute financial advice.