← Back to Blogs

The Lynchpad: Automating Peter Lynch's Stock Analysis

By CoilPad • January 3, 2026 · 15 min read

What is Peter Lynch's Decision Tree?

Peter Lynch, the legendary Fidelity Magellan fund manager, developed a systematic approach to stock analysis that he called the "2-Minute Drill." His methodology categorizes stocks into six types and applies specific metrics to each category:

  • Fast Growers: High-growth companies (20%+ annual growth). Watch PEG ratio and P/E.
  • Slow Growers: Mature companies with steady dividends. Focus on dividend yield.
  • Stalwarts: Large, stable companies. Look for reasonable P/E ratios.
  • Cyclicals: Companies tied to economic cycles. Watch inventory vs. sales growth.
  • Turnarounds: Distressed companies recovering. Check debt levels.
  • Asset Plays: Companies with undervalued assets. Analyze book value.

Lynch's most important automated check is the "Inventory Warning" - if inventory is growing faster than sales, it's a red flag that demand is slowing.

The Use Case: "The Lynchpad"

This script demonstrates three key capabilities of CoilPad that make it perfect for investment analysis:

  • External Libraries: Import yfinance to fetch live stock data automatically.
  • Logic & Automation: Apply Lynch's complex "inventory vs. sales" logic automatically.
  • Human-in-the-Loop: You define the tickers and the "Story" in a dictionary, and the code handles the math.
CoilPad running the Lynchpad stock analysis script

The Lynchpad in action - analyzing FIG, DUOL, Z, and KO with live data

The Complete Code

Copy this into a new CoilPad note. The script fetches live data from Yahoo Finance and applies Lynch's decision tree automatically:

# ==========================================
#  THE LYNCHPAD: AUTOMATED STOCK CHECKLIST
# ==========================================
# 1. Install dependency if needed: pip install yfinance
import yfinance as yf
import pandas as pd

# --- USER INPUT SECTION ---
# Define your portfolio and the "Story" (Lynch's 2-minute drill)
# This shows how Coilpad mixes manual notes with automated data.
portfolio = {
    "FIG":  {"category": "Fast Grower", "story": "Monopoly on design, AI integration coming."},
    "DUOL": {"category": "Fast Grower", "story": "Strong user retention, expanding to Math/Music."},
    "Z":    {"category": "Turnaround",  "story": "Housing market recovery play."},
    "KO":   {"category": "Slow Grower", "story": "Defensive dividend play."}
}

def analyze_lynch_metrics(ticker_symbol, category):
    """Fetches data and checks specific Lynch warnings based on category."""
    stock = yf.Ticker(ticker_symbol)
    info = stock.info
    
    # 1. Basic Data
    price = info.get('currentPrice', 0)
    pe = info.get('trailingPE', 0)
    peg = info.get('pegRatio', 0)
    div_yield = (info.get('dividendYield', 0) or 0) * 100
    
    # 2. The "Cyclical/Inventory" Check (The most important Lynch automated check)
    # Warning if Inventory is growing faster than Sales
    inventory_warning = "✅ OK"
    try:
        bs = stock.quarterly_balance_sheet
        fin = stock.quarterly_financials
        
        # Growth calculations (Current vs Previous Quarter)
        inv_curr, inv_prev = bs.loc['Inventory'].iloc[0], bs.loc['Inventory'].iloc[1]
        sales_curr, sales_prev = fin.loc['Total Revenue'].iloc[0], fin.loc['Total Revenue'].iloc[1]
        
        inv_growth = (inv_curr - inv_prev) / inv_prev
        sales_growth = (sales_curr - sales_prev) / sales_prev
        
        if inv_growth > sales_growth:
            inventory_warning = f"⚠️ WARNING: Inv up {inv_growth:.1%} > Sales up {sales_growth:.1%}"
    except:
        inventory_warning = "N/A (No Inventory Data)"

    # 3. Category Specific Logic
    verdict = "Hold/Neutral"
    notes = []
    
    if category == "Fast Grower":
        if peg < 1.0: notes.append("✅ PEG is attractive (<1.0)")
        elif peg > 2.0: notes.append("❌ PEG is high (>2.0)")
        if pe > 40: notes.append("⚠️ P/E is very high")
        
    elif category == "Slow Grower":
        if div_yield < 3.0: notes.append("❌ Yield is low for this category")
        else: notes.append("✅ Good Yield")
        
    elif category == "Turnaround":
        debt_equity = info.get('debtToEquity', 0)
        if debt_equity > 100: notes.append("⚠️ High Debt Load")
        else: notes.append("✅ Debt manageable")

    return {
        "Ticker": ticker_symbol,
        "Price": f"${price}",
        "Category": category,
        "P/E": f"{pe:.1f}" if pe else "-",
        "PEG": peg,
        "Inv Warning": inventory_warning,
        "Auto-Notes": "; ".join(notes)
    }

# --- EXECUTION ---
print(f"{'TICKER':<8} {'PRICE':<8} {'CAT':<12} {'WARNINGS & NOTES'}")
print("-" * 80)

for ticker, data in portfolio.items():
    res = analyze_lynch_metrics(ticker, data['category'])
    print(f"{res['Ticker']:<8} {res['Price']:<8} {res['Category'][:10]:<12} {res['Inv Warning']} {res['Auto-Notes']}")

Setting Up Your Environment

Before running the Lynchpad, you need to install the yfinance library. CoilPad makes this easy with its visual package manager:

  1. Open Settings (⌘,) → Python tab
  2. Create a virtual environment if you haven't already
  3. Type "yfinance" in the package installer
  4. Click "Install" and wait for completion
yfinance package installed in CoilPad

yfinance installed and ready to use

Why This Makes CoilPad Shine

1. "Live" Scratchpad

Unlike a static Excel sheet, this script pulls fresh data every time you run it. You can wake up, hit "Run" in CoilPad, and see if Figma's inventory data (or equivalent metrics) has changed.

2. Context + Code = Investment Journal

You aren't just running a script; you are maintaining the portfolio dictionary at the top. This effectively turns the code block into your Investment Journal. You can write comments right next to the ticker logic:

"FIG": {
    "category": "Fast Grower", 
    "story": "Holding until $100. Watch out for Adobe competition."
}  # <-- Your personal notes live in the code

3. Complex Logic Hidden

The analyze_lynch_metrics function hides the ugly API parsing, leaving your "User Interface" (the top section) clean and focused on decision-making.

4. AI-Powered Code Explanations

Don't understand how the inventory check works? Select the code and use CoilPad's built-in AI assistant to get instant explanations:

AI explaining the Lynchpad code

Simple Explanation mode breaks down the code in plain English

Deep Dive AI explanation of the Lynchpad

Deep Dive mode provides comprehensive analysis with step-by-step breakdowns

Customizing for Your Portfolio

The beauty of the Lynchpad is its flexibility. You can easily customize it for your own investment strategy:

Add Your Own Stocks

portfolio = {
    "AAPL": {"category": "Stalwart", "story": "Services revenue growing steadily"},
    "NVDA": {"category": "Fast Grower", "story": "AI chip demand accelerating"},
    "T":    {"category": "Slow Grower", "story": "High dividend for income"},
}

Add Custom Metrics

Want to track free cash flow or profit margins? The yfinance library provides access to hundreds of financial metrics:

# Add to the analyze_lynch_metrics function:
fcf = info.get('freeCashflow', 0)
profit_margin = info.get('profitMargins', 0) * 100

if profit_margin > 20:
    notes.append(f"✅ Strong margins: {profit_margin:.1f}%")

Real-World Use Cases

Daily Portfolio Check

Run the Lynchpad every morning to see if any of your holdings triggered warnings overnight. The inventory check is especially useful for retail stocks during earnings season.

Research New Ideas

Add potential investments to your portfolio dictionary with a "Watching" category. Run the analysis to see if the metrics align with Lynch's criteria before committing capital.

Track Your Thesis

The "story" field in each ticker entry becomes your investment thesis. Update it as your understanding evolves, creating a living document of your investment journey.

Beyond Peter Lynch

While this example focuses on Lynch's methodology, CoilPad's live Python environment is perfect for implementing any investment strategy:

  • Value Investing: Calculate intrinsic value using DCF models
  • Momentum Trading: Track price trends and moving averages
  • Dividend Investing: Analyze payout ratios and dividend growth
  • Technical Analysis: Calculate RSI, MACD, and other indicators

Build Your Own Lynchpad

Stop switching between spreadsheets and web tools.
Automate your investment analysis with live Python code.

Download CoilPad