Skip to content

Latest commit

 

History

History
122 lines (94 loc) · 3.23 KB

File metadata and controls

122 lines (94 loc) · 3.23 KB

Quick Start Guide

First Time Setup

# 1. Activate virtual environment
source .venv/bin/activate

# 2. Run the script
python main.py

You'll be prompted:

  • Do you want to include most active stocks? → Answer y or n

What Happens

Step 1: Input Tickers

  • Fetches S&P 500 list (~500 stocks)
  • Optionally fetches most active stocks (filtered ≥$10B market cap)
  • Saves to input_tickers/

Step 2: Fetch Data (with Smart Caching)

  • First run: Fetches data from Yahoo Finance (takes a few minutes for 500+ stocks)
  • Same-day reruns: Uses cached data (instant!)
  • Cache stored in: cache/raw_data_YYYY-MM-DD.csv

Step 3: Generate Sorted Reports

Creates folder: output_results/YYYY-MM-DD/ with 3 CSV files:

  1. by_sell_then_buy.csv

    • Best stocks with lowest sell ratings
    • Ties broken by highest buy ratings
  2. by_sell_then_price_gap.csv

    • Best stocks with lowest sell ratings
    • Ties broken by best price vs target (most undervalued)
  3. by_sell_then_market_cap.csv

    • Best stocks with lowest sell ratings
    • Ties broken by largest market cap (more stable)

Key Insights

Understanding the Output

Look for:

  • total_sell = 0 or very low → Few analysts recommend selling
  • total_buy = high → Many analysts recommend buying
  • price_vs_target < 0 → Trading below analyst's low target (potential bargain)
  • price_at_low_end = True → Currently within ±10% of analyst's low target

Example Good Stock:

ticker: AAPL
current_price: 267.11
target_low: 200.00
total_sell: 0
total_buy: 29
price_vs_target: 67.11  (trading above low target - bullish)

Example Potential Value:

ticker: INTC
current_price: 21.50
target_low: 25.00
total_sell: 2
total_buy: 15
price_vs_target: -3.50  (trading BELOW low target - potential bargain or concern)

Tips

Run Multiple Times Per Day

  • First run: Fetches fresh data
  • Subsequent runs: Uses cache (instant)
  • Experiment with different analysis without API limits!

Add Your Own Tickers

  1. Create a CSV in input_tickers/
  2. First column = ticker symbol
  3. Additional columns optional (name, notes, etc.)

Example input_tickers/my_watchlist.csv:

ticker,name,notes
AAPL,Apple Inc.,Tech leader
MSFT,Microsoft,Cloud growth

Force Fresh Data

Delete the cache file for today:

rm cache/raw_data_$(date +%Y-%m-%d).csv
python main.py

Add Custom Sorting Strategies

See README.md "Adding Custom Sorting Strategies" section

Troubleshooting

Problem: Wikipedia 403 Forbidden for S&P 500

  • Fixed in current version with proper headers
  • If still occurs, manually add CSV to input_tickers/

Problem: 'Ticker' object has no attribute 'analyst_price_targets'

  • Fixed in current version (using plural analyst_price_targets)
  • Make sure yfinance is up to date: pip install --upgrade yfinance

Problem: Data fetch takes too long

  • Normal for 500+ stocks (can take 10-30 minutes)
  • Use cache for subsequent runs on same day
  • Or create smaller CSV in input_tickers/ with specific tickers

Next Steps

  1. Open the CSV files in Excel/Numbers/Google Sheets
  2. Sort/filter by your own criteria
  3. Cross-reference with your research
  4. Remember: This is a screening tool, not investment advice!