vwap_topstepx

VWAP-Based Automated Trading Strategy - Enterprise Production Application

A production-ready VWAP-based automated trading strategy application with REST API backend and React frontend dashboard for TopstepX.

Architecture Diagram

Architecture

This is a full-stack enterprise application with:

Features

Project Structure

vwap_topstepx/
β”œβ”€β”€ backend/                 # FastAPI backend application
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/            # API routes
β”‚   β”‚   β”œβ”€β”€ core/           # Core configuration
β”‚   β”‚   β”œβ”€β”€ services/       # Business logic services
β”‚   β”‚   └── main.py         # Application entry point
β”‚   β”œβ”€β”€ requirements.txt    # Python dependencies
β”‚   └── Dockerfile          # Backend container
β”œβ”€β”€ frontend/               # React frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # React components
β”‚   β”‚   β”œβ”€β”€ services/       # API client
β”‚   β”‚   └── App.tsx         # Main app component
β”‚   β”œβ”€β”€ package.json        # Node dependencies
β”‚   └── Dockerfile          # Frontend container
β”œβ”€β”€ docker-compose.yml      # Docker Compose configuration
β”œβ”€β”€ vwap_strategy.py        # Core strategy implementation
β”œβ”€β”€ config.py               # Configuration module
└── README.md               # This file

Prerequisites

  1. Clone the repository

  2. Set up environment variables
    cp .env.example .env
    

    Edit .env and add your TopstepX credentials:

    PROJECT_X_API_KEY=your_api_key_here
    PROJECT_X_USERNAME=your_username_here
    
  3. Start the application
    docker-compose up -d
    
  4. Access the application
    • Frontend Dashboard: http://localhost:3000
    • Backend API: http://localhost:8000
    • API Documentation: http://localhost:8000/api/docs

Manual Installation

Backend Setup

  1. Navigate to backend directory
    cd backend
    
  2. Create virtual environment
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies
    pip install -r requirements.txt
    
  4. Set environment variables
    export PROJECT_X_API_KEY=your_api_key_here
    export PROJECT_X_USERNAME=your_username_here
    
  5. Run the backend
    uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
    

Frontend Setup

  1. Navigate to frontend directory
    cd frontend
    
  2. Install dependencies
    npm install
    
  3. Set environment variables (optional)
    export VITE_API_URL=http://localhost:8000
    
  4. Run the frontend
    npm run dev
    
  5. Access the dashboard
    • Open http://localhost:3000 in your browser

Configuration

Configuration is managed through environment variables:

Required Environment Variables

Optional Configuration

API Endpoints

The backend provides the following REST API endpoints:

Status & Health

Strategy Control

Configuration

API Documentation

Interactive API documentation is available at:

Strategy Logic

VWAP Trading Strategy

Production Deployment

Docker Deployment

The application is containerized and ready for production deployment:

# Build and start
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

Cloud Deployment

The application can be deployed to:

Environment Setup for Production

  1. Set environment variables securely (use secrets management)
  2. Configure CORS origins in backend/app/core/config.py
  3. Enable HTTPS/TLS for production
  4. Set up monitoring and logging
  5. Configure database for trade history (optional)

Development

Running Tests

# Backend tests (when available)
cd backend
pytest

# Frontend tests (when available)
cd frontend
npm test

Code Structure

Important Notes

⚠️ Production Considerations

License

This is an enterprise production application for trading purposes.