Skip to Content
All memories

Building NeuroTradeX — Architecting an AI-Driven Trading System

 — #AI#Trading#Crypto#Fintech#Engineering#Rust#Python

NeuroTradeX Architecture

NeuroTradeX is an advanced, modular trading platform designed for real-time, explainable AI in financial and crypto markets. It was built with a focus on transparency, security, extensibility, and performance — combining technologies like LSTM, Transformers, SHAP, WebSocket streaming, Dockerized services, and real exchange integrations.


⚙️ System Overview

At its core, NeuroTradeX is composed of 5 decoupled services:

  1. data-core: feature pipelines, OHLCV ingestion, sentiment processing via LLMs
  2. model-engine: deep learning prediction using LSTM, Transformer, and SHAP explanations
  3. exec-core: real or simulated execution (Binance, paper trading), with risk controls
  4. dashboard-ui: live Next.js UI to monitor model confidence, signal history, logs
  5. alert-system: async, multi-channel alerts via Telegram, Discord, and Webhooks

The entire system is open-source and hosted at: 🔗 gitlab.com/neurotradex


🧱 Modular Architecture

Each module runs independently, communicates through structured JSON files or WebSocket streams, and is deployable via Docker Compose or Kubernetes.


📊 Data Pipeline Highlights

The data-core module is responsible for ingesting:

  • OHLCV data from Binance/Bybit

  • Sentiment/news data from CoinDesk, Yahoo, Twitter

  • Feature engineering with ta-lib, including:

    • RSI, MACD, Bollinger Bands, OBV, ATR, and custom signals
  • Embedding of textual data using sentence-transformers and LLMs

technicals.py
def compute_macd(df):
    macd = df['close'].ewm(span=12).mean() - df['close'].ewm(span=26).mean()
    signal = macd.ewm(span=9).mean()
    return macd, signal

🧠 AI Modeling: model-engine

This module provides both supervised learning and interpretable AI via:

  • LSTM and Autoformer for time series prediction
  • SHAP values and LIME for feature attribution
  • Support for both:
    • static offline training
    • or online/streaming signal classification
shap_wrapper.py
explainer = shap.Explainer(model, sample_data)
shap_values = explainer(data_point)
shap.plots.waterfall(shap_values[0])

All models export signal objects in a common schema for consumption by the exec-core.


🛡️ Execution Engine: exec-core

Built with security and precision in mind, this module handles:

  • Signal validation
  • Risk checking (drawdown cap, dynamic sizing)
  • Execution via real APIs (Binance) or paper simulation
  • CLI and Telegram fallback approvals
trade_executor.py
if risk_manager.validate(signal):
    executor.place_order(signal.asset, signal.side, size)
else:
    fallback.notify(signal, reason="risk_threshold_breached")

Trade logs and decisions are timestamped and persisted locally.


📺 UI: dashboard-ui

Written in Next.js + Tailwind, the dashboard:

  • Streams signal flow and execution feedback
  • Shows confidence metrics and model explanations
  • Uses TradingView for OHLCV chart overlays
  • Offers real-time logs and theming (dark/light)
LiveChart.tsx
<LightweightChart
  data={ohlcv}
  signals={executedSignals}
  overlays={shapAttributions}
/>

🔔 Real-Time Notifications: alert-system

This service asynchronously pushes alerts to:

  • Telegram channels
  • Discord webhooks
  • Any custom webhook endpoint

It uses jinja2 templating, retries, exponential backoff, and tokenized configs via .env.

telegram_alert.py
def send(signal: TradeSignal):
    message = render_template("signal_message.md", signal)
    bot.send_message(chat_id=chat, text=message, parse_mode="Markdown")

Logs are grouped by date in /logs/alerts/YYYY-MM-DD.log.


🧪 Testing & CI/CD

Each module is:

  • Fully unit-tested via pytest or jest
  • Integrated into .gitlab-ci.yml for linting, security checks, and test execution
  • Built for containerized environments with Docker and optional support for Kubernetes Helm charts

🌍 Final Thoughts

Developing NeuroTradeX was an exercise in bringing together:

  • Machine learning
  • Financial engineering
  • Distributed systems
  • Explainability
  • Human-in-the-loop design

Its open-source nature allows contributors, researchers, and traders to explore, extend, and build upon a transparent architecture built for reliability and real-world applicability.

Whether you're working in DeFi, TradFi, or AI-driven quantitative systems, NeuroTradeX provides a foundation ready to grow.

Repository: gitlab.com/neurotradex