Skip to content

Latest commit

Β 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Algorithmic Trading System

AI-Assisted Strategy Development β€’ Backtesting β€’ Real-Time Trading Simulation


Market Data β†’ Strategy β†’ AI Analysis β†’ Decision β†’ Execution β†’ Monitoring

A full-stack algorithmic trading platform for developing strategies, backtesting historical market data, and running automated paper-trading simulations with AI-assisted analysis.


React Node.js Python MySQL


Docker WebSocket JWT Status


🧠 The Idea

This system brings the core algorithmic trading workflow into one platform:

╔══════════════════════════════════════════════════════════════╗
β•‘                                                              β•‘
β•‘     πŸ“Š MARKET DATA                                          β•‘
β•‘          β”‚                                                   β•‘
β•‘          β–Ό                                                   β•‘
β•‘     🧠 ALGORITHM                                             β•‘
β•‘          β”‚                                                   β•‘
β•‘          β–Ό                                                   β•‘
β•‘     πŸ€– AI ANALYSIS                                          β•‘
β•‘          β”‚                                                   β•‘
β•‘          β–Ό                                                   β•‘
β•‘     ⚑ TRADING DECISION                                      β•‘
β•‘          β”‚                                                   β•‘
β•‘          β–Ό                                                   β•‘
β•‘     πŸ’Ή ORDER / OUTPUT                                        β•‘
β•‘          β”‚                                                   β•‘
β•‘          β–Ό                                                   β•‘
β•‘     πŸ“ˆ MONITORING                                           β•‘
β•‘                                                              β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

The platform allows users to:

  • Create or select trading strategies
  • Configure trading rules
  • Backtest strategies using historical data
  • Analyze performance
  • Activate strategies
  • Generate automated trading signals
  • Simulate order execution
  • Monitor positions and trades
  • Use AI-assisted market analysis

πŸš€ Core Trading Loop

πŸ“Š β†’ 🧠 β†’ πŸ€– β†’ ⚑ β†’ πŸ’Ή β†’ πŸ“ˆ

Market Data β†’ Algorithm β†’ AI Analysis β†’ Decision β†’ Order β†’ Monitoring

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   MARKET DATA    β”‚
                    β”‚                  β”‚
                    β”‚ Historical / Liveβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ STRATEGY ENGINE  β”‚
                    β”‚                  β”‚
                    β”‚ Indicators       β”‚
                    β”‚ Conditions       β”‚
                    β”‚ Rules            β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   AI ANALYSIS    β”‚
                    β”‚                  β”‚
                    β”‚ Context          β”‚
                    β”‚ Risk             β”‚
                    β”‚ Explanation      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ TRADING DECISION β”‚
                    β”‚                  β”‚
                    β”‚ BUY / SELL / HOLDβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ TRADING ENGINE   β”‚
                    β”‚                  β”‚
                    β”‚ Risk Validation  β”‚
                    β”‚ Position Sizing  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ PAPER EXECUTION  β”‚
                    β”‚                  β”‚
                    β”‚ Simulated Orders  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   MONITORING     β”‚
                    β”‚                  β”‚
                    β”‚ P&L / Positions  β”‚
                    β”‚ Trades / Logs    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ What Makes It Different

πŸ”¬ Strategy First

Strategies can be created, configured, tested, and evaluated before activation.

πŸ“Š Data Driven

Historical and real-time market data feed the same trading workflow.

πŸ€– AI Assisted

AI analysis provides additional context around market conditions and strategy signals.

πŸ›‘οΈ Risk Aware

Risk controls are integrated into the trading engine instead of being treated as an afterthought.

⚑ Real-Time

WebSocket market feeds allow the dashboard to reflect trading activity as it happens.

πŸ§ͺ Paper Trading

The system simulates execution so strategies can be tested without placing real financial orders.


