This application scans stocks listed on the NYSE and NASDAQ (excluding ETFs and non-common stock) to identify instances of "Golden Cross" or "Death Cross" technical patterns.
- Golden Cross (Bullish): The 50-day Simple Moving Average (SMA) crosses above the 200-day Simple Moving Average (SMA).
- Death Cross (Bearish): The 50-day Simple Moving Average (SMA) crosses below the 200-day Simple Moving Average (SMA).
This application specifically looks for:
- The relevant SMA crossover (50-day vs. 200-day) occurring on the most recent trading day.
- The SMAs being in the opposite position on the prior trading day (e.g., for a Golden Cross, 50-day SMA <= 200-day SMA on the previous day).
- Optional volume confirmation: If enabled, the volume on the crossover day must be greater than a specified multiple of the 20-day average volume.
- Fetches a list of publicly traded stocks from the official NASDAQ FTP site (NASDAQ & Other Listed), filtering out ETFs and test issues.
- Retrieves historical daily price data for each ticker using the
yfinance
library. - Calculates 50-day and 200-day SMAs, and 20-day average volume using
pandas
. - Identifies tickers exhibiting a Golden Cross or Death Cross on the latest trading day.
- Allows users to select the scan type (Golden Cross, Death Cross, or Both).
- Provides an adjustable threshold for optional volume confirmation.
- Displays the results in an interactive table using Streamlit.
- Shows mini-charts for each identified ticker, visualizing the closing price, SMAs, and the crossover event.
- Backend/Analysis: Python 3
- Web Framework/UI: Streamlit
- Data Fetching:
yfinance
,urllib.request
(for FTP) - Data Manipulation:
pandas
- Charting:
matplotlib
- Clone the repository (if applicable):
git clone <repository-url> cd golden_cross_scanner
- Create a Python virtual environment:
python3 -m venv .venv
- Activate the virtual environment:
- macOS/Linux:
source .venv/bin/activate
- Windows:
.venv\Scripts\activate
- macOS/Linux:
- Install dependencies:
pip install -r requirements.txt
- Ensure your virtual environment is activated.
- Run the Streamlit application:
streamlit run app.py
- The application will open in your default web browser.
- Select the desired "Scan Type" (Golden Cross, Death Cross, or Both).
- Adjust the "Volume Confirmation Multiplier" if desired (set > 1.0 to enable the filter, e.g., 1.5 means volume must be > 1.5x the 20-day average).
- Click the "🚀 Scan for [Selected Type]" button to start the analysis.
Note: The initial scan can take a significant amount of time depending on the total number of stock tickers (~8,000-10,000+) and your network connection speed, as it needs to fetch data for each one. Subsequent runs within 6 hours will use a cached ticker list.
You can adjust some parameters directly in the app.py
script:
DAYS_OF_DATA
: Number of historical days fetched per ticker (default: 500).CHART_DAYS
: Number of days displayed on the mini-charts (default: 100).AVG_VOL_WINDOW
: Lookback period for calculating average volume (default: 20).TICKER_LIMIT
: Set to an integer (e.g.,50
) to limit the number of tickers scanned during development/testing. Set toNone
to scan all tickers.
- Ticker Symbols (Stocks Only): NASDAQ Trader FTP (
ftp://ftp.nasdaqtrader.com/symboldirectory/
) - Historical Stock Data: Yahoo Finance (via
yfinance
library)