🔧 Project Overview
This is a multi-user stock market prediction system that uses machine learning to forecast the next n candlestick patterns (bullish/bearish) for different users. The system integrates with Yahoo Finance, Alpha Vantage, and Polygon.io APIs to fetch real-time and historical candlestick data.
- Multi-User Support: Each user can configure their own prediction settings
- Multiple Data Sources: Yahoo Finance, Alpha Vantage, Polygon.io APIs
- Flexible Timeframes: 1min, 5min, 1h, 1d, 1w, 1mo
- ML Models: LSTM, CNN, RNN, and Hybrid models
- Real-time Charts: Interactive candlestick charts with technical indicators
- Performance Metrics: Accuracy, MAE, RMSE, MAPE tracking
- Export Functionality: CSV/PDF export of predictions
NEW_CANDLES/
├── backend/
│ ├── app.py # Flask application entry point
│ ├── config.py # Configuration settings
│ ├── requirements.txt # Python dependencies
│ ├── models/
│ │ ├── __init__.py
│ │ ├── lstm_model.py # LSTM implementation
│ │ ├── cnn_model.py # CNN implementation
│ │ ├── rnn_model.py # RNN implementation
│ │ └── hybrid_model.py # Hybrid model combining all
│ ├── data/
│ │ ├── __init__.py
│ │ ├── data_collector.py # API data collection
│ │ ├── preprocessor.py # Data preprocessing
│ │ └── storage.py # Database operations
│ ├── api/
│ │ ├── __init__.py
│ │ ├── yahoo_finance.py # Yahoo Finance API
│ │ ├── alpha_vantage.py # Alpha Vantage API
│ │ └── polygon_api.py # Polygon.io API
│ ├── ml/
│ │ ├── __init__.py
│ │ ├── trainer.py # Model training pipeline
│ │ ├── predictor.py # Prediction engine
│ │ └── evaluator.py # Performance evaluation
│ ├── auth/
│ │ ├── __init__.py
│ │ ├── user_manager.py # User authentication
│ │ └── session_manager.py # Session management
│ └── utils/
│ ├── __init__.py
│ ├── helpers.py # Utility functions
│ └── validators.py # Input validation
├── frontend/
│ ├── public/
│ │ ├── index.html
│ │ └── favicon.ico
│ ├── src/
│ │ ├── components/
│ │ │ ├── Auth/
│ │ │ ├── Dashboard/
│ │ │ ├── Charts/
│ │ │ ├── UserConfig/
│ │ │ └── Performance/
│ │ ├── services/
│ │ ├── utils/
│ │ ├── App.js
│ │ └── index.js
│ ├── package.json
│ └── package-lock.json
├── database/
│ ├── init.sql # Database schema
│ └── migrations/
├── docs/
│ ├── API.md # API documentation
│ ├── MODELS.md # ML models documentation
│ └── DEPLOYMENT.md # Deployment guide
└── tests/
├── backend/
└── frontend/
- Framework: Flask (Python)
- Database: SQLite/PostgreSQL
- ML Libraries: TensorFlow/Keras, scikit-learn, pandas, numpy
- APIs: yfinance, alpha_vantage, polygon-api-client
- Authentication: Flask-Login, JWT
- Framework: React.js
- Charts: Chart.js, TradingView Lightweight Charts
- UI Library: Material-UI
- State Management: Redux/Context API
- HTTP Client: Axios
- Python 3.8+
- Node.js 14+
- npm or yarn
cd backend
pip install -r requirements.txt
python app.py
cd frontend
npm install
npm start
- Best for sequential time series data
- Handles long-term dependencies
- Good for trend prediction
- Excellent for pattern recognition
- Identifies local features in candlestick patterns
- Fast training and inference
- Basic sequential model
- Good baseline for comparison
- Lightweight and fast
- Combines LSTM, CNN, and RNN
- Ensemble approach for better accuracy
- Weighted predictions from all models
Create a .env
file in the backend directory:
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key
POLYGON_API_KEY=your_polygon_key
SECRET_KEY=your_flask_secret_key
DATABASE_URL=sqlite:///candles.db
- Data Provider: Yahoo Finance, Alpha Vantage, Polygon.io
- Company: Any valid stock symbol (MSFT, AAPL, TSLA, etc.)
- Timeframe: 1min, 5min, 15min, 30min, 1h, 4h, 1d, 1w, 1mo
- Prediction Count: 1-50 future candlesticks
- ML Model: LSTM, CNN, RNN, or Hybrid
- Accuracy: Percentage of correct directional predictions
- MAE: Mean Absolute Error
- RMSE: Root Mean Square Error
- MAPE: Mean Absolute Percentage Error
- Sharpe Ratio: Risk-adjusted returns
- Win Rate: Percentage of profitable predictions
- User Configuration: User selects API, symbol, timeframe, and model
- Data Collection: System fetches historical data from chosen API
- Preprocessing: Data cleaning, normalization, and feature engineering
- Model Training: Train selected ML model on historical data
- Prediction: Generate next n candlestick predictions
- Visualization: Display results on interactive charts
- Evaluation: Calculate and display performance metrics
- User registration and login
- Session management
- Password reset functionality
- Multi-user support
- Individual user configurations
- User-specific model performance tracking
- Interactive candlestick charts
- Zoom and pan functionality
- Technical indicators overlay (MACD, RSI, EMA)
- Predicted vs actual comparison
- Real-time metrics dashboard
- Model comparison tables
- Performance history tracking
- Best model recommendations
- CSV export of predictions
- PDF reports generation
- Historical data download
# Backend tests
cd backend
python -m pytest tests/
# Frontend tests
cd frontend
npm test
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This system is for educational and research purposes only. Stock market predictions are inherently risky, and past performance does not guarantee future results. Always consult with financial advisors before making investment decisions.