Skip to main content

A CLI tool to track stock portfolios and get AI-powered analysis.

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

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:

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%)

Docker Deployment

Build and Run

# Build the image
docker-compose build

# Run one-time report
docker-compose run stock-tracker stock-tracker report

# Run with scheduled reports (daily at 4:30 PM UTC on weekdays)
docker-compose up -d cron

Environment Variables

Create a .env file:

GROQ_API_KEY=your_groq_api_key
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key
EMAIL_SMTP_SERVER=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USERNAME=your_email@gmail.com
EMAIL_PASSWORD=your_app_password
EMAIL_RECIPIENT=recipient@example.com

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 settings
  • positions.json - Your stock positions
  • cache.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
  • python-dateutil - Date utilities
  • appdirs - Cross-platform directories

Gmail Setup

For Gmail users, you'll need to use an App Password:

  1. Enable 2-factor authentication on your Google account
  2. Go to https://myaccount.google.com/apppasswords
  3. Generate an app password for "Mail"
  4. 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

stock_tracker_cli-0.1.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stock_tracker_cli-0.1.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file stock_tracker_cli-0.1.1.tar.gz.

File metadata

  • Download URL: stock_tracker_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stock_tracker_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1aebcd995e408b65b7dd37d1c772eb63fcbe822e614181b11f2e83d274198ec3
MD5 24ac6709ce0d7b8db401adde4b25cbc8
BLAKE2b-256 23e258908bbd9bf0da8bf3a248ab94b0e1ed2a10fb15a264c0fa6957f30090b9

See more details on using hashes here.

File details

Details for the file stock_tracker_cli-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for stock_tracker_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 332777fd70a6472400abb7ec1a542ea58d146021a9a76730c8613e1dc2832f6b
MD5 193dae89e7d0b6e9b03a013523e7f32a
BLAKE2b-256 aca6beb325a617a4f269fac6f4c89272024cfd8ba059c28bc8c119990810b4d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page