Skip to content

A comprehensive stock analysis tool built with Streamlit that provides real-time stock data, technical analysis, and machine learning-powered price predictions.

Notifications You must be signed in to change notification settings

saxil/StockTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Enhanced Stock Tracker

A comprehensive stock tracking and analysis application built with Streamlit featuring advanced technical analysis, portfolio management, price alerts, and AI-powered predictions.

πŸš€ Quick Start (No Setup Required!)

# 1. Clone the repository
git clone https://github.com/yourusername/StockTracker.git
cd StockTracker

# 2. Install dependencies
pip install -r requirements.txt

# 3. Run the application
streamlit run app.py

# 4. Open your browser to http://localhost:8501

That's it! No API keys, no configuration files, no database setup required. Just install and run!

Alternative: Use the startup scripts

# Windows
start.bat

# Linux/Mac
./start.sh

Visit the live application: Enhanced Stock Tracker

πŸ“‹ Features

πŸ“Š Stock Analysis

  • Real-time Stock Data: Fetch current and historical stock prices using Yahoo Finance
  • Interactive Charts: Beautiful, interactive candlestick charts powered by Plotly
  • 15+ Technical Indicators: SMA, EMA, RSI, MACD, Bollinger Bands, Stochastic, ATR, CCI, Williams %R, VWAP, OBV, and more
  • Trading Signals: Automated buy/sell/neutral signals based on technical analysis
  • Support & Resistance: Automatic identification of key price levels
  • Fibonacci Retracement: Calculate and display Fibonacci levels

πŸ’Ό Portfolio Management

  • Holdings Tracking: Add and manage stock holdings with purchase dates and prices
  • Performance Analytics: Real-time portfolio value, gains/losses, and percentage returns
  • Allocation Analysis: Visual portfolio allocation with pie charts and performance graphs
  • Dividend Tracking: Monitor dividend income and yields
  • Export Functionality: Download portfolio data as CSV files
  • Rebalancing Suggestions: AI-powered portfolio rebalancing recommendations

πŸ”” Smart Alerts System

  • Price Alerts: Set alerts for price above/below thresholds
  • Percentage Change Alerts: Get notified on significant price movements
  • Email Notifications: Receive alert notifications via email
  • Alert History: Track triggered alerts and statistics
  • Multiple Alert Types: Support for various alert conditions

🎯 AI-Powered Predictions

  • Machine Learning Models: Random Forest and Linear Regression for price forecasting
  • Customizable Timeframes: Predict prices 1-90 days into the future
  • Model Accuracy Metrics: MAE, RMSE, and performance indicators
  • Visual Predictions: Interactive charts showing predicted vs historical prices
  • Prediction Export: Download predictions as CSV data

πŸ” User Management

  • Secure Authentication: Login system with user profiles
  • Favorites System: Save and quickly access favorite stocks
  • Analysis History: Track all your stock analyses
  • Password Reset: Email-based password recovery
  • User Preferences: Personalized settings and configurations

πŸ’Ύ Data Persistence

  • SQLite Database: Robust data storage for stocks, portfolios, alerts, and analysis history
  • Historical Data Storage: Automatic storage of fetched stock data
  • Analysis Caching: Save and retrieve analysis results
  • Portfolio History: Track portfolio performance over time

πŸ› οΈ Technologies Used

  • Streamlit - Web application framework
  • Yahoo Finance API - Stock data source
  • Plotly - Interactive visualizations
  • scikit-learn - Machine learning models
  • SQLite - Database for data persistence
  • Pandas - Data manipulation and analysis
  • NumPy - Numerical computing
  • Python 3.8+ - Core programming language

πŸ—οΈ Project Structure

StockTracker/
β”œβ”€β”€ src/
β”‚   └── stock_tracker/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ main.py                 # Original Streamlit app
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   β”œβ”€β”€ __init__.py
β”‚       β”‚   β”œβ”€β”€ auth.py             # Authentication system
β”‚       β”‚   └── settings.py         # Application settings
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   β”œβ”€β”€ __init__.py
β”‚       β”‚   β”œβ”€β”€ stock.py            # Stock data models
β”‚       β”‚   └── database.py         # Database management
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   β”œβ”€β”€ __init__.py
β”‚       β”‚   └── email_service.py    # Email notifications
β”‚       β”œβ”€β”€ utils/
β”‚       β”‚   β”œβ”€β”€ __init__.py
β”‚       β”‚   β”œβ”€β”€ technical_analysis.py    # Technical indicators
β”‚       β”‚   β”œβ”€β”€ portfolio.py             # Portfolio management
β”‚       β”‚   └── alert_system.py          # Price alerts system
β”‚       └── templates/
β”‚           └── email/              # Email templates
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_database.py           # Database tests
β”‚   β”œβ”€β”€ test_technical_analysis.py # Technical analysis tests
β”‚   β”œβ”€β”€ test_portfolio.py          # Portfolio tests
β”‚   β”œβ”€β”€ test_email_service.py      # Email service tests
β”‚   └── fixtures/                  # Test data fixtures
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ stocks.db                  # SQLite database
β”‚   └── users.json                 # User data
β”œβ”€β”€ docs/                          # Documentation
β”œβ”€β”€ app.py                         # Enhanced Streamlit application
β”œβ”€β”€ app.py                         # Original application
β”œβ”€β”€ auth.py                        # Authentication module
β”œβ”€β”€ run_tests.py                   # Test runner
β”œβ”€β”€ requirements.txt               # Dependencies
└── README.md                      # This file

πŸƒβ€β™‚οΈ Running Locally

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Setup Instructions

  1. Clone the repository:
git clone https://github.com/yourusername/StockTracker.git
cd StockTracker
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the enhanced application:
streamlit run app.py
  1. Open your browser to: http://localhost:5000

πŸ§ͺ Testing

Run the comprehensive test suite:

# Verify everything works (no API keys required)
python verify_setup.py

# Run all tests
python run_tests.py

# Run tests with coverage report
python run_tests.py --coverage

# Run specific test modules
python -m pytest tests/test_database.py -v
python -m pytest tests/test_technical_analysis.py -v
python -m pytest tests/test_portfolio.py -v

πŸ› οΈ Troubleshooting

Common Issues

❓ "Module not found" errors

# Make sure you're in the correct directory and dependencies are installed
pip install -r requirements.txt

❓ "No data available" for stocks

# Test if Yahoo Finance is accessible
python verify_setup.py

❓ Email alerts not working

  • This is normal! Email is completely optional
  • See docs/EMAIL_SETUP.md if you want email notifications
  • All other features work without email setup

❓ Database errors

  • The app automatically creates its SQLite database
  • Delete data/stocks.db if you want to reset everything

πŸ”§ Configuration

Email Configuration (Optional)

For alert notifications, set up email configuration:

  1. Create environment variables:
# Windows
set EMAIL_ADDRESS=your-email@gmail.com
set EMAIL_PASSWORD=your-app-password

# Linux/Mac
export EMAIL_ADDRESS=your-email@gmail.com
export EMAIL_PASSWORD=your-app-password
  1. Or create .streamlit/secrets.toml:
[email]
EMAIL_ADDRESS = "your-email@gmail.com"
EMAIL_PASSWORD = "your-app-password"

Database Configuration

The application automatically creates a SQLite database in the data/ directory. No additional configuration required.

Stock Data Source

This application uses Yahoo Finance (yfinance) which provides free stock data without requiring any API keys or subscriptions. Simply install the requirements and start using the app!

πŸ“Š Usage Guide

Getting Started

  1. Create an account or login with existing credentials
  2. Analyze stocks by entering symbols (e.g., AAPL, GOOGL, MSFT)
  3. Add to portfolio to track your investments
  4. Set up alerts for price movements
  5. Explore technical analysis with advanced indicators
  6. Generate predictions using AI models

Key Features

Stock Analysis

  • Enter any stock symbol (e.g., AAPL, GOOGL, TSLA)
  • Choose analysis timeframe (1mo to 5y)
  • View real-time data, charts, and key metrics
  • Get automated trading signals

Portfolio Management

  • Add holdings with purchase price and date
  • Monitor real-time performance
  • View allocation and returns
  • Export data for external analysis

Price Alerts

  • Set price threshold alerts
  • Configure percentage change notifications
  • Receive email notifications (if configured)
  • Track alert history and statistics

Technical Analysis

  • 15+ technical indicators
  • Support and resistance levels
  • Fibonacci retracement levels
  • Advanced charting with multiple timeframes

AI Predictions

  • Machine learning price forecasting
  • Multiple model options (Random Forest, Linear Regression)
  • Customizable prediction timeframes
  • Model accuracy metrics

πŸ“¦ Deployment

This app is deployed on Streamlit Community Cloud. To deploy your own version:

  1. Fork this repository
  2. Go to share.streamlit.io
  3. Connect your GitHub account
  4. Select your forked repository
  5. Set the main file path to app.py (or base_app.py for basic version)
  6. Deploy!

No API keys required! The app uses Yahoo Finance which provides free data.

πŸ”§ Configuration

The app uses environment variables for sensitive data. Create a .streamlit/secrets.toml file for local development (optional):

[email]
GMAIL_EMAIL = "your-email@gmail.com"
GMAIL_APP_PASSWORD = "your-app-password"

Email configuration is only needed if you want to receive alert notifications.

πŸ“Š Popular Stock Symbols

Try these popular symbols in the app:

  • AAPL - Apple Inc.
  • GOOGL - Alphabet Inc.
  • MSFT - Microsoft Corporation
  • TSLA - Tesla Inc.
  • AMZN - Amazon.com Inc.
  • NVDA - NVIDIA Corporation

❓ Frequently Asked Questions

Q: Do I need any API keys?
A: No! The app uses Yahoo Finance which provides free data without requiring API keys.

Q: Do I need to set up email?
A: No, email is completely optional. It's only needed if you want to receive price alert notifications.

Q: What databases do I need to install?
A: None! The app uses SQLite which is built into Python. The database file is created automatically.

Q: Can I use this for real trading?
A: This is for educational and analysis purposes only. Always consult with financial professionals before making investment decisions.

Q: Does this work offline?
A: You need an internet connection to fetch current stock data, but the analysis and portfolio features work with cached data.

Q: Is my data safe?
A: All data is stored locally on your computer in a SQLite database. Nothing is sent to external servers except for fetching stock prices from Yahoo Finance.

⚠️ Disclaimer

This tool is for informational purposes only and should not be considered as financial advice. Always do your own research before making investment decisions.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A comprehensive stock analysis tool built with Streamlit that provides real-time stock data, technical analysis, and machine learning-powered price predictions.

Resources

Stars

Watchers

Forks

Languages