Skip to content

lumenworksco/AlphaFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

About

Algorithmic trading app for backtesting and live execution.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •