This repository contains scripts for a Stock Prediction App designed to predict stock prices 10 days into the future. The app uses a combination of machine learning models, technical indicators, and historical stock data to evaluate and predict stock price movements. It also incorporates a system to check predictions against real market behavior and provides insights for trading decisions.
-
Data Fetching and Preprocessing:
- Automatically fetches historical stock data for selected tickers.
- Prepares datasets with lead features and technical indicators.
-
Machine Learning Models:
- Utilizes multiple machine learning algorithms:
- Random Forest Regressor
- Linear Regression
- XGBoost
- LightGBM
- Selects the best-performing model based on RMSE for predictions.
- Utilizes multiple machine learning algorithms:
-
Prediction Evaluation:
- Predicts stock closing prices 10 days into the future.
- Evaluates success based on target price and stop-loss thresholds.
-
Post-Prediction Analysis:
- Analyzes stock behavior after predictions to determine profit/loss potential.
- Provides success rates and trading insights for each stock.
-
Daily Automation:
- Designed for daily automated execution to keep predictions up-to-date.
- The app fetches historical stock data for a defined list of tickers using the Yahoo Finance API.
- It identifies missing trading dates to ensure up-to-date datasets.
- Generates lead features and technical indicators (e.g., Stochastic RSI, Williams %R, ROC).
- Prepares datasets for model training and testing.
- Trains multiple models using historical data.
- Selects the best model based on evaluation metrics.
- Predicts closing prices 10 days ahead for all tickers.
- Stores predictions in a structured CSV file.
- Evaluates if predicted prices hit target or stop-loss thresholds.
- Provides insights into overall and ticker-specific success rates.
- Clone the Repository:
git clone https://github.com/your-username/stock-prediction-app.git cd stock-prediction-app
- Install Requirements:
pip install -r requirements.txt
-
Run the Prediction Script
python scripts/stock_prediction.py
-
Evaluate Predictions
python scripts/check_price.py
-
Automate with a Scheduler
Use cron (Linux/Mac) or Task Scheduler (Windows) to run the scripts daily.
Key Parameters
Tickers: Defined in stock_prediction.py.
Prediction Window: Default is 10 days ahead.
Historical Data Window: Uses the last 365 days for analysis.
Planned Enhancements
Add more ML models to improve prediction accuracy.
Include real-time data fetching for live trading recommendations.
Create dashboards for better visualization of predictions and results.
Enhance feature engineering with additional technical indicators.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for bug fixes or feature enhancements. License
This project is licensed under the MIT License. See LICENSE for more details. Acknowledgments
Libraries Used:
Pandas
NumPy
Scikit-learn
XGBoost
LightGBM
Yahoo Finance (yfinance)