Skip to content

alexanderwanyoike/the0

the0

Open-Source Algorithmic Trading Platform

Production-grade bot execution engine for quantitative trading

License: Apache 2.0 Docker Python TypeScript Rust C++ C# Scala Haskell Artifact Hub


What is the0?

the0 is an open-source algorithmic trading execution engine that provides production-grade infrastructure for deploying and managing trading bots across multiple markets. Build strategies in your preferred language—Python, TypeScript, Rust, C++, C#, Scala, or Haskell—then deploy them to a self-hosted execution engine with real-time monitoring and custom React dashboards.

Status: Beta - Active development. Not production-ready. Contributions and feedback welcome.

Key Features

  • Multi-Language Support - Build bots in Python, TypeScript, Rust, C++, C#, Scala, or Haskell
  • Custom Frontends - Create React dashboards tailored to your trading strategies
  • Real-time Execution - Deploy scheduled or continuous trading bots with isolated execution
  • Self-Hosted - Full control over your infrastructure and data
  • Docker Ready - Streamlined deployment with Docker Compose
  • CLI-First Workflow - Efficient bot management via command-line interface
  • Exchange Agnostic - Design your bots to work with any trading platform

Quick Start

Deploy the0 locally:

Prerequisites

  • Docker 20.10+ with Compose plugin (the CLI uses Docker Compose under the hood)
  • At least 4GB RAM available for containers

Option 1: CLI Local Deployment (Recommended)

# Install the CLI
curl -sSL https://install.the0.app | sh

# Start all services
the0 local start

# Access the platform
open http://localhost:3001  # Frontend
open http://localhost:3000  # API
open http://localhost:9001  # MinIO Console (admin/the0password)

Option 2: Kubernetes (Helm)

# Install from the Helm repository
helm repo add the0 https://alexanderwanyoike.github.io/the0
helm repo update
helm install the0 the0/the0 --namespace the0 --create-namespace

Local development with Minikube:

cd k8s
make minikube-up
make setup-hosts

See k8s/README.md for full Kubernetes deployment documentation.


CLI Installation

The the0 CLI tool provides a local development interface for managing your bots.

Quick Install (Recommended)

curl -sSL https://install.the0.app | sh

This detects your OS and architecture, downloads the latest release binary, verifies its checksum, and installs it to ~/.the0/bin/the0. Make sure ~/.the0/bin is in your PATH.

Install from Source

# Clone the repository if you haven't already
git clone https://github.com/alexanderwanyoike/the0.git
cd the0/cli

# Build and install the CLI
make install

# Verify installation
the0 --help

The source build installs to ~/bin/the0. Make sure ~/bin is in your PATH.

Prerequisites for CLI

  • Go 1.21+ - Required for building the CLI
  • Git - For cloning the repository

CLI Configuration & Usage

Configure API endpoint for local deployments:

# For Docker Compose deployment
export THE0_API_URL=http://localhost:3000

# For Kubernetes deployment  
export THE0_API_URL=http://api.the0.local:3000

For CLI bot usage instructions, visit the official documentation:

📖 the0 CLI Documentation


MCP Server (Claude Code Integration)

the0 includes a built-in MCP (Model Context Protocol) server that enables AI assistants like Claude Code to interact directly with the platform. This allows you to manage bots, view logs, and deploy configurations using natural language.

Configure Claude Code

MCP tools require authentication via API key. Generate one from the web dashboard (Settings → API Keys) or via the CLI (the0 auth login).

Option 1: CLI Command

claude mcp add the0 --transport http http://localhost:3000/mcp \
  --header "x-api-key: YOUR_API_KEY"

Option 2: Configuration File

Add to your .mcp.json in the project root:

{
  "mcpServers": {
    "the0": {
      "type": "http",
      "url": "http://localhost:3000/mcp",
      "headers": {
        "x-api-key": "YOUR_API_KEY"
      }
    }
  }
}

For team environments, use environment variable expansion to avoid committing secrets:

{
  "mcpServers": {
    "the0": {
      "type": "http",
      "url": "http://localhost:3000/mcp",
      "headers": {
        "x-api-key": "${THE0_API_KEY}"
      }
    }
  }
}

Restart Claude Code after configuring, then verify with /mcp — you should see the0 server as connected.

Available MCP Tools

Category Tool Description
Auth auth_status Check API key validity
Bot Instance bot_list List deployed bots
bot_get Get bot details
bot_deploy Deploy a new bot
bot_update Update bot configuration
bot_delete Delete a bot
Logs logs_get Get execution logs
logs_summary Get log statistics
Custom Bot custom_bot_list List available custom bots
custom_bot_get Get custom bot details
custom_bot_schema Get configuration schema

Example Usage

Once configured, ask Claude Code:

  • "List my deployed bots"
  • "Show me the logs for my trading bot"
  • "What custom bots are available?"
  • "Deploy a new scheduled bot with this configuration"

For detailed MCP documentation including all tool parameters and troubleshooting, see MCP Integration Guide.


Architecture

the0 is built as a microservices execution engine that enables algorithmic trading bot deployment and management:

