Skip to content

Sm3th/cryptopredict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CryptoPredict ๐Ÿ”ฎ

AI-powered cryptocurrency price forecasting with an active learning feedback loop.

CI Python FastAPI React TensorFlow License


โœจ Features

Feature Description
๐Ÿง  LSTM Model Multi-layer LSTM trained on historical price data with RSI, Bollinger Bands, and MA indicators
๐Ÿ“ˆ 7/14-day Forecast Autoregressive multi-step price prediction with confidence scoring
๐Ÿ’ฌ Active Learning User feedback loop that tracks model accuracy and triggers retraining
๐Ÿ“Š Live Metrics MAE, RMSE, and accuracy dashboard updated in real time
๐Ÿ”„ Auto-Retrain Background retraining triggered after every 50 feedback entries
๐ŸŒ CoinGecko API Free-tier market data โ€” no API key required
๐Ÿณ Docker Single-command full-stack deployment

๐Ÿ“ธ Screenshots

Add screenshots here after running the app locally.


๐Ÿ— Architecture

cryptopredict/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ main.py              # FastAPI application & REST endpoints
โ”‚   โ”œโ”€โ”€ train_model.py       # LSTM training pipeline (run once before API)
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ tests/
โ”‚       โ””โ”€โ”€ test_api.py
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx          # Main React application
โ”‚   โ”‚   โ”œโ”€โ”€ utils/api.js     # Typed API client
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/           # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ index.css        # Global styles
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ”œโ”€โ”€ nginx.conf
โ”‚   โ””โ”€โ”€ vite.config.js
โ”œโ”€โ”€ docker-compose.yml
โ””โ”€โ”€ .github/workflows/ci.yml

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 20+
  • (Optional) Docker & Docker Compose

Option 1 โ€” Docker (recommended)

git clone https://github.com/Sm3th/cryptopredict.git
cd cryptopredict

# 1. Train the model first (runs outside Docker to save the .keras file)
cd backend
pip install -r requirements.txt
python train_model.py --coin bitcoin --days 730

# 2. Spin up everything
cd ..
docker-compose up --build

Open http://localhost for the app, http://localhost:8000/docs for Swagger UI.


Option 2 โ€” Local development

Backend

cd backend
python -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install -r requirements.txt

# Train the model (required before starting the API)
python train_model.py --coin bitcoin --days 730

# Start API
uvicorn main:app --reload --port 8000

Frontend

cd frontend
npm install
npm run dev
# โ†’ http://localhost:5173

๐Ÿง  Model Details

Architecture

Input (60 ร— 1)
   โ†“
LSTM(128) โ†’ Dropout(0.2)
   โ†“
LSTM(64)  โ†’ Dropout(0.2)
   โ†“
LSTM(32)  โ†’ Dropout(0.2)
   โ†“
Dense(16, relu)
   โ†“
Dense(1)  โ† price prediction

Features used

Feature Description
price Daily closing price (normalized 0โ€“1)
MA_7 / MA_21 / MA_50 Moving averages
RSI Relative Strength Index (14-period)
BB_upper / BB_lower Bollinger Bands (20-period, ยฑ2ฯƒ)
volatility 7-day rolling std
momentum price โˆ’ price[โˆ’10]

Training configuration

Parameter Value
Lookback window 60 days
Train / Test split 80 / 20
Epochs 50 (early stopping, patience=10)
Batch size 32
Optimiser Adam
Loss MSE

๐Ÿ”Œ API Reference

Method Endpoint Description
GET / Health check
GET /api/health Detailed system status
POST /api/predict Run price forecast
POST /api/feedback Submit prediction feedback
POST /api/retrain Trigger background retraining
GET /api/metrics Model performance metrics
GET /api/feedback/history All feedback records
GET /api/coins Supported cryptocurrencies

Full interactive documentation: http://localhost:8000/docs

Example โ€” Predict

curl -X POST http://localhost:8000/api/predict \
  -H "Content-Type: application/json" \
  -d '{"coin_id": "bitcoin", "days": 7}'
{
  "coin_id": "bitcoin",
  "current_price": 67450.00,
  "predictions": [
    { "day": 1, "date": "2026-05-28", "price": 68120.50, "change_percentage": 0.99 },
    ...
  ],
  "confidence": 0.70,
  "sentiment": "Bullish",
  "sentiment_score": 72.4,
  "model_accuracy": 68.0
}

Example โ€” Feedback

curl -X POST http://localhost:8000/api/feedback \
  -H "Content-Type: application/json" \
  -d '{
    "prediction_id": "bitcoin_1234567890",
    "actual_price": 68000.00,
    "predicted_price": 68120.50,
    "date": "2026-05-28",
    "is_accurate": true
  }'

๐Ÿงช Tests

cd backend
pip install pytest httpx anyio
pytest tests/ -v

โš™๏ธ Environment Variables

Variable Default Description
ALLOWED_ORIGINS http://localhost:5173,... CORS allowed origins
MODEL_PATH crypto_lstm_model.keras Path to trained model
SCALER_PATH scaler.pkl Path to fitted scaler
VITE_API_URL /api API base URL (frontend)

๐Ÿ—บ Roadmap

  • Multi-coin comparison view
  • Sentiment analysis from Twitter/Reddit
  • Email alerts for large predicted swings
  • Model versioning & rollback
  • PostgreSQL for persistent feedback storage

โš ๏ธ Disclaimer

This project is built for educational purposes only. Cryptocurrency markets are highly volatile. Do not make financial decisions based on these predictions.


๐Ÿ“„ License

MIT ยฉ 2026 โ€” ฤฐsmet Organ

About

๐Ÿ”ฎ AI-powered cryptocurrency price forecasting using LSTM neural networks. Features a 7/14-day prediction model, real-time CoinGecko data, active learning feedback loop, and a trading-terminal UI. Built with FastAPI + React + TensorFlow.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors