Show HN: The0 – 用于交易机器人的自托管运行时,支持自定义编程语言
Show HN: The0 – self-hosted runtime for trading bots, bring your own language

原始链接: https://github.com/alexanderwanyoike/the0

**the0** 是一个开源、生产级的算法交易执行引擎,旨在跨任何市场部署和管理交易机器人。目前处于测试阶段,它提供了一个灵活且与交易所无关的基础设施,允许开发者使用 Python、TypeScript、Rust、C++、C#、Scala 或 Haskell 构建策略。 **主要功能包括:** * **灵活的执行方式:** 支持在隔离环境中进行定时(cron)和持续的实时交易。 * **开发者友好工具:** 以命令行(CLI)优先的工作流程、支持 Docker 部署,以及用于监控的可定制 React 仪表盘。 * **现代架构:** 基于微服务的系统,使用了 NestJS、Go、PostgreSQL、MongoDB 和 NATS。 * **AI 集成:** 内置模型上下文协议(MCP)服务器,允许用户通过 Claude Code 等 AI 助手管理机器人、查看日志并部署配置。 * **自托管:** 提供对基础设施和数据的完全控制,支持通过 Docker Compose 或 Kubernetes (Helm) 进行部署。 the0 由社区驱动,欢迎各类贡献(包括 AI 辅助编写的代码),前提是需符合质量和测试标准。它采用 Apache License 2.0 许可证。用户可直接从官网安装 CLI 以开始使用。

**The0** 是一个自托管、语言无关的运行时环境,旨在管理、部署和监控算法交易机器人。它由一位软件工程师开发,旨在提供一种比现有固化的交易框架更可靠的替代方案。The0 允许开发者使用任何语言(包括 Rust、C++、Python 和 TypeScript)编写机器人,同时保持对执行环境的完全控制。 该架构使用 Go 语言构建,将机器人视为容器化应用程序,可通过 Docker 在本地运行,也可在 Kubernetes 集群中运行。用户只需实现一个简单的接口——即一个 `main` 函数和一个配置文件——即可部署与底层基础设施解耦的机器人。Sidecar 守护进程负责处理日志记录、状态持久化和流式传输,并通过基于 React 的前端提供实时监控。 值得注意的是,The0 包含一个 MCP 服务器,使 AI 智能体能够自主查询机器人日志、监控性能并更新策略。The0 目前版本稳定,并以 Apache-2.0 许可证开源。它专注于交易算法的“生产级编排”,填补了 Lean 等现有平台在这一领域的不足。目前,它已被用于在最小化的基础设施上运行各种加密货币和股票交易机器人。
相关文章

原文

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.

  • 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

Deploy the0 locally:

  • 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

# Initialize local compose and configure the root admin
the0 local init --email [email protected] --password testuse123

# Start all services
the0 local start

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

Option 2: Kubernetes (Helm)

Kubernetes is not a one-command install. A production deployment needs operator-managed backing services and secrets for PostgreSQL, MongoDB, S3-compatible object storage, JWT signing, and the deployment-managed root admin. The chart can run NATS in the cluster, or you can point it at an external NATS service.

The Helm chart is published for production use, but prepare a values file and Secret workflow first:

helm repo add the0 https://alexanderwanyoike.github.io/the0
helm repo update

Local development with Minikube:

cd k8s
make minikube-up
make setup-hosts

See Kubernetes Deployment for the full guide, including the external services and root admin configuration the chart expects.


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.

# 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.

  • 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.

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.

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

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.


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

🌐 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
  • 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

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

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

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.

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
    }
  • Scheduled Bots - Run on cron schedules (daily, weekly, monthly)
  • Real-time Bots - Continuous execution with live data feeds


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

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
  • 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.

  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

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



联系我们 contact @ memedata.com