πŸ—οΈ System Architecture

                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚       FRONTEND        β”‚
                              β”‚                       β”‚
                              β”‚ React + Vite          β”‚
                              β”‚ Tailwind CSS          β”‚
                              β”‚ Dashboard             β”‚
                              β”‚ Strategy Builder      β”‚
                              β”‚ Backtesting           β”‚
                              β”‚ Analytics             β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
                                   REST / WebSocket
                                          β”‚
                                          β–Ό
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚       BACKEND         β”‚
                              β”‚                       β”‚
                              β”‚ Node.js + Express     β”‚
                              β”‚ JWT Authentication    β”‚
                              β”‚ REST API              β”‚
                              β”‚ WebSocket Server      β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                         β”‚                        β”‚
                β–Ό                         β–Ό                        β–Ό
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚   AI SERVICE     β”‚      β”‚ TRADING ENGINE   β”‚      β”‚    DATABASE     β”‚
      β”‚                  β”‚      β”‚                  β”‚      β”‚                 β”‚
      β”‚ FastAPI          β”‚      β”‚ Strategy Rules   β”‚      β”‚ MySQL           β”‚
      β”‚ Python           β”‚      β”‚ Signals          β”‚      β”‚                 β”‚
      β”‚ AI Analysis      β”‚      β”‚ Risk Controls    β”‚      β”‚ Users           β”‚
      β”‚ ML Hooks         β”‚      β”‚ Orders           β”‚      β”‚ Strategies      β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚ Trades          β”‚
                                                          β”‚ Positions       β”‚
                                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                   β”‚
                                                                   β–Ό
                                                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                        β”‚   MARKET DATA    β”‚
                                                        β”‚                  β”‚
                                                        β”‚ External API     β”‚
                                                        β”‚       or         β”‚
                                                        β”‚ Synthetic Data   β”‚
                                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧩 Architecture at a Glance

Component Technology Responsibility
πŸ–₯️ Frontend React + Vite + Tailwind Trading interface
βš™οΈ Backend Node.js + Express + TS API & orchestration
πŸ€– AI Service FastAPI + Python AI analysis
🧠 Trading Engine TypeScript worker Strategy execution
πŸ—„οΈ Database MySQL (fallback in-memory) Persistent data
⚑ Message Bus Redis (fallback in-memory) Engine ↔ server events
πŸ“‘ Market Data Binance / TwelveData / Synthetic Price feeds
🏦 Broker Adapter Paper + Alpaca (extensible) Order execution
πŸ” Authentication JWT + refresh tokens + 2FA User authentication
⚑ Real-Time WebSocket (authenticated) Live updates
🐳 Deployment Docker Compose (with engine worker) Service orchestration

πŸ“ˆ Trading Engine

The trading engine is responsible for converting strategy conditions into simulated trading actions.

Market Tick
     β”‚
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Data Update  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Indicators   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Strategy     β”‚
β”‚ Evaluation   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Signal       β”‚
β”‚ BUY/SELL/HOLDβ”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Risk Check   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Paper Order  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Position     β”‚
β”‚ Update       β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Portfolio    β”‚
β”‚ Analytics    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”¬ Backtesting Workflow

Before activating a strategy, it can be evaluated against historical market data.

              HISTORICAL DATA
                     β”‚
                     β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Select Asset β”‚
              β”‚ & Timeframe  β”‚
              β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Configure    β”‚
              β”‚ Strategy     β”‚
              β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Run          β”‚
              β”‚ Backtest     β”‚
              β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ Simulated Execution  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ Performance Analysis β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό              β–Ό
          ACCEPT          IMPROVE
              β”‚              β”‚
              β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
                NEXT TEST

πŸ€– AI-Assisted Analysis

The AI service provides additional context around market and strategy behavior.

Example

USER
"Why did my strategy generate a SELL signal?"

                 β”‚
                 β–Ό

        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚   AI SERVICE     β”‚
        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
        β”‚ Market Context   β”‚
        β”‚ Indicators       β”‚
        β”‚ Strategy Rules   β”‚
        β”‚ Risk Conditions  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β–Ό

        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ AI Explanation   β”‚
        β”‚                  β”‚
        β”‚ Signal Context   β”‚
        β”‚ Risk Factors     β”‚
        β”‚ Market Conditionsβ”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

AI is designed as decision support and analysis, rather than blindly controlling the trading engine.


πŸ›‘οΈ Risk Management

The platform includes several risk-management concepts:

  • Stop-loss
  • Take-profit
  • Position sizing
  • Maximum open trades
  • Strategy validation
  • Trade history
  • Activity logs
  • Backtesting before activation
  • Graceful market-data failure handling
                STRATEGY SIGNAL
                       β”‚
                       β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚  RISK CHECK  β”‚
               β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚                 β”‚
           PASS              FAIL
             β”‚                 β”‚
             β–Ό                 β–Ό
        EXECUTE             REJECT
          ORDER              SIGNAL

⚑ Real-Time Data

The platform uses WebSockets to deliver real-time updates between the trading engine and frontend.

              MARKET DATA
                   β”‚
                   β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Trading     β”‚
            β”‚ Engine      β”‚
            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
              WebSocket
                   β”‚
                   β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   Backend   β”‚
            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
              WebSocket
                   β”‚
                   β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚  Dashboard  β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

This allows the UI to reflect:

  • Live prices
  • Strategy signals
  • Orders
  • Position changes
  • Portfolio values
  • Trading activity

πŸ“ Repository Layout

algorithmic-trading-system/
β”‚
β”œβ”€β”€ database/
β”‚   └── schema.sql
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/            # REST endpoints (auth, strategies, bots, backtest,
β”‚   β”‚   β”‚                      #   market, marketplace, brokers, alerts, journal, trade)
β”‚   β”‚   β”œβ”€β”€ services/          # JS bridges to the TS market data layer
β”‚   β”‚   β”œβ”€β”€ modules/           # TypeScript core: indicators, risk, engine, bus,
β”‚   β”‚   β”‚                      #   market providers, broker adapters, totp
β”‚   β”‚   β”œβ”€β”€ data/              # mysql.js + memory.js stores
β”‚   β”‚   β”œβ”€β”€ config/            # DB/store wiring
β”‚   β”‚   β”œβ”€β”€ middleware/        # auth (JWT, pending-2FA)
β”‚   β”‚   β”œβ”€β”€ seed/              # marketplace seeding
β”‚   β”‚   β”œβ”€β”€ engine/            # standalone engine worker entrypoint
β”‚   β”‚   β”œβ”€β”€ test/              # vitest suites (indicators, risk, engine)
β”‚   β”‚   └── server.js
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── package.json
β”‚
β”œβ”€β”€ ai-service/
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ services/
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/        # Layout, CandleChart, StatCard, ProtectedRoute
β”‚   β”‚   β”œβ”€β”€ pages/             # Dashboard, Market, Strategies, StrategyBuilder,
β”‚   β”‚   β”‚                      #   Backtest, Bots, Marketplace, Brokers, Alerts,
β”‚   β”‚   β”‚                      #   Journal, Analytics, AIAssistant, Login, Register
β”‚   β”‚   β”œβ”€β”€ api/               # client.js (refresh tokens, WS token)
β”‚   β”‚   β”œβ”€β”€ context/           # AuthContext (2FA + refresh)
β”‚   β”‚   └── hooks/             # useWebSocket
β”‚   └── package.json
β”‚
β”œβ”€β”€ .github/workflows/ci.yml
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .env.example
└── README.md

πŸš€ Quick Start

1. Backend

cd backend
npm install
npm run dev

Port: 5000

Useful scripts:

npm run typecheck   # TypeScript type checking (tsc --noEmit)
npm test            # vitest suite (indicators, risk engine, backtest engine)
npm run engine      # run the trading engine as an external worker (uses Redis bus)

The backend automatically uses an in-memory database when MySQL is unavailable, and an in-memory message bus when Redis is unavailable.

For MySQL, configure the DB_* variables in:

backend/.env

Then import:

database/schema.sql

2. AI Service

cd ai-service

python -m venv .venv

Windows

.venv\Scripts\activate

macOS / Linux

source .venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Start FastAPI:

uvicorn main:app --reload --port 8000

Port: 8000


3. Frontend

cd frontend
npm install
npm run dev

Port: 5173

Open:

http://localhost:5173

🐳 Docker

Run the complete system (MySQL + Redis + backend + engine worker + AI + frontend) using Docker Compose:

docker compose up --build

Stop the services:

docker compose down

View running services:

docker compose ps

πŸ” Environment Configuration

Each service provides an .env.example.

Create the appropriate environment file:

cp .env.example .env

Typical configuration includes:

DATABASE_URL=
JWT_SECRET=
BROKER_ENC_KEY=

REDIS_URL=
ENGINE_EXTERNAL=1
ENGINE_INTERVAL_MS=15000

MARKET_DATA_API_KEY=
MARKET_DATA_API_BASE=
BINANCE_API_BASE=

AI_SERVICE_URL=

Never commit production secrets or API keys to the repository.


πŸ“Š Market Data

The system supports three data modes, with automatic fallback.

Synthetic Data

The default development mode generates synthetic candles so the system can operate without an external market-data provider.

Real Data