graph TB
    subgraph "Users"
        DEV[👨‍💻 Bot Developer<br/>Creates & tests bots]
        TRADER[📊 Trader<br/>Deploys & monitors]
    end
    
    subgraph "the0 Platform"
        subgraph "Client Layer"
            WEB[🌐 Web Dashboard<br/>Next.js 15, React 19<br/>Bot management & monitoring]
            CLI[🛠️ CLI Tool<br/>Go, Cobra<br/>Local development]
        end
        
        subgraph "API Layer"
            API[🚀 API Server<br/>NestJS, TypeScript<br/>REST API & orchestration]
        end
        
        subgraph "Runtime Services"
            BR[⚡ Bot Runner<br/>Go, gRPC<br/>Real-time execution]
            BS[⏰ Bot Scheduler<br/>Go, gRPC<br/>Cron execution]
        end

        subgraph "Data Layer"
            PG[(🐘 PostgreSQL<br/>Users, bots, auth)]
            MONGO[(🍃 MongoDB<br/>Runtime state, logs)]
            NATS[📨 NATS JetStream<br/>Event streaming]
            MINIO[📦 MinIO<br/>Code & log storage]
        end
    end
    
    %% User interactions
    DEV -.->|HTTPS| WEB
    DEV -.->|CLI| CLI
    TRADER -.->|HTTPS| WEB
    
    %% Client to API
    WEB -->|REST + JWT| API
    CLI -->|REST + API Key| API
    API -->|SSE| WEB
    
    %% API to databases
    API -->|SQL| PG
    API -->|Events| NATS
    API -->|S3 API| MINIO
    
    %% Runtime services
    NATS -->|Events| BR
    NATS -->|Events| BS

    BR -->|State| MONGO
    BS -->|Schedules| MONGO

    BR -->|Logs| MINIO
    
    %% Styling
    classDef userClass fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    classDef clientClass fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
    classDef apiClass fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef runtimeClass fill:#fff8e1,stroke:#f57c00,stroke-width:2px
    classDef dataClass fill:#e0f2f1,stroke:#00695c,stroke-width:2px

    class DEV,TRADER userClass
    class WEB,CLI clientClass
    class API apiClass
    class BR,BS runtimeClass
    class PG,MONGO,NATS,MINIO dataClass
Loading

How It Works

🌐 Web Dashboard - Next.js frontend for bot management, real-time monitoring, and documentation system

🛠️ CLI Tool - Go-based command-line interface for local bot development, testing, and deployment automation

🚀 API Server - NestJS backend providing REST APIs, JWT authentication, and event orchestration across all services

⚙️ Runtime Services - Specialized Go microservices using master-worker patterns for different execution models:

  • Bot Runner: Real-time trading bot execution
  • Bot Scheduler: Cron-based scheduled execution

💾 Data Architecture - Multi-database approach:

  • PostgreSQL: User accounts, bot definitions, authentication
  • MongoDB: Runtime state, job queues, execution logs
  • MinIO: Bot code storage and logs
  • NATS JetStream: Event streaming and service coordination

Key Benefits

  • Isolated: Each bot runs in isolation with resource management
  • Fast: Real-time execution with live market data
  • Scalable: Handles multiple bots and users across distributed infrastructure

Bot Development

Supported Languages

Build trading bots in any of these languages with official SDK support:

Language SDK Documentation Package Registry
Python sdk/python Quick Start PyPI
TypeScript/Node.js sdk/nodejs Quick Start npm
Rust sdk/rust Quick Start crates.io
C++ sdk/cpp Quick Start Header-only (FetchContent)
C# sdk/dotnet Quick Start NuGet
Scala sdk/scala Quick Start GitHub Packages
Haskell sdk/haskell Quick Start Source (cabal)

Custom Frontends

Build React dashboards tailored to your trading strategies using the React SDK:

SDK Documentation Package
sdk/react Custom Frontends @alexanderwanyoike/the0-react

Framework Agnostic

the0 doesn't lock you into specific libraries or frameworks. Use any packages from your language's ecosystem—pandas for Python, sttp for Scala, reqwest for Rust, or any other libraries you prefer.

Example: Simple DCA Bot

from typing import Dict, Any
from alpaca.trading.client import TradingClient

def main(id: str, config: Dict[str, Any]) -> Dict[str, Any]:
    """Dollar Cost Averaging bot - buys a fixed amount regularly"""
    
    # Initialize trading client
    client = TradingClient(
        api_key=config["api_key"],
        secret_key=config["secret_key"],
        paper=config.get("paper", True)
    )
    
    # Calculate and execute purchase
    symbol = config["symbol"]
    amount = config["amount"]
    
    # Place market buy order
    order = client.submit_order(
        symbol=symbol,
        notional=amount,
        side=OrderSide.BUY,
        type=OrderType.MARKET,
        time_in_force=TimeInForce.DAY
    )
    
    return {
        "status": "success",
        "message": f"Purchased ${amount} of {symbol}",
        "order_id": order.id
    }

Bot Types

  • Scheduled Bots - Run on cron schedules (daily, weekly, monthly)
  • Real-time Bots - Continuous execution with live data feeds

Documentation

Getting Started

Deployment Guides

Development Resources


Contributing

We welcome contributions from developers, traders, and AI enthusiasts! the0 is built by a community that values creativity and innovation.

AI-Assisted Development

We encourage the use of AI tools and agents in development:

  • AI Assistants Welcome - Use Claude, ChatGPT, GitHub Copilot, or any AI tools you prefer
  • AI-Generated Code - AI-written code is acceptable when properly tested
  • Creative Solutions - We value innovative approaches and problem-solving
  • Quality First - Ensure your code is properly tested, regardless of origin
  • Context Engineering Over Vibe Coding - Use context engineering when contributing with AI

Ways to Contribute

  • Bug Reports - Found an issue? Let us know
  • Feature Requests - Have ideas for improvements?
  • Code Contributions - Submit pull requests (AI-assisted or manual)
  • Documentation - Help improve our docs and examples
  • Bot Templates - Share innovative trading strategies and patterns

See CONTRIBUTING.md for detailed contribution guidelines.

Getting Started

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Build your solution (with or without AI assistance)
  4. Add tests
  5. Submit a pull request with a clear description

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


Support & Community


Built by AlphaNeuron

WebsiteDocumentationDiscord

About

Open Source Algorithmic Trading Engine

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors