Overview
A full-stack machine learning application that applies Long Short-Term Memory (LSTM) neural networks to predict closing prices for Nepal Stock Exchange (NEPSE) securities. Built with a FastAPI backend and React frontend, it covers 100+ tickers with real historical market data.
Problem Solved
Standard neural networks treat each input independently. LSTMs maintain a memory of past time steps — critical for financial time series where historical price momentum directly influences future movement.
Key Modules
Data Collection & Cleaning
Raw NEPSE CSV data ingested, cleaned for missing values, and formatted for time-series processing using Pandas.
Feature Engineering
100-day and 200-day moving averages computed to give the model richer market context beyond raw closing prices.
Preprocessing & Scaling
MinMax scaling applied to normalize all inputs to [0,1] range. Sequences of 100-day lookback windows created for LSTM input format.
Model Training & Evaluation
LSTM built and trained via TensorFlow/Keras. Evaluated on held-out test data with MSE, RMSE, and R² metrics alongside prediction vs. actual price visualizations.
Multi-Day Forecasting
Recursive prediction strategy feeds each predicted price back into the model to generate 5-day forward price trajectories.
Secure REST API
FastAPI backend with JWT-based user authentication, protected prediction endpoints, and Matplotlib-generated charts served as static media.
Technical Architecture
The trained model is serialized as stock_prediction_model.keras and loaded at inference time without retraining. The FastAPI backend handles auth via python-jose and passlib, and serves all chart images through a mounted static media directory. React frontend consumes the API and renders interactive Recharts visualizations.
Design Language
Focus on data visualization clarity — Recharts on the frontend for interactive price charts, Matplotlib on the backend for server-rendered prediction overlays and moving average plots.