No project description provided
Project description
📊 Earnings Stock Analyzer
This Python project analyzes how a stock has historically reacted in the market after publishing its earnings. It supports two data sources (library or API), multiple execution modes, and outputs both CSVs and plots for further analysis.
The main purpose of the project is to find a statistical edge that repeats historically around earnings announcements, in order to identify potential investment opportunities.
🎯 Purpose
The project has two main types of analysis:
-
Earnings Reaction Analysis
-
Calculates the absolute price change average around earnings announcements, the average in positive earnings, and the average in negative earnings:
- Previous Close → Next Open
- Previous Close → Next Close
- Next Open → Next Close
-
-
Momentum Analysis
-
Focuses on whether momentum continued the next day after earnings:
- Calculates the % of cases where earnings with a positive reaction continued upward the day after.
- Calculates the % of cases where earnings with a negative reaction continued downward the day after.
- Provides overall momentum success rate, % of positives with momentum, and % of negatives with momentum.
-
The purpose is to measure the persistence of trends following earnings.
-
Together, these two analyses provide a picture of both:
- The magnitude of changes caused by earnings (reaction analysis).
- The likelihood of continuation after earnings (momentum analysis).
- And ultimately, whether a statistical edge exists that can be exploited for investing strategies.
🗂 Project Structure
earnings-stock-analyzer/
├── earnings_stock_analyzer/
│ ├── __init__.py # Package initializer
│ ├── analyzer.py # Core analysis logic
│ ├── fetch.py # Unified data fetching (library or API)
│ ├── plot.py # Plotting and visualization
│ └── cli.py # CLI configuration
├── scripts/
│ ├── run_analysis.py # Main script for earnings reaction analysis
│ ├── run_momentum.py # Main script for momentum analysis
│
├── data/ # Input datasets (CSV)
├── output/ # Generated results (CSVs, plots)
├── README.md
├── pyproject.toml
├── poetry.lock
🚀 How to Run
-
Install dependencies:
poetry install -
Activate shell (optional):
poetry shell
🔹 Earnings Reaction Analysis
Run the analysis script:
poetry run python scripts/run_analysis.py <ticker> --source [library|api] [--api-key API_KEY]
Examples:
# Analyze NVDA with library data (default source if not specified)
poetry run python scripts/run_analysis.py NVDA
# Analyze NVDA with API (using default project key)
poetry run python scripts/run_analysis.py NVDA --source api
# Analyze NVDA with API and your own API key (optional, for higher limits)
poetry run python scripts/run_analysis.py NVDA --source api --api-key YOUR_KEY
# Analyze all tickers in S&P 500 + Nasdaq (no ticker specified)
poetry run python scripts/run_analysis.py
🔹 Momentum Analysis
Run the momentum script:
poetry run python scripts/run_momentum.py <ticker> --source [library|api] [--api-key API_KEY]
Examples:
# Momentum analysis for NVDA with library data
poetry run python scripts/run_momentum.py NVDA
# Momentum analysis for NVDA with API
poetry run python scripts/run_momentum.py NVDA --source api
# Momentum analysis for all tickers (S&P 500 + Nasdaq)
poetry run python scripts/run_momentum.py
📂 Output
All outputs are saved in the output/ directory.
Depending on how you run the program, different CSVs are created:
Single Ticker (Analysis or Momentum)
- Detailed CSV showing all historical earnings dates for the ticker.
- Includes Close→Open, Close→Close, and Open→Close changes.
- Momentum files also show continuation statistics (overall, positives, negatives).
All Tickers (S&P 500 + Nasdaq)
If no ticker is provided, the project analyzes all tickers in the dataset and creates rankings:
-
Analysis Mode:
- CSV with the Top 20 stocks ranked by the highest average absolute change in Close→Open on earnings days.
-
Momentum Mode:
- CSV with the Top 30 overall stocks with the highest % of momentum continuation.
- CSV with the Top 30 stocks on positive earnings days with the highest % of continued momentum.
- CSV with the Top 30 stocks on negative earnings days with the highest % of continued momentum.
This allows you to quickly identify which stocks historically have the largest reactions and which ones show the strongest continuation patterns.
🔑 Requirements
-
Python ≥ 3.13
-
Packages (auto-installed with Poetry):
requests,pandas,yfinance,matplotlib,seabornstocks-earnings-dates(my own library that you will see here is the one used in this project to recollect the earnings dates and % changes for each date): GitHub link)
✍️ Author
Developed by AlbertPerez7 as a personal project to explore API usage, data analysis, quantitative finance, and systematic investing strategies.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file earnings_stock_analyzer-0.1.1.tar.gz.
File metadata
- Download URL: earnings_stock_analyzer-0.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a42d3cf77b777e261f7879b1f707739122f3f194923b535c0866d07de76c5730
|
|
| MD5 |
26d92ac22039496f074f25ec21b17119
|
|
| BLAKE2b-256 |
b8930e51e329072ce34e279f7b9549907cb1fe435692963f733062aecd39f2ef
|
File details
Details for the file earnings_stock_analyzer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: earnings_stock_analyzer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fefc6baa5b895665deef2bdabe322b81bfb61207bca75ace8933993289d4e84
|
|
| MD5 |
8f0fb3daacc85e0292b86334675532fc
|
|
| BLAKE2b-256 |
2437354adc57e91b72840d644fc098f34b5c28d436e78b55882ad0e3f60b0dc4
|