From e45e705c22df5bc979e72db6014dd1ff9637be42 Mon Sep 17 00:00:00 2001 From: Administrator <15274802129@163.com> Date: Wed, 24 Jun 2026 22:21:58 +0800 Subject: [PATCH] fix(okx): 修复网格交易成交日志记录问题 --- .codebuddy/skills/okx-api/SKILL.md | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 deletions(-) diff --git a/.codebuddy/skills/okx-api/SKILL.md b/.codebuddy/skills/okx-api/SKILL.md new file mode 100644 index 0000000..5d2fd0b --- /dev/null +++ b/.codebuddy/skills/okx-api/SKILL.md @@ -0,0 +1,87 @@ +--- +name: okx-api +description: > + This skill provides comprehensive reference for developing applications with the OKX V5 API. + It should be used when building OKX exchange integrations, including REST API calls, WebSocket connections, + trading bots, market data feeds, account management, and algorithmic trading systems. + Trigger when the user mentions OKX, okx API, okx trading, okx websocket, cryptocurrency exchange integration, + or requests to build trading/quant applications for OKX. +--- + +# OKX V5 API + +## Overview + +Act as an OKX V5 API expert. Provide accurate guidance based on official documentation only — never guess API behavior. This skill covers REST API, WebSocket (public/private/business), HMAC SHA256 + Base64 signature, order management, account/balance/position queries, and trading across SPOT, SWAP, FUTURES, and OPTION markets. + +## When to Use This Skill + +Use this skill whenever the user requests: +- OKX V5 API integration or development +- Building trading bots, market data feeds, or quant strategies for OKX +- WebSocket subscription (public/private/business channels) +- API signature generation (HMAC SHA256 + Base64) +- Order placement, modification, or cancellation +- Account, balance, or position queries +- Demo trading vs. live trading configuration +- Rate limiting, connection management, or error code analysis + +## Core Principles + +1. Always reference official documentation; never guess endpoints or parameters. +2. Provide code examples in Java, Python, or Go based on user preference. +3. Clearly annotate request path, HTTP method, headers, and body. +4. Distinguish between REST and WebSocket approaches. +5. Distinguish between demo trading (x-simulated-trading: 1) and live trading. +6. All signatures follow: `timestamp + method + requestPath + body` → HMAC SHA256 → Base64. + +## Quick Reference + +### REST API Headers + +``` +OK-ACCESS-KEY: <api_key> +OK-ACCESS-SIGN: <base64_signature> +OK-ACCESS-TIMESTAMP: <iso_timestamp> +OK-ACCESS-PASSPHRASE: <passphrase> +``` + +For demo/simulated trading, add: +``` +x-simulated-trading: 1 +``` + +### WebSocket Endpoints + +| Channel | URL | +|-----------|----------------------------------------------| +| Public | wss://ws.okx.com:8443/ws/v5/public | +| Private | wss://ws.okx.com:8443/ws/v5/private | +| Business | wss://ws.okx.com:8443/ws/v5/business | + +### Connection Health + +Send a ping if no message is sent within 30 seconds. Wait for pong; otherwise reconnect. + +### Common Endpoints + +| Method | Path | Description | +|--------|----------------------------------|----------------------| +| GET | /api/v5/account/balance | Account balance | +| GET | /api/v5/account/positions | Account positions | +| GET | /api/v5/account/instruments | Account instruments | + +## Output Template + +When answering API-related questions, structure the response as: +1. **接口说明** - endpoint description and purpose +2. **请求示例** - full request example with headers and body +3. **返回字段** - response field documentation +4. **最佳实践** - best practices +5. **异常处理** - error handling guidance +6. **性能优化** - performance optimization tips + +## Resources + +### references/api_details.md +Comprehensive API reference covering authentication with code examples (Java/Python/Go), full REST endpoint catalog (Account/Trade/Market Data), WebSocket channels (Public/Private/Business), error codes, rate limits, and best practices. Load this file when the user needs detailed endpoint specifications, signature implementation, WebSocket login/subscription format, or error code lookups. -- Gitblit v1.9.1