Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .streamlit/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@ enableXsrfProtection = false

[browser]
gatherUsageStats = false

[theme]
primaryColor="#22A7F0" # A clear, vibrant blue
backgroundColor="#0E1117" # Dark background
secondaryBackgroundColor="#1C202D" # Slightly lighter dark for elements
textColor="#FAFAFA" # Light text for dark background
font="sans serif" # Or "serif", "monospace"

# Optional: You can also set specific widget colors if needed
# For example, to make buttons match the primary color:
# buttonBackgroundColor = "#22A7F0"
# buttonTextColor = "#FFFFFF"
```
201 changes: 65 additions & 136 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Visit the live application: [Enhanced Stock Tracker](https://your-app-name.strea
### 📊 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
- **15+ Technical Indicators**: SMA, EMA, RSI, MACD, Bollinger Bands, Stochastic, ATR, CCI, Williams %R, VWAP, OBV, and more. Prediction models also leverage a rich set of these indicators.
- **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
Expand All @@ -52,22 +52,23 @@ Visit the live application: [Enhanced Stock Tracker](https://your-app-name.strea
### 🔔 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
- **Email Notifications**: Receive email notifications for triggered alerts (requires SMTP configuration as per `docs/EMAIL_SETUP.md`).
- **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
- **Machine Learning Models**: Utilizes Random Forest, Linear Regression, and Gradient Boosting Regressor for price forecasting.
- **Enhanced Feature Engineering**: Models are trained using a comprehensive set of features, including various technical indicators, for improved accuracy.
- **Customizable Timeframes**: Predict prices 1-90 days into the future.
- **Model Accuracy Metrics**: MAE, RMSE, and performance indicators are displayed.
- **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
- **Password Reset**: Email-based password recovery (may use a separate email configuration, see `auth.py`).
- **User Preferences**: Personalized settings and configurations

### 💾 Data Persistence
Expand All @@ -79,7 +80,7 @@ Visit the live application: [Enhanced Stock Tracker](https://your-app-name.strea
## 🛠️ Technologies Used

- **Streamlit** - Web application framework
- **Yahoo Finance API** - Stock data source
- **Yahoo Finance API (yfinance)** - Stock data source
- **Plotly** - Interactive visualizations
- **scikit-learn** - Machine learning models
- **SQLite** - Database for data persistence
Expand All @@ -94,7 +95,7 @@ StockTracker/
├── src/
│ └── stock_tracker/
│ ├── __init__.py
│ ├── main.py # Original Streamlit app
│ ├── main.py # Original Streamlit app (references PredictionService)
│ ├── config/
│ │ ├── __init__.py
│ │ ├── auth.py # Authentication system
Expand All @@ -105,28 +106,31 @@ StockTracker/
│ │ └── database.py # Database management
│ ├── services/
│ │ ├── __init__.py
│ │ └── email_service.py # Email notifications
│ │ ├── email_service.py # Handles email notifications for alerts
│ │ └── prediction_service.py # Core logic for training and generating model-based price predictions
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── technical_analysis.py # Technical indicators
│ │ ├── portfolio.py # Portfolio management
│ │ └── alert_system.py # Price alerts system
│ │ └── alert_system.py # Price alerts system (uses EmailService)
│ └── templates/
│ └── email/ # Email templates
│ └── email/ # Email templates (if any, for future use)
├── 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
│ ├── test_prediction_service.py # Prediction service tests
│ └── fixtures/ # Test data fixtures
├── data/
│ ├── stocks.db # SQLite database
│ └── users.json # User data
├── docs/ # Documentation
├── enhanced_app.py # Enhanced Streamlit application
├── app.py # Original application
├── auth.py # Authentication module
│ └── users.json # User data (if auth.py uses it)
├── docs/
│ └── EMAIL_SETUP.md # Guide for configuring email notifications for alerts
├── enhanced_app.py # Enhanced Streamlit application (references PredictionService, AlertSystem)
├── app.py # Original application (deprecated or simplified)
├── auth.py # Authentication module (may have its own email setup for password resets)
├── run_tests.py # Test runner
├── requirements.txt # Dependencies
└── README.md # This file
Expand Down Expand Up @@ -162,188 +166,113 @@ pip install -r requirements.txt
streamlit run enhanced_app.py
```

5. **Or run the original application:**
```bash
streamlit run app.py
```

6. **Open your browser to:** `http://localhost:8501`
5. **Open your browser to:** `http://localhost:8501`

## 🧪 Testing

Run the comprehensive test suite:

```bash
# 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
# Example using unittest:
python -m unittest discover tests
```
(Adjust based on your actual test runner setup, e.g., `pytest tests/`)

## 🛠️ Troubleshooting

### Common Issues

**❓ "Module not found" errors**
```bash
# Make sure you're in the correct directory and dependencies are installed
pip install -r requirements.txt
```
- Ensure you're in the project root directory.
- Make sure dependencies are installed: `pip install -r requirements.txt`.
- Verify your `PYTHONPATH` if running scripts from subdirectories.

**❓ "No data available" for stocks**
```bash
# Test if Yahoo Finance is accessible
python verify_setup.py
```
- Check your internet connection.
- Yahoo Finance service might be temporarily unavailable.

**❓ 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
- Email notifications for alerts are optional and require configuration.
- Please refer to the detailed [Email Setup Guide](docs/EMAIL_SETUP.md) for instructions on setting up the necessary environment variables for the `EmailService`.
- All other application features work without this email setup.

**❓ Database errors**
- The app automatically creates its SQLite database
- Delete `data/stocks.db` if you want to reset everything
- The app automatically creates its SQLite database in the `data/` directory.
- If you encounter persistent issues, you can try deleting `data/stocks.db` to reset the database (this will remove all stored portfolio data, alerts, etc.).

## 🔧 Configuration

### Email Configuration (Optional)
For alert notifications, set up email configuration:
### Email Configuration for Alerts (Optional)

1. **Create environment variables:**
```bash
# Windows
set EMAIL_ADDRESS=your-email@gmail.com
set EMAIL_PASSWORD=your-app-password
To enable email notifications for triggered price alerts, you need to configure the `EmailService` by setting specific environment variables.
**For detailed instructions, please see the [Email Setup Guide](docs/EMAIL_SETUP.md).**

# Linux/Mac
export EMAIL_ADDRESS=your-email@gmail.com
export EMAIL_PASSWORD=your-app-password
```

2. **Or create `.streamlit/secrets.toml`:**
```toml
[email]
EMAIL_ADDRESS = "your-email@gmail.com"
EMAIL_PASSWORD = "your-app-password"
```
This setup is distinct from any email configuration that might be used by the `auth.py` module for features like password resets, which might use different environment variables or methods (e.g., `.streamlit/secrets.toml` if `auth.py` is designed to use Streamlit secrets for that purpose).

### Database Configuration
The application automatically creates a SQLite database in the `data/` directory. No additional configuration required.
The application automatically creates a SQLite database in the `data/` directory. No additional configuration is 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!
This application uses **Yahoo Finance (yfinance)** which provides free stock data without requiring any API keys or subscriptions.

## 📊 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
1. **Create an account** or login.
2. **Analyze stocks** by entering symbols.
3. **Add to portfolio** to track investments.
4. **Set up alerts** for price movements. If email is configured (see [Email Setup Guide](docs/EMAIL_SETUP.md)), you'll receive notifications.
5. **Explore technical analysis** and **AI-powered predictions**.

### Key Features
### Key Features (Summary)

#### 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
- Real-time data, charts, technical indicators, trading signals.

#### Portfolio Management
- Add holdings with purchase price and date
- Monitor real-time performance
- View allocation and returns
- Export data for external analysis
- Track holdings, performance, allocation. Export data.

#### Price Alerts
- Set price threshold alerts
- Configure percentage change notifications
- Receive email notifications (if configured)
- Track alert history and statistics
- Set price/percentage change alerts. Receive email notifications if configured.

#### Technical Analysis
- 15+ technical indicators
- Support and resistance levels
- Fibonacci retracement levels
- Advanced charting with multiple timeframes
- 15+ indicators, support/resistance, Fibonacci levels.

#### AI Predictions
- Machine learning price forecasting
- Multiple model options (Random Forest, Linear Regression)
- Customizable prediction timeframes
- Model accuracy metrics
- Models: Random Forest, Linear Regression, Gradient Boosting Regressor.
- Uses enhanced feature engineering with technical indicators.

## 📦 Deployment

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

1. Fork this repository
2. Go to [share.streamlit.io](https://share.streamlit.io)
3. Connect your GitHub account
4. Select your forked repository
5. Set the main file path to `enhanced_app.py` (or `app.py` for basic version)
1. Fork this repository.
2. Go to [share.streamlit.io](https://share.streamlit.io).
3. Connect your GitHub account and select your forked repository.
4. Set the main file path to `enhanced_app.py`.
5. Configure any necessary secrets (like those for email, if using) in the Streamlit Cloud settings for your app. Refer to the [Email Setup Guide](docs/EMAIL_SETUP.md) for the required environment variables.
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):

```toml
[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
**No API keys are required for core stock data functionality.**

## ❓ 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.
A: No! The app uses Yahoo Finance which provides free data without requiring API keys for fetching stock data.

**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: Do I need to set up email for alerts?**
A: No, email notifications for alerts are optional. If you wish to use this feature, refer to the [Email Setup Guide](docs/EMAIL_SETUP.md). The rest of the application functions without it.

**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](LICENSE) file for details.
```
Loading