Skip to content

A deep learning framework for stock price prediction and forecasting with LSTMs, featuring evaluation metrics, residual analysis, volatility indicators, and visualization tools.

Notifications You must be signed in to change notification settings

blkpvnthr/deepstock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

28 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DeepStock๐Ÿ“Š

DeepStock is a deep learning framework for stock price prediction and forecasting using LSTMs and feature engineering.
It supports training, evaluation, and visualization of model performance with residuals, loss curves, and volatility indicators.

Training Forecast GIF

Features

  • Preprocessing with MinMaxScaler and rolling features (MA10, MA20, MA50, returns).

  • Sequence generation for supervised learning on time series.

  • LSTM-based forecasting with:

    • Model checkpointing
    • Early stopping & learning rate scheduling
  • Evaluation metrics:

    • MAE, RMSE, Rยฒ, MAPE
    • Directional Accuracy (%)
    • Bias correction
  • Visualizations:

    • Actual vs. Predicted prices with forecasts
    • Residuals (Actual โˆ’ Predicted)
    • Smoothed training/validation loss curves
    • Volatility indicators (rolling std & Bollinger Band width)

๐Ÿ“‚ Project Structure

deepstock/
โ”‚
โ”œโ”€โ”€ data/                  # input stock data (CSV or yfinance)
โ”‚
โ”œโ”€โ”€ checkpoints/           # saved models (.keras)
โ”‚
โ”œโ”€โ”€ results/               # predictions, plots, forecasts
โ”‚   โ”œโ”€โ”€ predictions.csv
โ”‚   โ”œโ”€โ”€ future_predictions_60d.csv
โ”‚   โ”œโ”€โ”€ future_predictions_*_6m.csv
โ”‚   โ””โ”€โ”€ plots/
โ”‚
โ”œโ”€โ”€ images/                # example plots & animations
โ”‚   โ”œโ”€โ”€ example1.png
โ”‚   โ””โ”€โ”€ example2.gif
โ”‚
โ”œโ”€โ”€ prediction.py          # main training + forecasting loop
โ”œโ”€โ”€ requirements.txt       # dependencies
โ””โ”€โ”€ README.md              # project docs

Installation

Clone the repo:

git clone https://github.com/blkpvnthr/deepstock.git
cd deepstock

Create a virtual environment:

macOS/Linux

python -m venv .venv
source .venv/bin/activate

Windows

.venv\Scripts\activate

Install dependencies:

pip install -r requirements.txt

Usage

  1. Run training + forecasting
   python prediction.py

This will:

  • Train or load an existing model per ticker.
  • Save checkpoints to checkpoints/.
  • Generate predictions and forecasts (60-day & 6-month).
  • Save plots into results/plots/.

Example Output

Actual + Predictions + Forecasts Residuals & Loss Curves Volatility Indicators

๐Ÿ“Š Example Metrics

CGNX Evaluation Metrics:
MAE   : 0.0621
RMSE  : 0.0717
Rยฒ    : -1.1457
MAPE  : 48.67%
Directional Accuracy: 46.81%
Bias Correction: +1.235

Actual + Predictions + Forecasts

Forecast


๐Ÿ›  Requirements

Python 3.10+ pandas numpy scikit-learn matplotlib tensorflow / keras

Install them with:

pip install -r requirements.txt

๐Ÿ”ฎ Roadmap

Add hyperparameter tuning
Integrate additional technical indicators
Support transformer-based time-series models


๐Ÿ“œ License

MIT License. Feel free to fork and adapt for your own trading experiments ๐Ÿš€


โœจ Acknowledgements

Inspired by real-world quantitative finance research and experimentation with deep learning on market data.

About

A deep learning framework for stock price prediction and forecasting with LSTMs, featuring evaluation metrics, residual analysis, volatility indicators, and visualization tools.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages