Skip to content
AdityaBilPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title Aurelius Stock Predictor
emoji 📈
colorFrom green
colorTo blue
sdk gradio
app_file gradio_app.py
python_version 3.12
pinned false

Stock Price Movement Predictor

A web application that predicts short-term stock price movement (UP/DOWN) using a Conv1D-Transformer model trained on technical indicators and FinBERT news sentiment.

Features

  • 📈 3-day forward movement prediction with confidence score
  • 📰 Real-time news sentiment via FinBERT
  • 📊 Interactive charts with recent OHLCV data
  • 💹 35+ technical indicators (RSI, MACD, Bollinger Bands, ATR, etc.)
  • 🎨 Modern, responsive UI

Prerequisites

  • Python 3.8+
  • Trained model files (produced by train_v5.py):
    • stock_model.keras — Conv1D-Transformer model
    • scaler.pkl — RobustScaler fitted on training data
    • model_config.json — feature list, threshold, and hyperparameters
    • finbert_local/ (optional) — local FinBERT weights; falls back to ProsusAI/finbert from HuggingFace if missing

Installation

pip install -r requirements.txt

If you want hyperparameter tuning, also install:

pip install keras-tuner

Training the Model

If you don't have the model files yet, run the training script first:

python train_v5.py

This downloads stock data for 8 tickers (2018–2025), engineers features, optionally runs KerasTuner hyperparameter search, and saves all artifacts to the project directory.

Set RUN_TUNER = False in train_v5.py to skip tuning and use default hyperparameters.

Running the Gradio App

python gradio_app.py

Then open the local Gradio URL shown in the terminal.

Deploying to Hugging Face Spaces

Create a new Space with Gradio as the SDK and set the hardware to the free option available for your account (for a free personal account, this may be ZeroGPU). Upload the repository contents; the Space uses gradio_app.py as its entry point. The first boot downloads ProsusAI/finbert unless a local finbert/ directory is included.

The Space needs outbound network access at runtime for Yahoo Finance and GoogleNews. If either news source is unavailable, the app falls back to a zero sentiment score and still returns a price-based prediction.

Usage

  1. Enter a stock ticker (e.g. GOOGL, AAPL, NVDA)
  2. Click Predict
  3. View the UP/DOWN prediction with confidence percentage
  4. Check the price chart, recent OHLCV table, and sentiment breakdown

API Endpoints

Method Endpoint Description
GET / Main web interface
POST /api/predict Run prediction for a ticker
GET /api/stock-info Get basic stock info

POST /api/predict

// Request
{ "symbol": "GOOGL" }

// Response
{
  "symbol": "GOOGL",
  "prediction": "UP",
  "confidence": 0.72,
  "current_price": 175.4,
  "sentiment_score": 0.18,
  "articles_analysed": 12
}

GET /api/stock-info?symbol=GOOGL

Returns current price, volume, and 52-week high/low.

Project Structure

.
├── train_v5.py              # Training pipeline (Conv1D-Transformer + KerasTuner)
├── app.py                   # Flask backend
├── stock_model.keras        # Trained model (generated by train_v5.py)
├── scaler.pkl               # RobustScaler (generated by train_v5.py)
├── model_config.json        # Feature list, threshold, hyperparameters
├── finbert_local/           # Local FinBERT weights (optional)
├── templates/
│   └── index.html           # Main HTML template
├── static/
│   ├── css/
│   │   └── style.css
│   └── js/
│       └── main.js
├── requirements.txt
└── README.md

Model Details

Property Value
Architecture Conv1D stem + Transformer encoder
Training data 8 US tech stocks, 2018–2025
Features 35 technical indicators + FinBERT sentiment
Lookback window 20 trading days
Prediction target 3-day forward return > 0.5%
Loss function Focal loss (γ=2)
Threshold selection Youden's J-statistic
Scaler RobustScaler

Troubleshooting

  • Model not found — run train_v5.py first to generate stock_model.keras, scaler.pkl, and model_config.json
  • FinBERT missing — the app will fetch ProsusAI/finbert from HuggingFace automatically; ensure you have an internet connection on first run
  • News fetch fails — prediction still works; sentiment defaults to 0
  • Ticker not supported — the model was trained on large-cap US tech stocks; results on other sectors may be less reliable

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages