{"id":41285232,"url":"https://github.com/pseudocodes/goctp_l3_estimate","last_synced_at":"2026-01-23T03:02:19.956Z","repository":{"id":307433372,"uuid":"1029479850","full_name":"pseudocodes/goctp_l3_estimate","owner":"pseudocodes","description":"国内期货期权订单簿 L3 可视化工具","archived":false,"fork":false,"pushed_at":"2025-07-31T06:40:23.000Z","size":7985,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-31T08:40:07.032Z","etag":null,"topics":["ctp","futures","goctp","orderbook","orderbook-tick-data","trading"],"latest_commit_sha":null,"homepage":"","language":"Go","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/pseudocodes.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}},"created_at":"2025-07-31T05:42:58.000Z","updated_at":"2025-07-31T08:23:31.000Z","dependencies_parsed_at":"2025-07-31T08:55:40.830Z","dependency_job_id":null,"html_url":"https://github.com/pseudocodes/goctp_l3_estimate","commit_stats":null,"previous_names":["pseudocodes/goctp_l3_estimate"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pseudocodes/goctp_l3_estimate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocodes%2Fgoctp_l3_estimate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocodes%2Fgoctp_l3_estimate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocodes%2Fgoctp_l3_estimate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocodes%2Fgoctp_l3_estimate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pseudocodes","download_url":"https://codeload.github.com/pseudocodes/goctp_l3_estimate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocodes%2Fgoctp_l3_estimate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28679140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T01:00:35.747Z","status":"online","status_checked_at":"2026-01-23T02:00:08.296Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ctp","futures","goctp","orderbook","orderbook-tick-data","trading"],"created_at":"2026-01-23T03:01:44.811Z","updated_at":"2026-01-23T03:02:19.945Z","avatar_url":"https://github.com/pseudocodes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CTP L3 订单簿估算器\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"demo.gif\" alt=\"Demo GIF\"\u003e\n\u003c/div\u003e\n\n一个基于 Go 实现的实时 L3 订单簿可视化工具，用于国内期货期权合约，它尝试从 L2 市场深度数据重建单个订单队列。提供交互式可视化功能。\n\n基于 @jose-donato 的实现：[binancef_l3_estimate_go](https://github.com/jose-donato/binancef_l3_estimate_go)\n\n## ✨ 特性\n\n### 🎯 **核心 L3 重建**\n- 从 L2 数据实时重建单个订单队列\n- 基于 FIFO 的队列管理与智能订单匹配\n- 精确的小数运算，防止浮点错误\n- 支持上期 CTP 提供的合约行情数据\n\n\n### 🎨 **高级可视化**\n- **基于年龄的着色**：颜色越深 = 订单越旧（队列靠前）\n- **基于聚类的着色**：每个订单大小聚类使用不同颜色\n- **特殊高亮**：最大和第二大订单使用金色高亮\n\n\n### 📊 **交互式前端**\n- 实时 D3.js 堆叠条形图\n- 综合订单簿表格视图\n- 队列可视化与单个订单条\n- 交易对切换与实时更新\n- 响应式设计，针对交易工作流优化\n\n\n## 🚀 快速开始\n\n### 选项 1: 使用运行脚本 (推荐)\n```bash\n./run.sh ag2510\n```\n\n### Option 2: Direct Go command\n```bash\ngo run *.go au2510\n```\n\nThen open [http://localhost:8080](http://localhost:8080) in your browser.\n\n\n## 📡 WebSocket API\n\nThe application exposes a WebSocket API for programmatic control:\n\n```javascript\n// Toggle clustering\n\n// Switch symbol\nws.send(JSON.stringify({\n    type: \"switch_symbol\", \n    symbol: \"fu2510\"\n}));\n\n```\n\n## 🏗️ Architecture\n\n```\n┌─────────────────┐    ┌────────────────────┐    ┌─────────────────┐\n│   Binance API   │────│  L3 Reconstruction │────│  Visualization  │\n│  (L2 WebSocket) │    │     Algorithm      │    │   (D3.js + Go)  │\n└─────────────────┘    └────────────────────┘    └─────────────────┘\n                                │\n                        ┌──────────────────┐\n                        │   K-Means        │\n                        │   Clustering     │\n                        └──────────────────┘\n```\n\n## 🔬 L3 重建算法细节\n该算法采用多种策略以准确还原订单队列：\n\n1. **新增订单**：新订单插入队列尾部（FIFO）\n2. **移除订单**：\n   - 优先尝试精确匹配（如取消）\n   - 数量变化较大时 → 移除最大订单\n   - 数量变化较小时 → 从队头依次移除\n3. **队列维护**：定期优化队列并更新订单年龄\n\n指标追踪：全面的队列分析与统计\n\n## 📦 Dependencies\n\n- **Backend**: Go 1.23+, gorilla/websocket, shopspring/decimal, [pseudocodes/go2ctp](https://github.com/pseudocodes/go2ctp)\n- **Frontend**: D3.js v7, vanilla JavaScript\n- **Data Source**: Hongyuan Futures CTP,  openctp.cn/DataCenter.html\n\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseudocodes%2Fgoctp_l3_estimate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpseudocodes%2Fgoctp_l3_estimate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseudocodes%2Fgoctp_l3_estimate/lists"}