A CLI tool to track stock portfolios with AI-powered analysis and automated GitHub Actions reporting.
Project description
Stock Tracker CLI
A command-line tool to track your stock portfolio and get AI-powered investment analysis.
Features
- ๐ Portfolio Management: Add and remove stock positions with purchase prices
- ๐น Real-time Data: Fetch current stock prices using Alpha Vantage API
- ๐ค AI Analysis: Get intelligent insights using Groq's LLM (llama-3.3-70b-versatile)
- ๐ง Email Reports: Send HTML-formatted reports with AI analysis via email
- โก Smart Caching: 15-minute cache to reduce API calls
- ๐ณ Docker Support: Containerized deployment with automated scheduled reports
- ๐จ GitHub Actions Automation: Scheduled and event-based reporting with Tavily API integration
- ๐ฐ Market Event Detection: Automatically trigger reports when significant market events affect your portfolio
Installation
From PyPI
pip install stock-tracker-cli
From Source
git clone https://github.com/Chukwuebuka-2003/stock_cli.git
cd stock_cli
pip install -e .
Quick Start
1. Configure API Keys
# Setup Groq API key for AI analysis
stock-tracker setup-ai
# Setup Alpha Vantage API key for stock data
stock-tracker setup-alpha-vantage
# Setup email settings (optional, for email reports)
stock-tracker setup-email
Get Free API Keys:
- Groq: https://console.groq.com/
- Alpha Vantage: https://www.alphavantage.co/support/#api-key
2. Add Stock Positions
# Add a stock position
stock-tracker add AAPL 10 150.00
# Arguments: SYMBOL QUANTITY PURCHASE_PRICE
stock-tracker add MSFT 5 300.00
stock-tracker add GOOGL 3 2800.00
3. Generate Reports
# View portfolio report in terminal
stock-tracker report
# Get AI-powered analysis
stock-tracker ai-report
# Send AI report via email
stock-tracker ai-report --email recipient@example.com
Commands
Portfolio Management
# Add a stock position
stock-tracker add <SYMBOL> <QUANTITY> <PURCHASE_PRICE>
# Remove a stock position
stock-tracker remove <SYMBOL>
Reports
# Generate plain text report
stock-tracker report
# Generate AI-powered analysis report
stock-tracker ai-report [--email EMAIL]
Configuration
# Configure Groq API key
stock-tracker setup-ai
# Configure Alpha Vantage API key
stock-tracker setup-alpha-vantage
# Configure email settings
stock-tracker setup-email
Example Output
Stock Portfolio Report
Generated on: 2025-11-09 10:30:00
โโโโโโโโโโฆโโโโโโโโโโโฆโโโโโโโโโโโโโโโโโฆโโโโโโโโโโโโโโโโฆโโโโโโโโโโโโโฆโโโโโโโโโโโโโโโโโโ
โ Symbol โ Quantity โ Purchase Price โ Current Price โ Value โ Gain/Loss (%) โ
โ โโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฃ
โ AAPL โ 10.0 โ $150.00 โ $178.50 โ $1,785.00 โ +$285.00 (+19%) โ
โ MSFT โ 5.0 โ $300.00 โ $385.20 โ $1,926.00 โ +$426.00 (+28%) โ
โ GOOGL โ 3.0 โ $2,800.00 โ $2,950.00 โ $8,850.00 โ +$450.00 (+5%) โ
โโโโโโโโโโฉโโโโโโโโโโโฉโโโโโโโโโโโโโโโโโฉโโโโโโโโโโโโโโโโฉโโโโโโโโโโโโโฉโโโโโโโโโโโโโโโโโโ
Portfolio Summary:
Total Value: $12,561.00
Total Gain/Loss: +$1,161.00 (+10.2%)
GitHub Actions Automation โก
NEW! Automate your stock reports with GitHub Actions - no server required!
Features
- ๐ Scheduled Reports: Daily, weekly, and monthly automated reports
- ๐จ Event-Based Triggers: Automatically generate reports when market events affect your portfolio
- ๐ Secure: All credentials stored in GitHub Secrets
- ๐ง Email Delivery: Reports sent directly to your inbox
- ๐ณ Docker Execution: Containerized workflows for consistency
Quick Setup
-
Configure GitHub Secrets (Settings โ Secrets โ Actions):
GROQ_API_KEY ALPHA_VANTAGE_API_KEY TAVILY_API_KEY EMAIL_SMTP_SERVER EMAIL_SMTP_PORT EMAIL_ADDRESS EMAIL_PASSWORD EMAIL_RECIPIENT PORTFOLIO_POSITIONS -
Set Portfolio Positions (JSON format):
[{"symbol":"AAPL","quantity":10,"purchase_price":150.0},{"symbol":"GOOGL","quantity":5,"purchase_price":2800.0}]
-
Enable GitHub Actions in your repository settings
-
Done! Reports will be automatically generated and emailed on schedule
Workflows
- Scheduled Reports: Daily (8 AM UTC), Weekly (Mon 6 AM), Monthly (1st at 7 AM)
- Event-Based: Checks every 2 hours for market events affecting your portfolio
- Docker-Based: Containerized execution (8:30 AM UTC daily)
Get Started
๐ Complete Setup Guide - Detailed instructions with troubleshooting
Get Tavily API Key: https://tavily.com (Free tier: 1,000 credits/month)
Docker Deployment
Build and Run
# Build the image
docker build -t stock-tracker:latest .
# Run one-time report
docker run --rm stock-tracker:latest report
# Run AI report with email
docker run --rm \
-e GROQ_API_KEY="your_key" \
-e ALPHA_VANTAGE_API_KEY="your_key" \
-e EMAIL_ADDRESS="your@gmail.com" \
-e EMAIL_PASSWORD="app_password" \
-e EMAIL_RECIPIENT="recipient@example.com" \
-e PORTFOLIO_POSITIONS='[{"symbol":"AAPL","quantity":10,"purchase_price":150}]' \
stock-tracker:latest ai-report --email
Environment Variables
Create a .env file:
GROQ_API_KEY=your_groq_api_key
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key
TAVILY_API_KEY=your_tavily_api_key
EMAIL_SMTP_SERVER=smtp.gmail.com
EMAIL_SMTP_PORT=587
EMAIL_ADDRESS=your_email@gmail.com
EMAIL_PASSWORD=your_app_password
EMAIL_RECIPIENT=recipient@example.com
PORTFOLIO_POSITIONS=[{"symbol":"AAPL","quantity":10,"purchase_price":150.0}]
Configuration Files
The CLI stores data in platform-specific directories:
- Linux:
~/.config/StockTrackerCLI/and~/.local/share/StockTrackerCLI/ - macOS:
~/Library/Application Support/StockTrackerCLI/ - Windows:
%LOCALAPPDATA%\StockTrackerCLI\
Files:
config.json- API keys and email settingspositions.json- Your stock positionscache.json- Cached stock data (15-minute expiry)logs/stock_tracker.log- Application logs
Requirements
- Python 3.8 or higher
- Internet connection for API access
- API keys:
- Groq API (for AI analysis)
- Alpha Vantage API (for stock data)
- SMTP server access (optional, for email reports)
Dependencies
- click - CLI framework
- pandas - Data manipulation
- groq - AI inference
- alpha-vantage - Stock data API
- tavily-python - Market event detection and news search
- python-dateutil - Date utilities
- appdirs - Cross-platform directories
- schedule - Task scheduling
- python-dotenv - Environment variable management
Gmail Setup
For Gmail users, you'll need to use an App Password:
- Enable 2-factor authentication on your Google account
- Go to https://myaccount.google.com/apppasswords
- Generate an app password for "Mail"
- Use this app password when running
stock-tracker setup-email
License
MIT License - see LICENSE file for details
Author
Chukwuebuka Ezeokeke - GitHub
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Issues
Found a bug? Please report it on the GitHub Issues page.
Project details
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 stock_tracker_cli-0.2.0.tar.gz.
File metadata
- Download URL: stock_tracker_cli-0.2.0.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25873e5b71d4755193ac1244f52b24cb8985a80db2f7bf88fc75ab2ebc5e1b31
|
|
| MD5 |
ae38fa46052f280341df9510fb9afb9c
|
|
| BLAKE2b-256 |
5cb1f8afa7b754b8f27c17ca287af5387bce680f40c9cc3c6daa80f164938faf
|
File details
Details for the file stock_tracker_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: stock_tracker_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b5e2232dfa71d440da93de08482fb39f7c76e7872dbe1391f5bea7be2718e6a
|
|
| MD5 |
30da7e395ba470a778e0863a44a7947b
|
|
| BLAKE2b-256 |
eb446b8442b3de609f11ebe2230cb1ca13c8f389b7e131b70c890762351e7768
|