Skip to content

lumenworksco/AlphaFlow

Repository files navigation

πŸš€ AlphaFlow v7.0 - Professional Trading Platform

A professional algorithmic trading platform built with FastAPI + React + TypeScript.

✨ Features

  • πŸ“Š Real-time Market Data - Live quotes and WebSocket streaming
  • πŸ’Ό Portfolio Management - Track positions, P&L, and performance
  • πŸ“ˆ Advanced Charting - Professional charts with Recharts
  • πŸ€– Strategy Automation - Deploy and manage trading algorithms
  • πŸ“‰ Backtesting - Test strategies on historical data
  • 🎨 Bloomberg-Inspired UI - Clean, professional dark theme
  • ⚑ Fast & Modern - FastAPI backend, React frontend with Vite

πŸ—οΈ Architecture

Backend (FastAPI)

  • Framework: FastAPI (Python 3.10+)
  • Real-time: WebSocket for live data streaming
  • Trading: Alpaca API integration
  • Data: yfinance for market data

Frontend (React + TypeScript)

  • Framework: React 18 + TypeScript
  • Build Tool: Vite (ultra-fast)
  • Styling: TailwindCSS (Bloomberg-inspired theme)
  • Charts: Recharts for visualizations
  • State: React Query for server state
  • Routing: React Router

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+ and npm
  • Alpaca API keys (paper or live)

1. Clone & Setup

cd "/Volumes/File System/Algorithmic Trading"

# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install backend dependencies
pip install -r requirements-backend.txt

# Install frontend dependencies
cd frontend
npm install
cd ..

2. Configure API Keys

# Copy environment template
cp .env.example .env

# Edit .env and add your Alpaca API keys
nano .env

3. Start the Application

Option A: Run Both (Recommended)

# Terminal 1 - Backend
./start_backend.sh

# Terminal 2 - Frontend
cd frontend && npm run dev

Option B: Development Mode

# Backend with auto-reload
cd backend && python -m uvicorn main:app --reload

# Frontend with hot reload
cd frontend && npm run dev

4. Access the Application

πŸ“ Project Structure

AlphaFlow/
β”œβ”€β”€ backend/                 # FastAPI Backend
β”‚   β”œβ”€β”€ main.py             # Main FastAPI app
β”‚   β”œβ”€β”€ api/                # API endpoints
β”‚   β”‚   β”œβ”€β”€ trading.py      # Order management
β”‚   β”‚   β”œβ”€β”€ market_data.py  # Market data & quotes
β”‚   β”‚   β”œβ”€β”€ backtest.py     # Backtesting
β”‚   β”‚   β”œβ”€β”€ portfolio.py    # Portfolio metrics
β”‚   β”‚   └── strategies.py   # Strategy management
β”‚   └── core/               # Core utilities
β”‚       └── websocket_manager.py
β”‚
β”œβ”€β”€ frontend/               # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components
β”‚   β”‚   β”œβ”€β”€ components/    # Reusable components
β”‚   β”‚   β”œβ”€β”€ api/          # API client
β”‚   β”‚   └── App.tsx       # Main app
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”‚
β”œβ”€β”€ core/                  # Shared trading logic
β”‚   β”œβ”€β”€ backtester.py     # Backtest engine
β”‚   β”œβ”€β”€ indicators.py     # Technical indicators
β”‚   β”œβ”€β”€ strategies.py     # Trading strategies
β”‚   └── ...
β”‚
β”œβ”€β”€ requirements-backend.txt
β”œβ”€β”€ start_backend.sh
└── README.md

🎨 UI Preview

Bloomberg-Inspired Design

  • Dark Theme: Professional dark color scheme
  • Clean Typography: SF Pro Display + SF Mono
  • Real-time Updates: Live data with color flash animations
  • Responsive Tables: Professional data grids
  • Modern Charts: Interactive visualizations

Pages

  1. Dashboard - Portfolio overview, watchlist, equity curve
  2. Trading - Order placement and management
  3. Analytics - Performance metrics and analytics
  4. Backtest - Strategy backtesting interface
  5. Strategies - Deploy and manage algorithms
  6. Settings - Configuration and preferences

πŸ”Œ API Endpoints

Trading

  • POST /api/trading/orders - Place order
  • GET /api/trading/orders - Get orders
  • DELETE /api/trading/orders/{id} - Cancel order
  • GET /api/trading/positions - Get positions

Market Data

  • GET /api/market/quote/{symbol} - Get quote
  • GET /api/market/quotes - Get multiple quotes
  • GET /api/market/history/{symbol} - Get historical data
  • GET /api/market/search - Search symbols

Backtest

  • POST /api/backtest/run - Start backtest
  • GET /api/backtest/status/{id} - Get status
  • GET /api/backtest/results/{id} - Get results

Portfolio

  • GET /api/portfolio/summary - Portfolio summary
  • GET /api/portfolio/performance - Performance metrics
  • GET /api/portfolio/history - Equity curve

πŸ”§ Development

Backend Development

# Auto-reload on code changes
python -m uvicorn backend.main:app --reload --port 8000

# Run tests
pytest tests/

Frontend Development

cd frontend

# Development server with hot reload
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

πŸ“¦ Deployment

Backend (Production)

# Using Gunicorn
gunicorn backend.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

# Using Docker
docker build -t alphaflow-backend .
docker run -p 8000:8000 alphaflow-backend

Frontend (Production)

cd frontend
npm run build

# Serve dist/ folder with nginx, Vercel, or Netlify

πŸ› οΈ Tech Stack

Backend

  • FastAPI - Modern, fast web framework
  • Uvicorn - ASGI server
  • WebSockets - Real-time communication
  • Alpaca API - Trading execution
  • yfinance - Market data
  • pandas - Data manipulation
  • scikit-learn - Machine learning

Frontend

  • React 18 - UI framework
  • TypeScript - Type safety
  • Vite - Build tool
  • TailwindCSS - Styling
  • React Query - Server state
  • React Router - Navigation
  • Recharts - Charts
  • Lucide React - Icons
  • Axios - HTTP client

πŸ” Security

  • API keys stored in .env (never committed)
  • CORS configured for frontend origin
  • Input validation with Pydantic
  • Type safety with TypeScript

πŸ“ License

MIT License - See LICENSE file

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“§ Support

For issues and questions:

  • Open an issue on GitHub
  • Check API documentation at /api/docs

Made with FastAPI + React | Version 7.0.0 | Professional Trading Platform

About

Algorithmic trading app for backtesting and live execution.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •