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.
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
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 β
ββββββββββββββββββββ
Strategies can be created, configured, tested, and evaluated before activation.
Historical and real-time market data feed the same trading workflow.
AI analysis provides additional context around market conditions and strategy signals.
Risk controls are integrated into the trading engine instead of being treated as an afterthought.
WebSocket market feeds allow the dashboard to reflect trading activity as it happens.
The system simulates execution so strategies can be tested without placing real financial orders.
βββββββββββββββββββββββββ
β 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 β
ββββββββββββββββββββ
| 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 |
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 β
ββββββββββββββββ
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
The AI service provides additional context around market and strategy behavior.
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.
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
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
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
cd backend
npm install
npm run devPort: 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
cd ai-service
python -m venv .venv.venv\Scripts\activatesource .venv/bin/activateInstall dependencies:
pip install -r requirements.txtStart FastAPI:
uvicorn main:app --reload --port 8000Port: 8000
cd frontend
npm install
npm run devPort: 5173
Open:
http://localhost:5173
Run the complete system (MySQL + Redis + backend + engine worker + AI + frontend) using Docker Compose:
docker compose up --buildStop the services:
docker compose downView running services:
docker compose psEach service provides an .env.example.
Create the appropriate environment file:
cp .env.example .envTypical 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.
The system supports three data modes, with automatic fallback.
The default development mode generates synthetic candles so the system can operate without an external market-data provider.
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_KEYis 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.comIf an external provider fails, the system falls back to synthetic market data so the platform keeps running.
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).
REGISTER
β
βΌ
DASHBOARD
β
βΌ
SELECT STRATEGY
β
βΌ
CONFIGURE RULES
β
βΌ
BACKTEST
β
βΌ
ANALYZE RESULTS
β
βΌ
ACTIVATE
β
βΌ
PAPER TRADING
β
βΌ
MONITOR PERFORMANCE
β
βΌ
AI ANALYSIS
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 |
- React frontend
- Express backend
- FastAPI AI service
- JWT authentication
- Database integration
- Synthetic market data
- WebSocket foundation
- Strategy creation
- Strategy activation
- Rule-based signals
- Risk controls
- Advanced strategy builder
- Multi-strategy execution (bot ecosystem)
- Historical data workflow
- Trade simulation
- Performance metrics (Sortino, annualized, expectancy)
- Fees, slippage and shorting simulation
- Parameter optimization (grid search)
- Walk-forward analysis
- Strategy comparison
- AI service
- Market analysis
- AI-assisted explanations
- Context-aware recommendations
- Advanced strategy analysis
- 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
Each major responsibility is separated into its own service.
Strategies can be evaluated using historical data before activation.
Trading activity, orders, positions, and system events are tracked.
External market-data failures do not immediately bring down the platform.
AI analysis is intended to help users understand signals and market conditions.
The architecture separates frontend, backend, AI, trading, and database responsibilities so individual services can evolve independently.
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.