Providers are queried in priority order:

  • Binance (https://api.binance.com) β€” live candles and 24h tickers for crypto symbols (BTC, ETH, SOL, XRP, …)
  • TwelveData β€” stocks, ETFs and forex when MARKET_DATA_API_KEY is set
  • Synthetic fallback β€” used when no provider is available for a symbol
MARKET_DATA_API_KEY=
MARKET_DATA_API_BASE=https://api.twelvedata.com
BINANCE_API_BASE=https://api.binance.com

If an external provider fails, the system falls back to synthetic market data so the platform keeps running.


🏦 Broker Connectivity

Bots run in two modes:

  • Paper (default) β€” simulated execution against the built-in paper account
  • Live β€” routed through a connected broker adapter (Alpaca), gated by a connectivity test and a kill-switch (live_enabled)

Credentials are encrypted at rest (AES-256-GCM) using BROKER_ENC_KEY. A live bot cannot start unless its strategy passes riskEngine.validateForLive() (requires explicit stop-loss and position-sizing rules).


πŸ§ͺ Example User Journey

       REGISTER
          β”‚
          β–Ό
     DASHBOARD
          β”‚
          β–Ό
   SELECT STRATEGY
          β”‚
          β–Ό
   CONFIGURE RULES
          β”‚
          β–Ό
      BACKTEST
          β”‚
          β–Ό
   ANALYZE RESULTS
          β”‚
          β–Ό
      ACTIVATE
          β”‚
          β–Ό
   PAPER TRADING
          β”‚
          β–Ό
  MONITOR PERFORMANCE
          β”‚
          β–Ό
      AI ANALYSIS

πŸ“ˆ Performance Metrics

The platform can evaluate strategies using:

Metric Purpose
Total P&L Overall profitability
Win Rate Successful trade percentage
Profit Factor Gross profit vs. gross loss
Maximum Drawdown Largest portfolio decline
Sharpe Ratio Risk-adjusted performance
Total Trades Number of executed trades
Average Trade Average trade performance
Equity Curve Portfolio growth
Open Positions Current exposure

πŸ—ΊοΈ Development Roadmap

Phase 1 β€” Foundation

  • React frontend
  • Express backend
  • FastAPI AI service
  • JWT authentication
  • Database integration
  • Synthetic market data
  • WebSocket foundation

Phase 2 β€” Strategy Engine

  • Strategy creation
  • Strategy activation
  • Rule-based signals
  • Risk controls
  • Advanced strategy builder
  • Multi-strategy execution (bot ecosystem)

Phase 3 β€” Backtesting

  • Historical data workflow
  • Trade simulation
  • Performance metrics (Sortino, annualized, expectancy)
  • Fees, slippage and shorting simulation
  • Parameter optimization (grid search)
  • Walk-forward analysis
  • Strategy comparison

Phase 4 β€” AI

  • AI service
  • Market analysis
  • AI-assisted explanations
  • Context-aware recommendations
  • Advanced strategy analysis

Phase 5 β€” Platform Features

  • Trading bots (paper + live gating)
  • Bot marketplace with one-click install
  • Broker connections (Alpaca) with encrypted credentials
  • Price alerts
  • Trade journal
  • Two-factor authentication + refresh tokens
  • Redis message bus + external engine worker
  • CI/CD workflow
  • Monitoring & observability
  • Performance optimization

🧱 Engineering Principles

Modular

Each major responsibility is separated into its own service.

Testable

Strategies can be evaluated using historical data before activation.

Observable

Trading activity, orders, positions, and system events are tracked.

Resilient

External market-data failures do not immediately bring down the platform.

Explainable

AI analysis is intended to help users understand signals and market conditions.

Scalable

The architecture separates frontend, backend, AI, trading, and database responsibilities so individual services can evolve independently.


⚠️ Disclaimer

This project is intended for educational, research, and software-development purposes.

Paper trading and backtesting are simulations. Historical performance does not guarantee future results, and simulated execution may differ significantly from live market execution due to factors such as slippage, spreads, latency, liquidity, and market conditions.

AI-generated analysis should not be considered financial advice.

This system does not execute real-money trades by default.


⚑ MARKET β†’ ALGORITHM β†’ AI β†’ DECISION β†’ EXECUTION

Build strategies. Backtest ideas. Simulate markets.



Algorithmic Trading System

Built for algorithmic trading research, strategy development, and paper-trading simulation.

About

AI-assisted algorithmic trading platform for strategy development, backtesting, real-time market analysis, and automated paper-trading simulation.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages