Canslim screener

From nicepkg/ai-workflow · View interactive version

Canslim screener is an AI agent skill from the GitHub repository nicepkg/ai-workflow. Screen US stocks using William O'Neil's CANSLIM growth stock methodology. Use when user requests CANSLIM stock screening, growth stock analysis, momentum stock identification, or wants to find stocks with strong earnings and price momentum following O'Neil's investment system.

How to use this skill

Skill file

CANSLIM Stock Screener - Phase 2

Overview

This skill screens US stocks using William O'Neil's proven CANSLIM methodology, a systematic approach for identifying growth stocks with strong fundamentals and price momentum. CANSLIM analyzes 7 key components: Current Earnings, Annual Growth, Newness/New Highs, Supply/Demand, Leadership/RS Rank, Institutional Sponsorship, and Market Direction.

Phase 2 implements 6 of 7 components (C, A, N, S, I, M), representing 80% of the full methodology. This phase adds critical volume analysis (S) and institutional ownership tracking (I) to the Phase 1 foundation.

Two-Stage Approach:

  1. Stage 1 (FMP API + Finviz): Analyze stock universe with 6 CANSLIM components
  2. Stage 2 (Reporting): Rank by composite score and generate actionable reports

Key Features:

Phase 2 Component Weights (Renormalized for 6 components):

Future Phases:


When to Use This Skill

Explicit Triggers:

Implicit Triggers:

When NOT to Use:


Workflow

Step 1: Verify API Access and Requirements

Check if user has FMP API key configured:

# Check environment variable
echo $FMP_API_KEY

# If not set, prompt user to provide it

Requirements:

Installation:

pip install requests beautifulsoup4 lxml

If API key is missing, guide user to:

  1. Sign up at https://site.financialmodelingprep.com/developer/docs
  2. Get free API key (250 calls/day)
  3. Set environment variable: export FMP_API_KEY=your_key_here

Step 2: Determine Stock Universe

Option A: Default Universe (Recommended)

Use top 40 S&P 500 stocks by market cap (predefined in script):

python3 skills/canslim-screener/scripts/screen_canslim.py

Option B: Custom Universe

User provides specific symbols or sector:

python3 skills/canslim-screener/scripts/screen_canslim.py \
  --universe AAPL MSFT GOOGL AMZN NVDA META TSLA

Option C: Sector-Specific

User can provide sector-focused list (Technology, Healthcare, etc.)

API Budget Considerations (Phase 2):

Step 3: Execute CANSLIM Screening Script

Run the main screening script with appropriate parameters:

cd /Users/takueisaotome/PycharmProjects/claude-trading-skills/skills/canslim-screener/scripts

# Basic run (40 stocks, top 20 in report)
python3 screen_canslim.py --api-key $FMP_API_KEY

# Custom parameters
python3 screen_canslim.py \
  --api-key $FMP_API_KEY \
  --max-candidates 40 \
  --top 20 \
  --output-dir ../../../

Script Workflow (Phase 2):

  1. Market Direction (M): Analyze S&P 500 trend vs 50-day EMA
  1. Stock Analysis: For each stock, calculate:
  1. Composite Scoring: Weighted average with component breakdown
  2. Ranking: Sort by composite score (highest first)
  3. Reporting: Generate JSON + Markdown outputs

Expected Execution Time (Phase 2):

Finviz Fallback Behavior:

Step 4: Read and Parse Screening Results

The script generates two output files:

Read the Markdown report to identify top candidates:

# Find the latest report
ls -lt canslim_screener_*.md | head -1

# Read the report
cat canslim_screener_YYYY-MM-DD_HHMMSS.md

Report Structure (Phase 2):

New Component Details in Report:

Step 5: Analyze Top Candidates and Provide Recommendations

Review the top-ranked stocks and cross-reference with knowledge bases:

Reference Documents to Consult:

  1. references/interpretation_guide.md - Understand rating bands and portfolio sizing
  2. references/canslim_methodology.md - Deep dive into component meanings (now includes S and I)
  3. references/scoring_system.md - Understand scoring formulas (Phase 2 weights)

Analysis Framework:

For Exceptional+ stocks (90-100 points):

For Exceptional stocks (80-89 points):

For Strong stocks (70-79 points):

For Above Average stocks (60-69 points):

Bear Market Override:

Step 6: Generate User-Facing Report

Create a concise, actionable summary for the user:

Report Format:

# CANSLIM Stock Screening Results (Phase 2)
**Date:** YYYY-MM-DD
**Market Condition:** [Trend] - M Score: [X]/100
**Stocks Analyzed:** [N]
**Components:** C, A, N, S, I, M (6 of 7)

## Market Summary
[2-3 sentences on current market environment based on M component]
[If bear market: WARNING - Consider raising cash allocation]

## Top 5 CANSLIM Candidates

### 1. [SYMBOL] - [Company Name] ⭐⭐⭐
**Score:** [X.X]/100 ([Rating])
**Price:** $[XXX.XX] | **Sector:** [Sector]

**Component Breakdown:**
- C (Earnings): [X]/100 - [EPS growth]% QoQ, [Revenue growth]% revenue
- A (Growth): [X]/100 - [CAGR]% 3yr EPS CAGR
- N (Newness): [X]/100 - [Distance]% from 52wk high
- S (Supply/Demand): [X]/100 - Up/Down Volume Ratio: [X.XX]
- I (Institutional): [X]/100 - [N] holders, [X.X]% ownership [⭐ Superinvestor if present]
- M (Market): [X]/100 - [Trend]

**Interpretation:** [Rating description and guidance]
**Weakest Component:** [X] ([score])
**Data Source Note:** [If Finviz used: "Institutional data from Finviz"]

[Repeat for top 5 stocks]

## Investment Recommendations

**Immediate Buy List (90+ score):**
- [List stocks with exceptional+ ratings]
- Position sizing: 15-20% each

**Strong Buy List (80-89 score):**
- [List stocks with exceptional ratings]
- Position sizing: 10-15% each

**Watchlist (70-79 score):**
- [List stocks with strong ratings]
- Buy on pullback

## Risk Factors
- [Identify any quality warnings from components]
- [Market condition warnings]
- [Sector concentration risks if applicable]
- [Data source reliability notes if Finviz heavily used]

## Next Steps
1. Conduct detailed fundamental analysis on top 3 candidates
2. Check earnings calendars for upcoming reports
3. Review technical charts for entry timing
4. [If bear market: Wait for market recovery before deploying capital]

---
**Note:** This is Phase 2 (C, A, N, S, I, M components - 80% coverage). Phase 3 will add L component for full 7-component CANSLIM.

Resources

Scripts Directory (`scripts/`)

Main Scripts:

Calculators (scripts/calculators/):

Supporting Modules:

References Directory (`references/`)

Knowledge Bases:

How to Use References:


Troubleshooting

Issue 1: FMP API Rate Limit Exceeded

Symptoms:

ERROR: 429 Too Many Requests - Rate limit exceeded
Retrying in 60 seconds...

Causes:

Solutions:

  1. Wait and Retry: Script auto-retries after 60s
  2. Reduce Universe: Use --max-candidates 30 to lower API usage
  3. Check Daily Usage: Free tier resets at midnight UTC
  4. Upgrade Plan: FMP Starter ($29.99/month) provides 750 calls/day

Issue 2: Missing Required Libraries

Symptoms:

ERROR: required libraries not found. Install with: pip install beautifulsoup4 requests lxml

Solutions:

# Install all required libraries
pip install requests beautifulsoup4 lxml

# Or install individually
pip install beautifulsoup4
pip install requests
pip install lxml

Issue 3: Finviz Fallback Slow Execution

Symptoms:

Execution time: 2 minutes 30 seconds for 40 stocks (slower than expected)

Causes:

Solutions:

  1. Accept Delay: 1-2 minutes for 40 stocks is normal with Finviz fallback
  2. Monitor Fallback Usage: Check logs for "Using Finviz institutional ownership" messages
  3. Reduce Rate Limit (advanced): Edit finviz_stock_client.py, change rate_limit_seconds=2.0 to 1.5 (risk: IP ban)

Note: Finviz fallback adds ~2 seconds per stock but significantly improves I component accuracy (35 → 60-100 points).

Issue 4: Finviz Web Scraping Failure

Symptoms:

WARNING: Finviz request failed with status 403 for NVDA
⚠️ Using Finviz institutional ownership data - FMP shares outstanding unavailable. Finviz fallback also unavailable. Score reduced by 50%.

Causes:

Solutions:

  1. Wait and Retry: Rate limit resets after a few minutes
  2. Check Internet Connection: Verify network access to finviz.com
  3. Fallback Accepted: Script continues with FMP holder count only (I score capped at 70/100)
  4. Manual Verification: Check Finviz website manually for blocked IP

Graceful Degradation:

Issue 5: No Stocks Meet Minimum Thresholds

Symptoms:

✓ Successfully analyzed 40 stocks
Top 5 Stocks:
  1. AAPL  -  58.3 (Average)
  2. MSFT  -  55.1 (Average)
  ...

Causes:

Solutions:

  1. Check M Component: If M=0 (bear market), raise cash per CANSLIM rules
  2. Expand Universe: Try different sectors or market cap ranges
  3. Lower Expectations: Average scores (55-65) may still be actionable in weak markets
  4. Wait for Better Setup: CANSLIM works best in bull markets

Issue 6: Data Quality Warnings

Symptoms:

⚠️ Revenue declining despite EPS growth (possible buyback distortion)
⚠️ Using Finviz institutional ownership data (68.3%) - FMP shares outstanding unavailable.

Interpretation:

Actions:

  1. Review component details in full report
  2. Cross-check with fundamental analysis
  3. Adjust position sizing based on risk level
  4. Finviz data is reliable - no action needed for data source warnings

Important Notes

Phase 2 Implementation Status

This is Phase 2 implementing 6 of 7 CANSLIM components:

Implications:

Score Conversion:

Finviz Integration Benefits

Automatic Fallback System:

Data Source Priority:

  1. FMP API (primary): Institutional holder count + shares outstanding calculation
  2. Finviz (fallback): Direct institutional ownership % from web page
  3. Partial Data (last resort): Holder count only, 50% penalty applied

Tested Reliability:

Future Enhancements

Phase 3 (Planned):

Phase 4 (Planned):

Data Source Attribution

Disclaimer

This screener is for educational and informational purposes only.


Version: Phase 2

Last Updated: 2026-01-12

API Requirements: FMP API (free tier sufficient) + BeautifulSoup/requests/lxml for Finviz

Execution Time: ~1 minute 40 seconds for 40 stocks

Output Formats: JSON + Markdown

Components Implemented: C, A, N, S, I, M (6 of 7, 80% coverage)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.