Skip to content

Latest commit

 

History

History
295 lines (217 loc) · 8.23 KB

File metadata and controls

295 lines (217 loc) · 8.23 KB

AlphaFlow - Production Algorithmic Trading Platform

Version: 7.0.0 | Status: ✅ Production Ready | License: MIT

A professional, enterprise-grade algorithmic trading platform with automated strategy execution, multi-layer risk management, and real-time monitoring. Built for live trading with Alpaca Markets API.


🚀 Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Alpaca Markets account (Sign up free)

Installation

# 1. Clone repository
git clone https://github.com/The-Align-Project/Trading-Algorithm.git
cd Trading-Algorithm

# 2. Backend Setup
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

# 3. Configure API Keys
cp .env.example .env
# Edit .env with your Alpaca API keys

# 4. Frontend Setup
cd frontend
npm install
cd ..

Running the Platform

# Terminal 1 - Start Backend
source .venv/bin/activate
python3 -m uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000

# Terminal 2 - Start Frontend
cd frontend
npm run dev

Access: Open http://localhost:5173 in your browser


✨ Key Features

🤖 Automated Trading

  • 7 Production Strategies: MA Crossover, RSI Mean Reversion, Momentum, Mean Reversion, Multi-Timeframe Confluence, Volatility Breakout, Quick Test
  • Real-time Execution: Automated order placement via Alpaca API
  • Paper & Live Trading: Test strategies risk-free before going live
  • 24/7 Operation: Continuous strategy monitoring and execution

🛡️ Enterprise Risk Management

  • Multi-Layer Protection: Position, portfolio, and daily risk limits
  • Stop-Loss Automation: Automatic exits at 2x ATR below entry
  • Portfolio Heat Tracking: Maximum 25% of capital at risk
  • Correlation Limits: Maximum 15% in correlated assets (>0.7 correlation)
  • Daily Loss Limits: Auto-halt at 2% daily loss
  • Emergency Kill Switch: Instant stop all strategies with one click

📊 Monitoring & Alerts

  • Trade History Database: Complete audit trail (JSON persistence)
  • Email Notifications: Instant alerts for trades, stops, emergencies
  • Slack Integration: Team notifications via webhooks
  • System Health Monitoring: Real-time CPU, memory, API status
  • Performance Analytics: Win rate, P&L, profit factor, Sharpe ratio

💻 Professional UI

  • Bloomberg-Inspired Design: Dark theme, real-time data grids
  • 6 Specialized Pages: Dashboard, Trading, Strategies, Analytics, Backtest, Settings
  • Real-Time Updates: Live quotes, positions, P&L (5-second polling)
  • Trading Mode Indicator: Clear PAPER/LIVE mode badge
  • Emergency Controls: Always-visible stop button

📁 Project Structure

AlphaFlow/
├── backend/            # FastAPI server (17 files)
│   ├── api/            # 9 REST API endpoints
│   └── [modules]       # Strategy executor, risk management, notifications
├── core/               # Trading engine (9 essential modules)
│   ├── trading_engine.py
│   ├── indicators.py   # 20+ technical indicators
│   ├── backtester.py
│   └── [...]
├── frontend/           # React + TypeScript UI
│   ├── src/pages/      # 6 pages
│   ├── src/components/ # 4 components
│   └── [...]
├── docs/               # Complete documentation (10 guides)
├── .env.example        # Environment variables template
├── requirements.txt    # Python dependencies
└── README.md           # This file

📚 Documentation

Document Description
README_PRODUCTION.md Complete production guide - Quick start, features, API docs
DEPLOYMENT_CHECKLIST.md Step-by-step deployment - Setup, testing, go-live
LIVE_TRADING_READY.md Live trading features - Notifications, risk, monitoring
PROJECT_STRUCTURE.md Project organization - Every file explained
CONTRIBUTING.md Contribution guidelines

🎯 Trading Strategies

Recommended: Multi-Timeframe Confluence

Performance: +$14,035 (75% win rate, 1.08 Sharpe)

Analyzes daily, hourly, and intraday timeframes. Only trades when all align.

Momentum Strategy

Performance: +$25,351 (100% win rate, 1.85 Sharpe)

Follows strong price trends with momentum indicators.

RSI Mean Reversion

Performance: +$10,924 (75% win rate, 0.91 Sharpe)

Buy oversold, sell overbought based on RSI levels.

See docs/README_PRODUCTION.md for all 7 strategies


⚙️ Configuration

Environment Variables (.env)

Required:

ALPACA_API_KEY=your_key_here
ALPACA_SECRET_KEY=your_secret_here
ALPACA_PAPER=true  # true=paper, false=LIVE (real money!)

Risk Parameters (defaults are conservative):

MAX_POSITION_SIZE=0.10          # Max 10% per position
MAX_DAILY_LOSS=0.02             # Halt at 2% daily loss
MAX_PORTFOLIO_HEAT=0.25         # Max 25% at risk

Notifications (highly recommended):

SMTP_SERVER=smtp.gmail.com
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_app_password
EMAIL_TO=recipient@example.com

See .env.example for all options


🔒 Safety First

Before Live Trading

  • Test in paper mode for 2+ weeks
  • All strategies profitable in paper mode
  • Email notifications working
  • Emergency stop tested
  • Risk parameters configured correctly
  • Starting with small capital ($1k-$5k max)

NEVER Do This

  • ❌ Skip paper trading
  • ❌ Start with large capital
  • ❌ Trade without notifications
  • ❌ Ignore daily loss limits
  • ❌ Override emergency stops

⚠️ Live trading uses REAL MONEY. You can lose your entire investment. Past performance does not guarantee future results.


📊 API Documentation

REST API

Key Endpoints

GET  /api/system/health              # System health check
GET  /api/strategies/list            # Available strategies
POST /api/strategies/{id}/start      # Start strategy
POST /api/strategies/emergency-stop  # Emergency kill switch
GET  /api/positions/list             # Current positions
GET  /api/trades/history             # Trade history
GET  /api/trades/performance         # Performance stats

🧪 Testing

# Run backend tests
pytest tests/

# Check code quality
black backend/ core/
flake8 backend/ core/
mypy backend/ core/

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for:

  • Code style guidelines
  • Development setup
  • Pull request process
  • Testing requirements

📄 License

MIT License - see LICENSE file for details.


⚠️ Disclaimer

This software is for educational and informational purposes only.

  • Not financial advice
  • Trading involves substantial risk of loss
  • Past performance does not guarantee future results
  • You are solely responsible for your trading decisions
  • The authors/contributors are not liable for any losses
  • Use at your own risk

Always:

  • Start with paper trading
  • Never risk money you can't afford to lose
  • Understand the strategies before using them
  • Monitor your positions regularly
  • Set appropriate risk limits

📞 Support


🎉 Ready to Trade!

Production Checklist:

  • ✅ 7 automated strategies
  • ✅ Multi-layer risk management
  • ✅ Trade history & analytics
  • ✅ Email & Slack notifications
  • ✅ Emergency kill switch
  • ✅ System health monitoring
  • ✅ Paper & live trading modes
  • ✅ Professional Bloomberg-style UI

Start with paper trading, monitor closely, scale gradually!


Built with: Python • FastAPI • React • TypeScript • Alpaca Markets API

Version: 7.0.0 - Production Release

Last Updated: January 20, 2026

Status: ✅ FULLY PRODUCTION-READY FOR LIVE AUTOMATED TRADING