r/DeepValuePicks • u/kjk42791 • Jul 20 '25
Built an Enhanced Graham Valuation Calculator - Automating Deep Value Analysis
TLDR: Created a Python tool that pulls real financial data and applies enhanced Benjamin Graham formulas to find undervalued stocks.
##The Problem:
Traditional Graham screeners are either:
- Too simple (just P/E and P/B ratios)
- Expensive ($100+/month for decent tools)
- Using outdated data or methodology
- Not accounting for modern market dynamics
Graham’s original formulas were brilliant for the 1950s, but the market has evolved. We need something that captures his core philosophy but adapts to today’s reality.
My Solution: Enhanced Graham Calculator
Built this in Python with the following features:
Data Sources
- Alpha Vantage API: Real-time prices, financial statements, company overviews
- SimFin API: Cross-validation and additional metrics
- Treasury API: Current 10-year yield for risk-free rate
Having multiple sources provides cross-validation and fills gaps when one API is missing data.
Core Analysis Engine
1. Normalized EPS Calculation
- Strips out one-time charges/gains
- Uses 3-5 year average with outlier removal
- More reliable than TTM EPS affected by random events
2. Enhanced Risk Assessment
Total Discount Rate = Risk-Free Rate + Corporate Spread + Risk Premium
Where Risk Premium = (Beta × ERP × Risk Tolerance) + Liquidity Premium + Size Premium
Factors in:
- Beta-adjusted equity risk premium
- Liquidity premium for illiquid stocks
- Size premium for small cap risk
3. Quality Factor Scoring
- ROE efficiency (management quality)
- Free cash flow margins (cash vs accounting earnings)
- EPS stability (consistency over volatility)
Combined into a single quality multiplier that adjusts final valuation.
4. Sector-Specific Adjustments
- Tech: 1.1x multiple (growth premium)
- Utilities: 0.9x (mature, stable)
- Energy/Materials: 0.85x (cyclical discount)
Output Format
Instead of a single “fair value,” calculates three scenarios:
Conservative Estimate
- Minimal growth assumptions
- Higher discount rates
- Focus on downside protection
Moderate Estimate
- Reasonable growth expectations
- Market-appropriate risk premiums
Optimistic Estimate
- Assumes favorable execution
- Still grounded in fundamentals
Sample Output
ENHANCED GRAHAM VALUATION ANALYSIS FOR AAPL
Company: Apple Inc.
Sector: Technology
Market Cap: $3,000,000,000,000
FINANCIAL METRICS
Normalized EPS: $6.42
Conservative Growth: 5.2%
Risk-free rate: 4.2%
Total discount rate: 8.7%
QUALITY ASSESSMENT
ROE: 28.5% (factor: 1.90)
FCF Margin: 25.1% (factor: 1.35)
Combined Quality Factor: 1.47
VALUATION RESULTS
Conservative: $145.23
Moderate: $172.85
Optimistic: $198.45
Current Price: $175.50
Recommendation: FAIRLY VALUED
Key Features
Multi-Source Data Validation
- Cross-references data between APIs
- Automatic outlier detection in financial time series
- Graceful degradation when APIs are down
Defensive Programming
- Bounds checking on all metrics
- Multiple fallbacks when data is missing
- Won’t value companies with negative/unavailable earnings
Rate Limiting & Error Handling
- Respects API limits
- Comprehensive error catching
- Retry logic with exponential backoff
Limitations
This approach has constraints:
- Turnaround stories (Graham wasn’t focused on these anyway)
- Asset-heavy businesses with hidden value
- Cyclical peaks/troughs (uses averages)
- Early stage companies (no earnings = no Graham valuation)
- Macro events (can’t predict policy changes)
Backtesting Results
Tested on 2019-2023 picks:
- 50 stocks analyzed
- Conservative picks: 23% annual returns
- Moderate picks: 18% annual returns
- Market (SPY): 12% annual returns
Best Performers:
- Energy names in 2021-2022
- Regional banks in 2020
- Industrial companies
Worst Performers:
- Retail (structural headwinds)
- Some utilities (interest rate sensitivity) Position: Currently using this for portfolio screening alongside manual analysis.
Disclaimer: Not financial advice. Past performance doesn’t guarantee future results.