Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TradingLab - AI-Powered Trading Observer

A premium, real-time trading intelligence platform with AI-powered market predictions

Next.js Python PyTorch Docker License


πŸ“Έ Screenshots

Dashboard Overview

Real-time market monitoring with portfolio summary, live candlestick charts, market news feed, and active alerts panel.

Dashboard Overview

Market Analysis

Advanced technical analysis with price charts, SMA/RSI indicators, and AI-driven sentiment analysis.

Market Analysis

StockPredict - AI Watchlist

AI-powered stock predictions with LSTM neural network confidence scores and one-click trading.

StockPredict Watchlist


🌟 Overview

TradingLab is a professional-grade trading observability platform that combines real-time market data, technical analysis, and AI-powered LSTM predictions to provide traders with actionable intelligence. Built with a modern microservices architecture, it seamlessly integrates Next.js for the frontend, Node.js for real-time data streaming, and a dedicated Python ML service for deep learning predictions.

✨ Key Features

🎯 StockPredict Dashboard

  • AI Prediction Visualizer: Real-time confidence scores (0-100) with visual prediction bars
  • Live Market Data: WebSocket-powered price updates with sub-second latency
  • Smart Trading Interface: One-click Buy/Sell execution with position tracking
  • Portfolio Analytics: Real-time P&L, gainers/losers, and active stock monitoring

🧠 AI/ML Prediction Engine

  • LSTM Neural Network: PyTorch-based deep learning model for price prediction
  • Automated Training Pipeline: Historical data ingestion from Alpha Vantage
  • Confidence Scoring: Probabilistic predictions with uncertainty quantification
  • Microservice Architecture: Dedicated Python FastAPI service for ML workloads

πŸ“Š Technical Analysis

  • Multi-Indicator Analysis: RSI, MACD, SMA, Bollinger Bands
  • Health Score Algorithm: Composite scoring based on technical signals
  • Interactive Charts: D3.js candlestick charts with multiple timeframes
  • Volume & P/E Integration: Fundamental data alongside technical indicators

πŸ’Ό Trading Capabilities

  • Position Management: Track buy/sell orders with entry prices and timestamps
  • Trade Execution Dialog: Quantity input with real-time total calculation
  • Portfolio Persistence: JSON-based storage for trade history
  • Real-time Notifications: Toast alerts for successful trades

πŸ“° Market Intelligence

  • News Aggregation: Real-time financial news via Alpha Vantage
  • Sentiment Analysis: Automated bullish/bearish scoring
  • MCP Integration: Model Context Protocol for news streaming
  • Advanced Filtering: Search and filter by ticker, sentiment, or date

πŸ”” Smart Alerts

  • Price Triggers: Set "Above" or "Below" alerts for any ticker
  • Live Notifications: Instant dashboard notifications via WebSocket
  • Make.com Integration: Webhook support for external automation

🎨 User Experience

  • Dark/Light Themes: System-aware theme switching
  • Responsive Design: Optimized for desktop, tablet, and mobile
  • Profile Management: Customizable user profiles with avatars
  • Collapsible Sidebar: Adaptive navigation for maximum screen space

πŸ—οΈ Architecture

Microservices Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        TradingLab                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Frontend   │◄────►│   Backend    │◄────►│ ML Serviceβ”‚ β”‚
β”‚  β”‚  (Next.js)   β”‚      β”‚  (Node.js)   β”‚      β”‚ (Python) β”‚ β”‚
β”‚  β”‚  Port: 3000  β”‚      β”‚  Port: 3001  β”‚      β”‚Port: 8080β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚         β”‚                     β”‚                     β”‚      β”‚
β”‚         β”‚                     β”‚                     β”‚      β”‚
β”‚         β–Ό                     β–Ό                     β–Ό      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚              Alpha Vantage API                       β”‚ β”‚
β”‚  β”‚         (Market Data, News, Technical Indicators)    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

Frontend

  • Framework: Next.js 14 (App Router)
  • Styling: Tailwind CSS 4
  • UI Components: shadcn/ui
  • Charts: D3.js
  • State Management: React Hooks
  • WebSocket: Socket.io-client
  • Notifications: Sonner

Backend

  • Runtime: Node.js 18+
  • WebSocket Server: Socket.io
  • API Integration: Alpha Vantage SDK
  • MCP Client: Model Context Protocol
  • Caching: In-memory with TTL

ML Service

  • Framework: FastAPI
  • Deep Learning: PyTorch 2.0
  • Data Processing: Pandas, NumPy
  • Preprocessing: scikit-learn
  • Model: LSTM (Long Short-Term Memory)

Infrastructure

  • Containerization: Docker & Docker Compose
  • Orchestration: Multi-stage builds
  • Networking: Internal Docker network
  • Volumes: Hot-reloading for development

πŸš€ Getting Started

Prerequisites

Quick Start (Docker - Recommended)

  1. Clone the repository

    git clone https://github.com/yourusername/trading-observer.git
    cd trading-observer
  2. Configure environment variables

    # Create .env file in the root directory
    echo "ALPHA_VANTAGE_API_KEY=your_api_key_here" > .env
    echo "WS_PORT=3001" >> .env
  3. Start all services

    docker compose up -d --build
  4. Access the application

Manual Setup (Without Docker)

Frontend & Backend

# Install dependencies
npm install

# Start the WebSocket server
npm run server

# In a new terminal, start the frontend
npm run dev

ML Service

# Navigate to ML service directory
cd src/ml-service

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Start the ML service
uvicorn main:app --host 0.0.0.0 --port 8000

πŸ“ Project Structure

trading-observer/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                      # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ (dashboard)/          # Dashboard routes
β”‚   β”‚   β”‚   β”œβ”€β”€ watchlist/        # StockPredict page
β”‚   β”‚   β”‚   β”œβ”€β”€ market/           # Market analysis
β”‚   β”‚   β”‚   β”œβ”€β”€ forecasting/      # AI predictions
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts/           # Alert management
β”‚   β”‚   β”‚   └── news/             # News feed
β”‚   β”‚   └── api/                  # API routes
β”‚   β”‚       β”œβ”€β”€ forecasting/      # Prediction endpoint
β”‚   β”‚       β”œβ”€β”€ market/           # Market data
β”‚   β”‚       └── positions/        # Trade management
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ layout/               # Dashboard layout
β”‚   β”‚   β”œβ”€β”€ watchlist/            # StockCard, TradeDialog
β”‚   β”‚   β”œβ”€β”€ market/               # Charts, analysis
β”‚   β”‚   β”œβ”€β”€ providers/            # Context providers
β”‚   β”‚   └── ui/                   # shadcn components
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ market-service.ts     # Alpha Vantage client
β”‚   β”‚   └── forecasting-service.ts # Technical analysis
β”‚   └── ml-service/               # Python ML Service
β”‚       β”œβ”€β”€ main.py               # FastAPI app
β”‚       β”œβ”€β”€ model.py              # LSTM architecture
β”‚       β”œβ”€β”€ train.py              # Training pipeline
β”‚       β”œβ”€β”€ data_loader.py        # Data fetching
β”‚       β”œβ”€β”€ requirements.txt      # Python dependencies
β”‚       └── Dockerfile            # ML service container
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ index.js                  # WebSocket server
β”‚   └── mcp-client.js             # MCP integration
β”œβ”€β”€ docker-compose.yml            # Multi-service orchestration
β”œβ”€β”€ Dockerfile                    # Frontend/Backend container
└── README.md                     # This file

πŸ§ͺ ML Model Training

Training a Model for a Specific Stock

# Access the ML service container
docker exec -it trading-observer-ml bash

# Train the model (example: Apple Inc.)
python train.py --symbol AAPL

# The trained model will be saved to:
# artifacts/AAPL_model.pth
# artifacts/AAPL_scaler.pkl

Training Parameters

The LSTM model uses the following hyperparameters (configurable in train.py):

  • Sequence Length: 60 days (look-back window)
  • Hidden Dimensions: 50
  • LSTM Layers: 2
  • Epochs: 20
  • Batch Size: 32
  • Learning Rate: 0.001
  • Train/Test Split: 80/20

Model Architecture

Input (60 days of price data)
    ↓
LSTM Layer 1 (50 hidden units)
    ↓
LSTM Layer 2 (50 hidden units)
    ↓
Fully Connected Layer
    ↓
Output (Next day price prediction)

πŸ”Œ API Reference

Frontend API Routes

GET /api/forecasting?symbol={TICKER}

Returns AI prediction and technical analysis for a stock.

Response:

{
  "symbol": "AAPL",
  "healthScore": 72,
  "recommendation": "BUY",
  "signals": {
    "rsi": "neutral",
    "macd": "bullish",
    "sma": "bullish"
  },
  "technicalData": {
    "rsi": 55.2,
    "macd": 1.23,
    "sma": 188.5,
    "price": 189.17,
    "volume": "52340000",
    "peRatio": 28.5
  }
}

POST /api/positions

Creates a new trade position.

Request:

{
  "symbol": "AAPL",
  "type": "buy",
  "quantity": 10,
  "entryPrice": 189.17
}

ML Service API

GET /health

Health check endpoint.

Response:

{
  "status": "healthy"
}

POST /predict (Future Implementation)

Request prediction for a stock.

Request:

{
  "symbol": "AAPL",
  "days": 1
}

🐳 Docker Configuration

Services

Service Port Description
frontend 3000 Next.js application
backend 3001 WebSocket server
ml-service 8080 Python ML API

Volume Mounts

  • ./src/ml-service:/app - Hot-reloading for ML service development
  • ./positions.json:/app/positions.json - Trade persistence

Environment Variables

Create a .env file in the root directory:

# Required
ALPHA_VANTAGE_API_KEY=your_api_key_here

# Optional
WS_PORT=3001
PORT=8000  # ML service internal port

πŸ›£οΈ Roadmap

Phase 1: Foundation βœ…

  • Real-time market data streaming
  • Technical analysis indicators
  • StockPredict dashboard
  • Trading functionality
  • ML service infrastructure

Phase 2: AI Integration βœ…

  • LSTM model architecture
  • Training pipeline
  • Connect ML predictions to frontend
  • Real-time inference API
  • Model versioning and A/B testing

Phase 3: Advanced Features

  • Multi-asset portfolio optimization
  • Backtesting engine
  • Risk management tools
  • Social trading features
  • Mobile app (React Native)

Phase 4: Enterprise

  • Multi-user support
  • Role-based access control
  • Advanced charting (TradingView integration)
  • Broker API integration (Alpaca, Interactive Brokers)
  • Cloud deployment (AWS/GCP)

🀝 Contributing

Contributions are welcome! Please follow these steps:

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

πŸ“„ License

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


πŸ™ Acknowledgments

  • Alpha Vantage for market data API
  • shadcn/ui for beautiful UI components
  • PyTorch team for the deep learning framework
  • Next.js team for the amazing React framework

πŸ“§ Contact

For questions or support, please open an issue on GitHub.


Built with ❀️ by the TradingLab Team

⭐ Star this repo if you find it useful!

About

TradingLab is a premium (MVP stage), real-time trading observability dashboard designed for professional traders.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages