A comprehensive AI-powered stock market analysis and trading signal prediction system that combines CNN and LSTM neural networks with technical analysis. The system includes real-time NEPSE (Nepal Stock Exchange) data scraping, pattern recognition, and both command-line and web interfaces.
- AI-Powered Predictions: CNN-LSTM hybrid model for trading signal generation
- Pattern Recognition: Candlestick pattern analysis using deep learning
- Technical Analysis: 15+ technical indicators (RSI, MACD, Moving Averages, etc.)
- Real-time Data: Live NEPSE market data scraping and analysis
- Multi-timeframe Analysis: Support for various timeframes and lookback periods
- Web Application: Modern, responsive web interface with Bootstrap 5
- CLI Tool: Command-line interface for batch processing and automation
- REST API: RESTful endpoints for integration with other systems
- NEPSE Integration: Real-time data from Nepal Stock Exchange
- Kaggle Datasets: Historical US stock and ETF data for training
- Custom Data Input: Support for manual OHLCV data entry
The system uses a sophisticated hybrid architecture:
- CNN Layer: Extracts local patterns from candlestick formations
- LSTM Layer: Captures temporal dependencies and market trends
- Technical Indicators: Enhanced feature engineering with 10+ indicators
- Ensemble Methods: Combines multiple prediction strategies
- Python 3.8 or higher
- pip package manager
- 4GB+ RAM (recommended for model training)
-
Clone the repository:
git clone https://github.com/sthaarwin/FNEPSE.git cd FNEPSE -
Install dependencies:
pip install -r requirements.txt
-
Download and preprocess data (optional - for training):
python src/data_loader.py python src/preprocess.py
Start the web interface:
python app.pyThen open your browser to http://localhost:5000
For the full-featured web app with real-time NEPSE data:
python web_app.pyAccess at http://localhost:5001
For direct predictions:
python trading_signal_predictor.pyMake predictions via REST API:
curl -X POST http://localhost:5000/predict \
-H "Content-Type: application/json" \
-d '{
"ohlcv_data": [
{"open": 100, "high": 105, "low": 98, "close": 103},
{"open": 103, "high": 107, "low": 101, "close": 106}
]
}'FNEPSE/
βββ app.py # Main Flask web application
βββ web_app.py # Enhanced web app with NEPSE integration
βββ trading_signal_predictor.py # Core prediction engine
βββ config.yaml # Configuration settings
βββ requirements.txt # Python dependencies
βββ data/ # Data storage
β βββ raw/ # Raw market data
β βββ processed/ # Cleaned datasets
β βββ preprocessed/ # Model-ready data
βββ models/ # Trained models
β βββ candlestick_cnn_lstm.h5 # Pattern recognition model
β βββ trading_signals_model.h5 # Trading signal model
β βββ scaler.pkl # Feature scaler
βββ scraper/ # NEPSE data scraper
β βββ nepse_scraper/ # Web scraping utilities
βββ src/ # Source code
β βββ data_loader.py # Data downloading and loading
β βββ preprocess.py # Data preprocessing pipeline
βββ notebooks/ # Jupyter notebooks
βββ templates/ # HTML templates
βββ static/ # Static web assets
βββ utils/ # Utility functions
The system generates three types of signals:
- BUY (2): Strong bullish indicators suggest potential upward movement
- HOLD (1): Mixed or neutral signals, maintain current position
- SELL (0): Bearish indicators suggest potential downward movement
Each prediction includes:
- Signal strength (0-2)
- Confidence score (0-1)
- Detailed explanation of factors
- Technical indicator analysis
The system analyzes multiple technical indicators:
- Trend: Moving Averages (5, 20), EMA (12, 26)
- Momentum: RSI, MACD, Stochastic Oscillator
- Volatility: Standard Deviation, Bollinger Bands
- Volume: Volume surge analysis
- Price Action: Support/Resistance levels, Price spreads
Customize the system behavior via config.yaml:
model:
lookback_period: 20
confidence_threshold: 0.7
trading:
risk_tolerance: "medium"
max_positions: 10
data:
update_frequency: "daily"
data_sources: ["nepse", "kaggle"]| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Web interface homepage |
/predict |
POST | Generate trading signal |
/market_data |
GET | Current NEPSE market data |
/predict_for_ticker |
POST | Predict for specific stock |
/recommendations |
GET | AI-generated stock recommendations |
/health |
GET | System health check |
- Past performance does not guarantee future results
- Always conduct your own research before making investment decisions
- Consider consulting with financial advisors for investment advice
- The developers are not responsible for any financial losses
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Nepal Stock Exchange (NEPSE) for market data
- Kaggle community for stock datasets
- TensorFlow and Keras teams for ML frameworks
- Flask community for web framework
- Author: Arwin Shrestha
- GitHub: @sthaarwin
- Project Link: https://github.com/sthaarwin/FNEPSE
Made with β€οΈ for the trading community