{"id":43347003,"url":"https://github.com/gjwang/zero_x_infinity","last_synced_at":"2026-02-02T01:37:52.258Z","repository":{"id":329059843,"uuid":"1116160324","full_name":"gjwang/zero_x_infinity","owner":"gjwang","description":"The Hardest Core HFT Exchange Engine in Rust. From Hello World to 1.3M TPS. 🚀","archived":false,"fork":false,"pushed_at":"2025-12-28T19:05:51.000Z","size":73073,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-29T03:13:54.475Z","etag":null,"topics":["cyrptocurrency","exchange","hft","high-frequency-trading","low-latency","matching-engine","rust","trading-engine"],"latest_commit_sha":null,"homepage":"https://gjwang.github.io/zero_x_infinity/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gjwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-14T10:19:56.000Z","updated_at":"2025-12-28T16:09:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gjwang/zero_x_infinity","commit_stats":null,"previous_names":["gjwang/zero_x_infinity"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/gjwang/zero_x_infinity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjwang%2Fzero_x_infinity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjwang%2Fzero_x_infinity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjwang%2Fzero_x_infinity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjwang%2Fzero_x_infinity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gjwang","download_url":"https://codeload.github.com/gjwang/zero_x_infinity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjwang%2Fzero_x_infinity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28999917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T01:32:03.847Z","status":"ssl_error","status_checked_at":"2026-02-02T01:32:03.458Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cyrptocurrency","exchange","hft","high-frequency-trading","low-latency","matching-engine","rust","trading-engine"],"created_at":"2026-02-02T01:37:51.393Z","updated_at":"2026-02-02T01:37:52.252Z","avatar_url":"https://github.com/gjwang.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# ⚔️ 0xInfinity\n\n\u003ch3\u003e\n  \u003ca href=\"#-english\"\u003e🇺🇸 English\u003c/a\u003e\n  \u0026nbsp;\u0026nbsp;\u0026nbsp;|\u0026nbsp;\u0026nbsp;\u0026nbsp;\n  \u003ca href=\"#-chinese\"\u003e🇨🇳 中文\u003c/a\u003e\n\u003c/h3\u003e\n\n\u003c/div\u003e\n\n\u003cdiv id=\"-english\"\u003e\u003c/div\u003e\n\n# 🇺🇸 English\n\n\u003e **\"From Hello World to Microsecond Latency.\"**\n\n[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)]()\n[![License](https://img.shields.io/badge/license-MIT-blue)]()\n[![Rust](https://img.shields.io/badge/language-Rust-orange)]()\n[![mdBook](https://img.shields.io/badge/docs-mdBook-blue)](https://gjwang.github.io/zero_x_infinity/)\n\n---\n\n## ⚡ Why 0xInfinity?\n\n**This is not another \"Toy Matching Engine\" tutorial.**\n\nWe are building a **production-grade** crypto trading engine that handles **1.3M orders/sec** (P99 \u003c 200µs) on a single core. This project documents the entire journey from a naive `Vec\u003cOrder\u003e` implementation to a professional LMAX Disruptor-style Ring Buffer architecture.\n\n### 🔥 Hardcore Tech Stack\n*   **Zero GC**: Pure Rust implementation with zero garbage collection pauses.\n*   **Lock-free**: High-performance Ring Buffer (`crossbeam-queue`) for inter-thread communication.\n*   **Determinism**: Event Sourcing architecture ensures 100% reproduceability.\n*   **Safety**: Ed25519 Authentication \u0026 Type-safe Asset handling.\n*   **Persistence**: TDengine (Time-Series Database) for high-speed audit logging.\n*   **Crash Recovery**: Universal WAL \u0026 Snapshot for bit-perfect state reconstruction.\n\n## 🏗️ Architecture\n\n```mermaid\ngraph TD\n    Client[Client] --\u003e|HTTP/WS| Gateway\n    Gateway --\u003e|RingBuffer| Ingestion\n    subgraph \"Trading Core (Single Thread)\"\n        Ingestion --\u003e|SeqOrder| UBSCore[\"UBSCore (Risk/Balance)\"]\n        UBSCore --\u003e|LockedOrder| ME[\"Matching Engine\"]\n        ME --\u003e|Trade/OrderUpdate| Settlement\n    end\n    Settlement --\u003e|Async| Persistence[TDengine]\n    Settlement --\u003e|Async| MktData[\"Market Data (K-Line)\"]\n    Settlement --\u003e|Async| WS[\"WebSocket Push\"]\n```\n\n## ✨ Core Features\n\n*   **Order Management**: Limit, Market, Cancel, Maker/Taker logic.\n*   **Risk Control**: Pre-trade balance check, exact fund locking.\n*   **Market Data**: Real-time Depth (Orderbook), K-Line (followers Binance format), Ticker.\n*   **Interfaces**: REST API, WebSocket Stream (Pub/Sub).\n*   **Replay**: Full determinism allows replaying from genesis for exactly-once state recovery.\n\n---\n\n## 🚀 The Journey\n\n**📖 [Read the Book Online →](https://gjwang.github.io/zero_x_infinity/)**\n\n**📊 [Project Roadmap →](./docs/src/0x00-mvp-roadmap.md)**\n\n### Chapters\n\n| Stage | Title | Description |\n|-------|-------|-------------|\n| 0x01 | [Genesis](./docs/src/0x01-genesis.md) | Basic OrderBook Engine |\n| 0x11 | [Deposit \u0026 Withdraw](./docs/src/0x11-deposit-withdraw.md) | ✅ Mock Chain Integration (RC2 Released) |\n| 0x02 | [The Curse of Float](./docs/src/0x02-the-curse-of-float.md) | Float Curse → u64 Refactor |\n| 0x03 | [Decimal World](./docs/src/0x03-decimal-world.md) | Decimal System \u0026 Precision |\n| 0x04 | [BTree OrderBook](./docs/src/0x04-btree-orderbook.md) | BTreeMap Structure Refactor |\n| 0x05 | [User Balance](./docs/src/0x05-user-balance.md) | Account \u0026 Balance Management |\n| 0x06 | [Enforced Balance](./docs/src/0x06-enforced-balance.md) | Type-Safe Enforced Balance |\n| 0x07-a | [Testing Framework](./docs/src/0x07-a-testing-framework.md) | 1M Orders Batch Testing |\n| 0x07-b | [Performance Baseline](./docs/src/0x07-b-perf-baseline.md) | Baseline \u0026 Bottleneck Analysis |\n| 0x08-a | [Trading Pipeline Design](./docs/src/0x08-a-trading-pipeline-design.md) | Pipeline Architecture |\n| 0x08-b | [UBSCore Implementation](./docs/src/0x08-b-ubscore-implementation.md) | UBSCore Implementation |\n| 0x08-c | [Complete Event Flow](./docs/src/0x08-c-ring-buffer-pipeline.md) | Complete Event Flow |\n| 0x08-d | [Complete Order Lifecycle](./docs/src/0x08-d-complete-order-lifecycle.md) | Complete Order Lifecycle |\n| 0x08-e | [Cancel Optimization](./docs/src/0x08-e-cancel-optimization.md) | Cancel Optimization: Order Index |\n| 0x08-f | [Ring Buffer Pipeline](./docs/src/0x08-f-ring-buffer-pipeline.md) | Ring Buffer Performance |\n| 0x08-g | [Multi-Thread Pipeline](./docs/src/0x08-g-multi-thread-pipeline.md) | Multi-Thread Pipeline |\n| 0x08-h | [Performance Monitoring](./docs/src/0x08-h-performance-monitoring.md) | Monitoring \u0026 Intent-Encoded |\n| 0x09-a | [Gateway: Client Access Layer](./docs/src/0x09-a-gateway.md) | HTTP Gateway Access Layer |\n| 0x09-b | [Settlement Persistence](./docs/src/0x09-b-settlement-persistence.md) | TDengine Persistence |\n| 0x09-c | [WebSocket Push](./docs/src/0x09-c-websocket-push.md) | Real-time Push |\n| 0x09-d | [K-Line Aggregation](./docs/src/0x09-d-kline-aggregation.md) | K-Line Aggregation |\n| 0x09-e | [Order Book Depth](./docs/src/0x09-e-orderbook-depth.md) | OrderBook Depth |\n| 0x09-f | [Full Integration Test](./docs/src/0x09-f-integration-test.md) | E2E Integration \u0026 Regression |\n| **Part II** | **Productization** | |\n| 0x0A | [Part II Introduction](./docs/src/0x0A-part-ii-introduction.md) | Productization Roadmap |\n| 0x0A-a | [Account System](./docs/src/0x0A-a-account-system.md) | PostgreSQL Account Manager |\n| 0x0A-b | [API Auth](./docs/src/0x0A-c-api-auth.md) | Ed25519 Authentication |\n| 0x0B | [Funding \u0026 Transfer](./docs/src/0x0B-funding.md) | Funding System Architecture |\n| 0x0B-a | [Internal Transfer](./docs/src/0x0B-a-transfer.md) | FSM-based 2PC Transfer |\n| 0x0C | [Trade Fee](./docs/src/0x0C-trade-fee.md) | Maker/Taker Fee System |\n| **Part III** | **Resilience** | |\n| 0x0D | [Snapshot \u0026 Recovery](./docs/src/0x0D-snapshot-recovery.md) | Universal WAL \u0026 Snapshot Persistence |\n| 0x0E | [OpenAPI Integration](./docs/src/0x0E-openapi-integration.md) | Swagger UI \u0026 SDK Generation |\n| 0x0F | [Admin Dashboard](./docs/src/0x0F-admin-dashboard.md) | FastAPI Amis Admin + Trace ID |\n| 0x10 | [Web Frontend](./docs/src/0x10-web-frontend.md) | Frontend Outsourcing Requirement |\n| 0x11 | [Deposit \u0026 Withdraw](./docs/src/0x11-deposit-withdraw.md) | ✅ Mock Chain Integration |\n| 0x11-a | [Real Chain Integration](./docs/src/0x11-a-real-chain.md) | ✅ BTC Sentinel MVP |\n| 0x11-b | [Sentinel Hardening](./docs/src/0x11-b-sentinel-hardening.md) | ✅ DEF-002 Fix, ADR-005/006 |\n| **Phase V** | **Extreme Optimization** | **\"Metal Mode\"** |\n| 0x14 | [Extreme Optimization](./docs/src/0x14-extreme-optimization.md) | Architecture Manifesto |\n| 0x14-a | [Benchmark Harness](./docs/src/0x14-a-bench-harness.md) | ✅ 100% Bit-exact Parity (FILL) |\n| 0x14-b | [Order Commands](./docs/src/0x14-b-order-commands.md) | ✅ IOC, Move, Reduce (Feature Parity) |\n| 0x15 | [Zero-Copy](./docs/src/0x15-zero-copy.md) | Planned |\n| 0x16 | [CPU Affinity](./docs/src/0x16-cpu-affinity.md) | Planned |\n| 0x17 | [SIMD Matching](./docs/src/0x17-simd-matching.md) | Planned |\n\n\n---\n\n## 🏃 Quick Start\n\n```bash\n# Install git hooks\n./scripts/install-hooks.sh\n\n# Run Gateway mode (HTTP API + Trading Core)\ncargo run --release -- --gateway --port 8080\n\n# Run single-threaded pipeline (1.3M orders)\ncargo run --release -- --pipeline --input fixtures/test_with_cancel_highbal\n\n# Run multi-threaded pipeline\ncargo run --release -- --pipeline-mt --input fixtures/test_with_cancel_highbal\n\n# Compare both pipelines (ST vs MT)\n./scripts/test_pipeline_compare.sh highbal\n\n# Regression check (vs Golden Baseline)\n./scripts/test_pipeline_compare.sh 100k\n\n# Generate new baseline (requires --force)\n./scripts/generate_baseline.sh 100k -f\n```\n\n---\n\n## 📑 Regression Testing\n\nWe use a **Golden Set** strategy. Baselines are stored in `baseline/`.\n\n- **Consistnecy**: MT mode must match ST mode 100%.\n- **Persistence**: MT mode relies on **TDengine** for audit trails.\n- **Protection**: Updates to baseline require `generate_baseline.sh --force`.\n\n---\n\n## 💾 Persistence (TDengine)\n\n### Start TDengine\n\n```bash\ndocker run -d --name tdengine -p 6030:6030 -p 6041:6041 tdengine/tdengine:latest\n```\n\n### Enable Persistence\n\nEdit `config/dev.yaml`:\n\n```yaml\npersistence:\n  enabled: true\n  tdengine_dsn: \"taos+ws://root:taosdata@localhost:6041\"\n```\n\n### Start Persistence Mode\n\n```bash\ncargo run --release -- --gateway --env dev\n```\n\n### Query Data\n\n```bash\n# Connect to TDengine\ndocker exec -it tdengine taos\n\n# Query orders\nUSE trading;\nSELECT * FROM orders LIMIT 10;\n```\n\n\u003cbr\u003e\n\u003cdiv align=\"right\"\u003e\u003ca href=\"#-english\"\u003e↑ Back to Top\u003c/a\u003e\u003c/div\u003e\n\u003cbr\u003e\n\n---\n\n\u003cdiv id=\"-chinese\"\u003e\u003c/div\u003e\n\n# 🇨🇳 中文文档\n\n\u003e **\"From Hello World to Microsecond Latency.\"**\n\n---\n\n## ⚡ 为什么选择 0xInfinity?\n\n**这不是另一个 \"玩具级撮合引擎\" 教程。**\n\n我们正在构建一个**生产级**的加密货币交易引擎，在单核上可处理 **130万订单/秒** (P99 \u003c 200µs)。本项目记录了从最朴素的 `Vec\u003cOrder\u003e` 实现到专业的 LMAX Disruptor 风格 Ring Buffer 架构的完整演进过程。\n\n### 🔥 硬核技术栈\n*   **零 GC (Zero GC)**: 纯 Rust 实现，无垃圾回收暂停。\n*   **无锁并发 (Lock-free)**: 基于高性能 Ring Buffer (`crossbeam-queue`) 的线程间通信。\n*   **确定性 (Determinism)**: 事件溯源架构，确保 100% 可重现性。\n*   **安全性 (Safety)**: Ed25519 非对称鉴权 \u0026 类型安全的资产处理。\n*   **持久化 (Persistence)**: 集成 TDengine 时序数据库，实现极速审计日志。\n*   **崩溃恢复 (Crash Recovery)**: 通用 WAL \u0026 快照，实现比特级精确状态重建。\n\n---\n\n## 🏗️ 架构概览\n\n```mermaid\ngraph TD\n    Client[客户端] --\u003e|HTTP/WS| Gateway\n    Gateway --\u003e|RingBuffer| Ingestion\n    subgraph \"核心交易线程 (Single Thread)\"\n        Ingestion --\u003e|SeqOrder| UBSCore[\"UBSCore (风控/余额)\"]\n        UBSCore --\u003e|LockedOrder| ME[撮合引擎]\n        ME --\u003e|Trade/OrderUpdate| Settlement\n    end\n    Settlement --\u003e|异步| Persistence[TDengine]\n    Settlement --\u003e|异步| MktData[\"行情数据 (K-Line)\"]\n    Settlement --\u003e|异步| WS[WebSocket 推送]\n```\n\n## ✨ 核心特性\n\n*   **订单管理**: 限价单、市价单、撤单、Maker/Taker 逻辑。\n*   **风控系统**: 交易前余额检查、精确资金锁定。\n*   **行情数据**: 实时深度 (Orderbook)、K线 (Binance 格式)、Ticker。\n*   **接口支持**: REST API、WebSocket流 (Pub/Sub)。\n*   **回放机制**: 全确定性设计，允许从创世状态重放以实现精确的状态恢复。\n\n---\n\n## 🚀 学习之旅\n\n**📖 [在线阅读完整教程 →](https://gjwang.github.io/zero_x_infinity/)**\n\n**📊 [项目路线图 →](./docs/src/0x00-mvp-roadmap.md)**\n\n### 章节索引\n\n| 阶段 | 标题 | 描述 |\n|-------|-------|-------------|\n| 0x01 | [Genesis](./docs/src/0x01-genesis.md) | 基础订单簿引擎 |\n| 0x02 | [The Curse of Float](./docs/src/0x02-the-curse-of-float.md) | 浮点数的诅咒 → u64 重构 |\n| 0x03 | [Decimal World](./docs/src/0x03-decimal-world.md) | 十进制转换与精度配置 |\n| 0x04 | [BTree OrderBook](./docs/src/0x04-btree-orderbook.md) | BTreeMap 数据结构重构 |\n| 0x05 | [User Balance](./docs/src/0x05-user-balance.md) | 用户账户与余额管理 |\n| 0x06 | [Enforced Balance](./docs/src/0x06-enforced-balance.md) | 类型安全的强制余额 |\n| 0x07-a | [Testing Framework](./docs/src/0x07-a-testing-framework.md) | 100万订单批量测试框架 |\n| 0x07-b | [Performance Baseline](./docs/src/0x07-b-perf-baseline.md) | 性能基线与瓶颈分析 |\n| 0x08-a | [Trading Pipeline Design](./docs/src/0x08-a-trading-pipeline-design.md) | 交易流水线设计 |\n| 0x08-b | [UBSCore Implementation](./docs/src/0x08-b-ubscore-implementation.md) | UBSCore 实现 |\n| 0x08-c | [Complete Event Flow](./docs/src/0x08-c-ring-buffer-pipeline.md) | 完整事件流 |\n| 0x08-d | [Complete Order Lifecycle](./docs/src/0x08-d-complete-order-lifecycle.md) | 完整订单生命周期 |\n| 0x08-e | [Cancel Optimization](./docs/src/0x08-e-cancel-optimization.md) | 撤单性能优化：Order Index |\n| 0x08-f | [Ring Buffer Pipeline](./docs/src/0x08-f-ring-buffer-pipeline.md) | Ring Buffer Pipeline 性能分析 |\n| 0x08-g | [Multi-Thread Pipeline](./docs/src/0x08-g-multi-thread-pipeline.md) | 多线程 Pipeline |\n| 0x08-h | [Performance Monitoring](./docs/src/0x08-h-performance-monitoring.md) | 性能监控与意图编码 |\n| 0x09-a | [Gateway: Client Access Layer](./docs/src/0x09-a-gateway.md) | HTTP Gateway 客户端接入层 |\n| 0x09-b | [Settlement Persistence](./docs/src/0x09-b-settlement-persistence.md) | TDengine 持久化层 |\n| 0x09-c | [WebSocket Push](./docs/src/0x09-c-websocket-push.md) | 实时推送 |\n| 0x09-d | [K-Line Aggregation](./docs/src/0x09-d-kline-aggregation.md) | K线聚合 |\n| 0x09-e | [Order Book Depth](./docs/src/0x09-e-orderbook-depth.md) | 盘口深度 |\n| 0x09-f | [Full Integration Test](./docs/src/0x09-f-integration-test.md) | 全功能集成与回归验收 |\n| **Part II** | **产品化阶段 (Productization)** | |\n| 0x0A | [Part II Introduction](./docs/src/0x0A-part-ii-introduction.md) | 产品化路线图 |\n| 0x0A-a | [Account System](./docs/src/0x0A-a-account-system.md) | PostgreSQL 账户管理 |\n| 0x0A-b | [API Auth](./docs/src/0x0A-c-api-auth.md) | Ed25519 安全鉴权 |\n| 0x0B | [Funding \u0026 Transfer](./docs/src/0x0B-funding.md) | 资金体系架构 |\n| 0x0B-a | [Internal Transfer](./docs/src/0x0B-a-transfer.md) | FSM 内部转账 |\n| 0x0C | [Trade Fee](./docs/src/0x0C-trade-fee.md) | Maker/Taker 手续费系统 |\n| **Part III** | **鲁棒性阶段 (Resilience)** | |\n| 0x0D | [Snapshot \u0026 Recovery](./docs/src/0x0D-snapshot-recovery.md) | 通用 WAL \u0026 快照持久化 |\n| 0x0E | [OpenAPI Integration](./docs/src/0x0E-openapi-integration.md) | Swagger UI 与 SDK 生成 |\n| 0x0F | [Admin Dashboard](./docs/src/0x0F-admin-dashboard.md) | 管理后台 + Trace ID 证据链 |\n| 0x10 | [Web Frontend](./docs/src/0x10-web-frontend.md) | 前端外包需求文档 |\n| 0x11 | [Deposit \u0026 Withdraw](./docs/src/0x11-deposit-withdraw.md) | ✅ 充值与提现 (Mock Chain) |\n| 0x11-a | [Real Chain Integration](./docs/src/0x11-a-real-chain.md) | ✅ BTC Sentinel MVP |\n| 0x11-b | [Sentinel Hardening](./docs/src/0x11-b-sentinel-hardening.md) | ✅ Multi-chain \u0026 Security (ADR-005/006) |\n| **Phase V** | **极致优化 (Extreme Optimization)** | **\"Metal Mode\"** |\n| 0x14 | [Extreme Optimization](./docs/src/0x14-extreme-optimization.md) | 架构宣言 |\n| 0x14-a | [Benchmark Harness](./docs/src/0x14-a-bench-harness.md) | ✅ 100% 比特精确对齐 (FILL phase) |\n| 0x14-b | [Order Commands](./docs/src/0x14-b-order-commands.md) | ✅ IOC, Move, Reduce (功能补全) |\n| 0x15 | [Zero-Copy](./docs/src/0x15-zero-copy.md) | 计划中 |\n| 0x16 | [CPU Affinity](./docs/src/0x16-cpu-affinity.md) | 计划中 |\n| 0x17 | [SIMD Matching](./docs/src/0x17-simd-matching.md) | 计划中 |\n\n---\n\n## 🏃 快速开始\n\n```bash\n# 安装 git hooks\n./scripts/install-hooks.sh\n\n# 运行 Gateway 模式 (HTTP API + 交易核心)\ncargo run --release -- --gateway --port 8080\n\n# 运行单线程流水线 (吞吐量基准测试)\ncargo run --release -- --pipeline --input fixtures/test_with_cancel_highbal\n\n# 运行多线程流水线\ncargo run --release -- --pipeline-mt --input fixtures/test_with_cancel_highbal\n\n# 对比测试 (单线程 vs 多线程)\n./scripts/test_pipeline_compare.sh highbal\n\n# 回归检查 (对比黄金基线)\n./scripts/test_pipeline_compare.sh 100k\n```\n\n---\n\n## 📑 回归测试与基线 (Regression)\n\n本项目采用 **Golden Set** 基线比对策略。基线数据存储在 `baseline/` 目录下，代表了系统 100% 正确的状态。\n\n- **100% 资产一致性**：多线程模式必须在 `avail` 和 `frozen` 金额上与单线程基准完全对齐。\n- **DB 持久化优先**：多线程模式已移除本地 CSV 流水，全面采用 **TDengine** 进行审计。\n- **基线保护**：禁止随意修改基线，更新必须通过 `generate_baseline.sh --force` 并在确认逻辑正确后提交。\n\n---\n\n## 💾 结算持久化 (TDengine)\n\n### 1. 启动 TDengine\n\n```bash\ndocker run -d --name tdengine -p 6030:6030 -p 6041:6041 tdengine/tdengine:latest\n```\n\n### 2. 启用持久化配置\n\n编辑 `config/dev.yaml`:\n\n```yaml\npersistence:\n  enabled: true\n  tdengine_dsn: \"taos+ws://root:taosdata@localhost:6041\"\n```\n\n### 3. API 概览\n\n**公开接口 (Public)**:\n- `GET /api/v1/public/depth` - 盘口深度\n- `GET /api/v1/public/klines` - K 线数据\n- `GET /api/v1/public/trades` - 公开交易历史\n- `GET /api/v1/public/assets` - 资产列表\n\n**私有接口 (Private, Ed25519 签名)**:\n- `POST /api/v1/private/order` - 创建订单\n- `POST /api/v1/private/cancel` - 取消订单\n- `POST /api/v1/private/transfer` - 内部转账\n- `GET /api/v1/private/balances/all` - 查询余额\n- `WS /ws` - WebSocket 实时推送\n\n---\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgjwang%2Fzero_x_infinity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgjwang%2Fzero_x_infinity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgjwang%2Fzero_x_infinity/lists"}