Skip to content

sthaarwin/FNEPSE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FNEPSE - Stock Market Analyzer & Predictor

Python TensorFlow Flask License

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.

πŸš€ Features

Core Functionality

  • 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

Interfaces

  • 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

Data Sources

  • 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

πŸ“Š Model Architecture

The system uses a sophisticated hybrid architecture:

  1. CNN Layer: Extracts local patterns from candlestick formations
  2. LSTM Layer: Captures temporal dependencies and market trends
  3. Technical Indicators: Enhanced feature engineering with 10+ indicators
  4. Ensemble Methods: Combines multiple prediction strategies

πŸ› οΈ Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • 4GB+ RAM (recommended for model training)

Quick Setup

  1. Clone the repository:

    git clone https://github.com/sthaarwin/FNEPSE.git
    cd FNEPSE
  2. Install dependencies:

    pip install -r requirements.txt
  3. Download and preprocess data (optional - for training):

    python src/data_loader.py
    python src/preprocess.py

πŸš€ Usage

Web Application

Start the web interface:

python app.py

Then open your browser to http://localhost:5000

Enhanced Web App with NEPSE Integration

For the full-featured web app with real-time NEPSE data:

python web_app.py

Access at http://localhost:5001

Command Line Interface

For direct predictions:

python trading_signal_predictor.py

API Usage

Make 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}
    ]
  }'

πŸ“ Project Structure

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

🎯 Trading Signals

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

πŸ“ˆ Technical Indicators

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

πŸ”§ Configuration

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"]

🚦 API Endpoints

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

πŸ”’ Risk Warning

⚠️ Important Disclaimer: This tool is for educational and research purposes only.

  • 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

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

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

πŸ™ Acknowledgments

  • Nepal Stock Exchange (NEPSE) for market data
  • Kaggle community for stock datasets
  • TensorFlow and Keras teams for ML frameworks
  • Flask community for web framework

πŸ“§ Contact


Made with ❀️ for the trading community

About

stock market analyzer and predictor using CNN and LSTM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors