opentrade-cex
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenTrade CEX Trading
OpenTrade CEX 交易
29 API endpoints for centralized exchange trading — market data, account management, spot & futures orders, positions, leverage, and wallet agent.
IMPORTANT: This is a CEX (centralized exchange) trading skill. All trades are executed server-side with built-in risk controls — no private key management or transaction signing required.IMPORTANT: Write operations (place order, edit order, close position, set leverage) are protected by a 4-layer risk engine: price deviation check, position limit, rate limit, and balance verification.
包含29个用于中心化交易所交易的API端点——覆盖行情数据、账户管理、现货与期货订单、持仓、杠杆和钱包代理功能。
重要提示:这是一项**CEX(中心化交易所)**交易技能。所有交易都在服务端执行,内置风险控制机制——无需管理私钥或对交易签名。重要提示:写入操作(下单、编辑订单、平仓、设置杠杆)受四层风险引擎保护:价格偏差检查、持仓限额、速率限制和余额校验。
Pre-flight Checks
前置检查
Every time before running any CEX command, always follow these steps in order:
- Find or create a file in the project root to load the API credentials:
.env
bash
OPEN_TOKEN=your_token_hereGet your API token at: https://6551.io/mcp
Security warning: Never commit .env to git (add it to .gitignore) and never expose credentials in logs, screenshots, or chat messages.
- Set the base URL and auth header:
bash
BASE_URL="https://ai.6551.io"
AUTH_HEADER="Authorization: Bearer $OPEN_TOKEN"每次运行任何CEX命令前,请务必按顺序执行以下步骤:
- 找到或在项目根目录创建文件,用于加载API凭证:
.env
bash
OPEN_TOKEN=your_token_here获取你的API令牌:https://6551.io/mcp
安全警告:切勿将.env提交到git(请将其添加到.gitignore中),也切勿在日志、截图或聊天消息中泄露凭证。
- 设置基础URL和鉴权请求头:
bash
BASE_URL="https://ai.6551.io"
AUTH_HEADER="Authorization: Bearer $OPEN_TOKEN"Skill Routing
技能路由
- For DEX swaps / on-chain token exchange → use
opentrade-dex-swap - For on-chain wallet balances / portfolio → use
opentrade-portfolio - For on-chain market data / smart money signals → use
opentrade-market - For token search / holders / trending → use
opentrade-token - For custodial wallet (BSC/Solana) → use
opentrade-wallet - For transaction broadcasting / gas → use
opentrade-gateway - For CEX trading (spot, futures, leverage, orders, positions) → use this skill ()
opentrade-cex
- DEX兑换/链上代币交易 → 使用
opentrade-dex-swap - 链上钱包余额/资产组合 → 使用
opentrade-portfolio - 链上市场数据/聪明钱信号 → 使用
opentrade-market - 代币搜索/持币地址/热门代币 → 使用
opentrade-token - 托管钱包(BSC/Solana) → 使用
opentrade-wallet - 交易广播/Gas费处理 → 使用
opentrade-gateway - CEX交易(现货、期货、杠杆、订单、持仓) → 使用本技能()
opentrade-cex
Supported Exchanges
支持的交易所
| ExchangeID | Name |
|---|---|
| Binance |
| Bybit |
| OKX |
| Hyperliquid |
| Aster |
| 交易所ID | 名称 |
|---|---|
| Binance |
| Bybit |
| OKX |
| Hyperliquid |
| Aster |
Quickstart
快速开始
bash
undefinedbash
undefined1. Get real-time ticker
1. 获取实时行情
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/ticker?symbol=BTC/USDT&exchangeId=binance"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/ticker?symbol=BTC/USDT&exchangeId=binance"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
2. Check account balance
2. 查看账户余额
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/summary?exchangeId=binance&symbol=BTC/USDT:USDT"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/summary?exchangeId=binance&symbol=BTC/USDT:USDT"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
3. Place a limit buy order
3. 下限价买单
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"buy","type":"limit","quantity":0.001,"price":60000,"exchangeId":"binance"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"buy","type":"limit","quantity":0.001,"price":60000,"exchangeId":"binance"}'
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"buy","type":"limit","quantity":0.001,"price":60000,"exchangeId":"binance"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"buy","type":"limit","quantity":0.001,"price":60000,"exchangeId":"binance"}'
4. Check open orders
4. 查看未成交订单
curl -s "$BASE_URL/open/trader/newsliquid/v1/orders/open?exchangeId=binance"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
curl -s "$BASE_URL/open/trader/newsliquid/v1/orders/open?exchangeId=binance"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
5. Check current positions
5. 查看当前持仓
curl -s "$BASE_URL/open/trader/newsliquid/v1/positions?exchangeId=binance"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
curl -s "$BASE_URL/open/trader/newsliquid/v1/positions?exchangeId=binance"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
6. Close a position (market price)
6. 平仓(市价)
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/positions/close"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"long","quantity":0,"exchangeId":"binance"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"long","quantity":0,"exchangeId":"binance"}'
> **Note**: Trading pair format follows CCXT standard: `BTC/USDT` for spot, `BTC/USDT:USDT` for USDT perpetual contracts.curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/positions/close"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"long","quantity":0,"exchangeId":"binance"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"symbol":"BTC/USDT:USDT","side":"long","quantity":0,"exchangeId":"binance"}'
> **注意**:交易对格式遵循CCXT标准:现货用`BTC/USDT`,USDT永续合约用`BTC/USDT:USDT`。Command Index
命令索引
Market Data (no risk control)
行情数据(无风控)
| # | Endpoint | Method | Description |
|---|---|---|---|
| 1 | | GET | Get market metadata (trading pairs, precision, limits) |
| 2 | | GET | Get real-time ticker (last price, 24h change, volume) |
| 3 | | GET | Get K-line / candlestick data |
| 4 | | GET | Get base currency list (USDT, BTC, etc.) |
| 5 | | GET | Get server time |
| # | 端点 | 请求方法 | 描述 |
|---|---|---|---|
| 1 | | GET | 获取市场元数据(交易对、精度、交易限制) |
| 2 | | GET | 获取实时行情(最新价格、24小时涨跌幅、成交量) |
| 3 | | GET | 获取K线/蜡烛图数据 |
| 4 | | GET | 获取基础币种列表(USDT、BTC等) |
| 5 | | GET | 获取服务器时间 |
Account (no risk control)
账户(无风控)
| # | Endpoint | Method | Description |
|---|---|---|---|
| 6 | | GET | Account summary (balance, leverage, max position) |
| 7 | | GET | Query specific spot asset |
| 8 | | GET | Query all spot assets |
| # | 端点 | 请求方法 | 描述 |
|---|---|---|---|
| 6 | | GET | 账户摘要(余额、杠杆、最大持仓) |
| 7 | | GET | 查询指定现货资产 |
| 8 | | GET | 查询所有现货资产 |
Config (no risk control)
配置(无风控)
| # | Endpoint | Method | Description |
|---|---|---|---|
| 9 | | GET | Get trading config |
| 10 | | PUT | Update trading config |
| # | 端点 | 请求方法 | 描述 |
|---|---|---|---|
| 9 | | GET | 获取交易配置 |
| 10 | | PUT | 更新交易配置 |
Orders (risk control on create/edit)
订单(创建/编辑操作受风控)
| # | Endpoint | Method | Risk | Description |
|---|---|---|---|---|
| 11 | | POST | Yes | Place order (limit/market/stop-loss/take-profit) |
| 12 | | PUT | Yes | Edit existing order |
| 13 | | DELETE | No | Cancel order |
| 14 | | GET | No | List open orders |
| 15 | | GET | No | List closed orders |
| # | 端点 | 请求方法 | 受风控 | 描述 |
|---|---|---|---|---|
| 11 | | POST | 是 | 下单(限价/市价/止损/止盈) |
| 12 | | PUT | 是 | 编辑现有订单 |
| 13 | | DELETE | 否 | 取消订单 |
| 14 | | GET | 否 | 列出未成交订单 |
| 15 | | GET | 否 | 列出已完成订单 |
Positions (risk control on close)
持仓(平仓操作受风控)
| # | Endpoint | Method | Risk | Description |
|---|---|---|---|---|
| 16 | | GET | No | List current positions |
| 17 | | GET | No | List historical positions |
| 18 | | POST | Yes | Close position (market price) |
| # | 端点 | 请求方法 | 受风控 | 描述 |
|---|---|---|---|---|
| 16 | | GET | 否 | 列出当前持仓 |
| 17 | | GET | 否 | 列出历史持仓 |
| 18 | | POST | 是 | 平仓(市价) |
Trades (no risk control)
交易记录(无风控)
| # | Endpoint | Method | Description |
|---|---|---|---|
| 19 | | GET | Get trade execution history |
| # | 端点 | 请求方法 | 描述 |
|---|---|---|---|
| 19 | | GET | 获取交易执行历史 |
Leverage & Margin (risk control on leverage change)
杠杆与保证金(更改杠杆受风控)
| # | Endpoint | Method | Risk | Description |
|---|---|---|---|---|
| 20 | | GET | No | Get available leverage tiers |
| 21 | | GET | No | Get current leverage setting |
| 22 | | PUT | Yes | Set leverage multiplier |
| 23 | | GET | No | Get margin mode |
| 24 | | GET | No | Get position mode (one-way/hedge) |
| 25 | | PUT | No | Set position mode |
| # | 端点 | 请求方法 | 受风控 | 描述 |
|---|---|---|---|---|
| 20 | | GET | 否 | 获取可用杠杆档位 |
| 21 | | GET | 否 | 获取当前杠杆设置 |
| 22 | | PUT | 是 | 设置杠杆倍数 |
| 23 | | GET | 否 | 获取保证金模式 |
| 24 | | GET | 否 | 获取持仓模式(单向/双向) |
| 25 | | PUT | 否 | 设置持仓模式 |
Wallet Agent (no risk control)
钱包代理(无风控)
| # | Endpoint | Method | Description |
|---|---|---|---|
| 26 | | POST | Create wallet agent |
| 27 | | GET | List wallet agents |
| 28 | | GET | Query wallet agent by address |
| 29 | | PUT | Authorize wallet agent |
| # | 端点 | 请求方法 | 描述 |
|---|---|---|---|
| 26 | | POST | 创建钱包代理 |
| 27 | | GET | 列出钱包代理 |
| 28 | | GET | 按地址查询钱包代理 |
| 29 | | PUT | 授权钱包代理 |
API Reference
API 参考
1. Get Market Metadata
1. 获取市场元数据
获取指定交易对在所有交易所的市场元数据信息(交易对列表、合约类型、杠杆范围、最小下单量等)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/metadata?ticker=BTC" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Base currency code (e.g., |
Response:
json
{
"success": true,
"data": {
"ticker": "BTC",
"markets": [
{
"exchangeId": "binance",
"id": "BTCUSDT",
"symbol": "BTC/USDT",
"displaySymbol": "BTC/USDT",
"active": true,
"leverageMin": 1,
"leverageMax": 125,
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"settleCurrency": "USDT",
"type": "swap",
"rawType": "swap",
"costMin": 5.0,
"amountMin": 0.001,
"margin": true,
"spot": false,
"swap": true,
"future": false,
"option": false,
"contract": true
}
]
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- List available exchanges and trading pairs for the requested ticker
- Highlight leverage range, min order size, and contract type (spot/swap/future)
获取指定交易对在所有交易所的市场元数据信息(交易对列表、合约类型、杠杆范围、最小下单量等)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/metadata?ticker=BTC" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 基础币种代码(例如 |
返回结果:
json
{
"success": true,
"data": {
"ticker": "BTC",
"markets": [
{
"exchangeId": "binance",
"id": "BTCUSDT",
"symbol": "BTC/USDT",
"displaySymbol": "BTC/USDT",
"active": true,
"leverageMin": 1,
"leverageMax": 125,
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"settleCurrency": "USDT",
"type": "swap",
"rawType": "swap",
"costMin": 5.0,
"amountMin": 0.001,
"margin": true,
"spot": false,
"swap": true,
"future": false,
"option": false,
"contract": true
}
]
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- 列出请求币种支持的交易所和交易对
- 突出显示杠杆范围、最小下单量和合约类型(现货/永续/期货)
2. Get Ticker
2. 获取行情
获取指定交易所和交易对的实时行情数据。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/ticker?symbol=BTC/USDT&exchangeId=binance" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Trading pair in CCXT format (e.g., |
| String (query) | Yes | Exchange ID: |
Response:
json
{
"success": true,
"data": {
"symbol": "BTC/USDT",
"last": 67890.50,
"bid": 67889.00,
"ask": 67891.00,
"high": 68500.00,
"low": 66800.00,
"volume": 12345.678,
"timestamp": "2026-03-21T10:30:00Z"
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "BTC/USDT: $67,890.50"
- "Bid: $67,889 | Ask: $67,891"
- "24h High: $68,500 | Low: $66,800 | Volume: 12,345.68 BTC"
获取指定交易所和交易对的实时行情数据。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/ticker?symbol=BTC/USDT&exchangeId=binance" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | CCXT格式的交易对(例如 |
| String(查询参数) | 是 | 交易所ID: |
返回结果:
json
{
"success": true,
"data": {
"symbol": "BTC/USDT",
"last": 67890.50,
"bid": 67889.00,
"ask": 67891.00,
"high": 68500.00,
"low": 66800.00,
"volume": 12345.678,
"timestamp": "2026-03-21T10:30:00Z"
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "BTC/USDT: $67,890.50"
- "买一价: $67,889 | 卖一价: $67,891"
- "24小时最高价: $68,500 | 最低价: $66,800 | 成交量: 12,345.68 BTC"
3. Get K-Lines
3. 获取K线
获取 Binance K 线(蜡烛图)数据。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/klines?symbol=BTCUSDT&interval=1h&limit=100" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | No | Trading pair (default: |
| String (query) | No | K-line interval (default: |
| Integer (query) | No | Number of candles (default: 100) |
Response:
json
{
"success": true,
"data": [
{
"openTime": 1679400000000,
"open": "67800.00",
"high": "67900.00",
"low": "67750.00",
"close": "67850.00",
"volume": "123.456",
"closeTime": 1679400059999
}
],
"usage": {"cost": 1, "quota": 99}
}Display to user:
- Summarize recent price action (e.g., "BTC rose from $67,800 to $67,850 in the last hour")
- Mention support/resistance levels if visible
获取 Binance K 线(蜡烛图)数据。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/klines?symbol=BTCUSDT&interval=1h&limit=100" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 否 | 交易对(默认: |
| String(查询参数) | 否 | K线周期(默认: |
| Integer(查询参数) | 否 | K线数量(默认:100) |
返回结果:
json
{
"success": true,
"data": [
{
"openTime": 1679400000000,
"open": "67800.00",
"high": "67900.00",
"low": "67750.00",
"close": "67850.00",
"volume": "123.456",
"closeTime": 1679400059999
}
],
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- 总结近期价格走势(例如:"过去1小时BTC价格从$67,800上涨至$67,850")
- 如果有明显的支撑/阻力位可以提及
4. Get Base Currencies
4. 获取基础币种列表
获取所有交易所支持的去重基础币种列表。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/base-currencies" \
-H "$AUTH_HEADER"Parameters: None
Response:
json
{
"success": true,
"data": ["BTC", "ETH", "SOL", "DOGE", "XRP"],
"usage": {"cost": 1, "quota": 99}
}获取所有交易所支持的去重基础币种列表。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/base-currencies" \
-H "$AUTH_HEADER"参数: 无
返回结果:
json
{
"success": true,
"data": ["BTC", "ETH", "SOL", "DOGE", "XRP"],
"usage": {"cost": 1, "quota": 99}
}5. Get Server Time
5. 获取服务器时间
获取 ai-bots-trading 服务器的当前时间。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/time" \
-H "$AUTH_HEADER"Parameters: None
Response:
json
{
"timestamp": 1679400000000,
"time": "2026-03-21T10:30:00Z",
"usage": {"cost": 1, "quota": 99}
}获取 ai-bots-trading 服务器的当前时间。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/time" \
-H "$AUTH_HEADER"参数: 无
返回结果:
json
{
"timestamp": 1679400000000,
"time": "2026-03-21T10:30:00Z",
"usage": {"cost": 1, "quota": 99}
}6. Get Account Summary
6. 获取账户摘要
获取指定交易所的账户余额摘要信息,包括总余额、可用余额、杠杆分析等。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/summary?exchangeId=binance&symbol=BTC/USDT:USDT&accountType=swap" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Exchange ID |
| String (query) | No | Trading pair, for determining quote currency |
| String (query) | No | Account type (default: |
Response:
json
{
"success": true,
"data": {
"exchangeId": "binance",
"accountType": "swap",
"balance": 10000.00,
"available": 8500.00,
"currency": "USDT",
"leverage": 10,
"maxPosition": 85000.00,
"totals": {
"USDT": 10000.00,
"BTC": 0.05
},
"frees": {
"USDT": 8500.00,
"BTC": 0.05
},
"leverageAnalysis": {
"symbol": "BTC/USDT:USDT",
"exchangeId": "binance",
"availableBalance": 8500.00,
"balanceCurrency": "USDT",
"leverageInfo": {
"exchangeId": "binance",
"symbol": "BTC/USDT:USDT",
"tiers": [],
"supportsDynamicLeverage": true,
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"settleCurrency": "USDT",
"generatedAt": 1679400000000
},
"marketPrice": 67890.50
}
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "Total Balance: $10,000.00 USDT"
- "Available: $8,500.00 | Leverage: 10x"
- "Max Position: $85,000.00"
获取指定交易所的账户余额摘要信息,包括总余额、可用余额、杠杆分析等。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/summary?exchangeId=binance&symbol=BTC/USDT:USDT&accountType=swap" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 交易所ID |
| String(查询参数) | 否 | 交易对,用于确定计价币种 |
| String(查询参数) | 否 | 账户类型(默认: |
返回结果:
json
{
"success": true,
"data": {
"exchangeId": "binance",
"accountType": "swap",
"balance": 10000.00,
"available": 8500.00,
"currency": "USDT",
"leverage": 10,
"maxPosition": 85000.00,
"totals": {
"USDT": 10000.00,
"BTC": 0.05
},
"frees": {
"USDT": 8500.00,
"BTC": 0.05
},
"leverageAnalysis": {
"symbol": "BTC/USDT:USDT",
"exchangeId": "binance",
"availableBalance": 8500.00,
"balanceCurrency": "USDT",
"leverageInfo": {
"exchangeId": "binance",
"symbol": "BTC/USDT:USDT",
"tiers": [],
"supportsDynamicLeverage": true,
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"settleCurrency": "USDT",
"generatedAt": 1679400000000
},
"marketPrice": 67890.50
}
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "总余额: $10,000.00 USDT"
- "可用余额: $8,500.00 | 杠杆: 10x"
- "最大持仓额: $85,000.00"
7. Get Spot Asset
7. 获取现货资产
查询指定交易所和交易对的现货资产持有信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/spot?exchangeId=binance&symbol=BTC/USDT" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Exchange ID |
| String (query) | Yes | Trading pair (e.g., |
Response:
json
{
"success": true,
"data": {
"exchangeId": "binance",
"symbol": "BTC/USDT",
"baseAsset": "BTC",
"quantity": 0.5,
"free": 0.45,
"locked": 0.05,
"costPrice": 65000.00,
"totalCost": 32500.00
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "BTC: 0.5 (Free: 0.45, Locked: 0.05)"
- "Avg Cost: $65,000 | Total Cost: $32,500"
查询指定交易所和交易对的现货资产持有信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/spot?exchangeId=binance&symbol=BTC/USDT" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 交易所ID |
| String(查询参数) | 是 | 交易对(例如 |
返回结果:
json
{
"success": true,
"data": {
"exchangeId": "binance",
"symbol": "BTC/USDT",
"baseAsset": "BTC",
"quantity": 0.5,
"free": 0.45,
"locked": 0.05,
"costPrice": 65000.00,
"totalCost": 32500.00
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "BTC: 0.5(可用: 0.45, 冻结: 0.05)"
- "平均成本: $65,000 | 总成本: $32,500"
8. Get All Spot Assets
8. 获取所有现货资产
获取指定交易所的所有现货资产列表。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/spots?exchangeId=binance" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Exchange ID |
| String (query) | No | Filter by trading pair |
Response:
json
{
"success": true,
"data": [
{
"exchangeId": "binance",
"symbol": null,
"baseAsset": "BTC",
"quantity": 0.5,
"free": 0.45,
"locked": 0.05,
"costPrice": 65000.00,
"totalCost": 32500.00
},
{
"exchangeId": "binance",
"symbol": null,
"baseAsset": "USDT",
"quantity": 10000.00,
"free": 8500.00,
"locked": 1500.00,
"costPrice": 1.00,
"totalCost": 10000.00
}
],
"usage": {"cost": 1, "quota": 99}
}Display to user:
- List all assets with non-zero balances, showing free/locked split and cost basis
获取指定交易所的所有现货资产列表。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/account/spots?exchangeId=binance" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 交易所ID |
| String(查询参数) | 否 | 按交易对过滤 |
返回结果:
json
{
"success": true,
"data": [
{
"exchangeId": "binance",
"symbol": null,
"baseAsset": "BTC",
"quantity": 0.5,
"free": 0.45,
"locked": 0.05,
"costPrice": 65000.00,
"totalCost": 32500.00
},
{
"exchangeId": "binance",
"symbol": null,
"baseAsset": "USDT",
"quantity": 10000.00,
"free": 8500.00,
"locked": 1500.00,
"costPrice": 1.00,
"totalCost": 10000.00
}
],
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- 列出所有余额不为零的资产,展示可用/冻结拆分和成本基准
9. Get Trading Config
9. 获取交易配置
获取用户的交易配置摘要(不包含密钥敏感信息)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/config" \
-H "$AUTH_HEADER"Parameters: None
Response:
json
{
"success": true,
"data": {
"defaultExchange": "binance",
"defaultLeverage": 10,
"defaultPosition": 100.0,
"general": {},
"binanceConfigured": true,
"bybitConfigured": false,
"okxConfigured": true,
"hyperliquidConfigured": false,
"asterConfigured": false
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "Default Exchange: binance | Leverage: 10x | Position: $100"
- List which exchanges are configured
获取用户的交易配置摘要(不包含密钥敏感信息)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/config" \
-H "$AUTH_HEADER"参数: 无
返回结果:
json
{
"success": true,
"data": {
"defaultExchange": "binance",
"defaultLeverage": 10,
"defaultPosition": 100.0,
"general": {},
"binanceConfigured": true,
"bybitConfigured": false,
"okxConfigured": true,
"hyperliquidConfigured": false,
"asterConfigured": false
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "默认交易所: binance | 杠杆: 10x | 持仓额: $100"
- 列出已配置的交易所
10. Update Trading Config
10. 更新交易配置
更新用户的交易配置,包括默认交易所、杠杆和交易所凭证。
IMPORTANT: Exchange API credentials (,apiKey,secret) are sensitive. Never log or display them.password
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/config" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"defaultExchange": "binance",
"defaultLeverage": 10,
"defaultPosition": 100.0,
"binance": {
"apiKey": "your-api-key",
"secret": "your-api-secret",
"password": ""
}
}'Parameters (body):
| Field | Type | Required | Description |
|---|---|---|---|
| String | No | Default exchange: |
| Integer | No | Default leverage (1-125) |
| Float | No | Default position size |
| Object | No | General config |
| Object | No | Exchange credentials: |
Response:
json
{
"success": true,
"data": {
"updated": true
},
"usage": {"cost": 1, "quota": 99}
}更新用户的交易配置,包括默认交易所、杠杆和交易所凭证。
重要提示:交易所API凭证(、apiKey、secret)属于敏感信息,切勿记录或展示。password
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/config" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"defaultExchange": "binance",
"defaultLeverage": 10,
"defaultPosition": 100.0,
"binance": {
"apiKey": "your-api-key",
"secret": "your-api-secret",
"password": ""
}
}'参数(请求体):
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 否 | 默认交易所: |
| Integer | 否 | 默认杠杆(1-125) |
| Float | 否 | 默认持仓额 |
| Object | 否 | 通用配置 |
| Object | 否 | 交易所凭证: |
返回结果:
json
{
"success": true,
"data": {
"updated": true
},
"usage": {"cost": 1, "quota": 99}
}11. Place Order (Risk Controlled)
11. 下单(受风控)
在指定交易所下单。支持多种订单类型。
This endpoint is protected by the risk engine — orders that deviate too far from market price, exceed position limits, hit rate limits, or lack sufficient balance will be rejected.
bash
undefined在指定交易所下单。支持多种订单类型。
该端点受风险引擎保护——与市场价格偏差过大、超出持仓限额、触发速率限制或余额不足的订单将被拒绝。
bash
undefinedLimit order: buy 0.01 BTC at $65,000 with TP/SL
限价单:以$65,000买入0.01 BTC,附带止盈止损
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "buy", "type": "limit", "quantity": 0.01, "price": 65000.00, "stopLossPrice": 64000.00, "takeProfitPrice": 70000.00 }'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "buy", "type": "limit", "quantity": 0.01, "price": 65000.00, "stopLossPrice": 64000.00, "takeProfitPrice": 70000.00 }'
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "buy", "type": "limit", "quantity": 0.01, "price": 65000.00, "stopLossPrice": 64000.00, "takeProfitPrice": 70000.00 }'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "buy", "type": "limit", "quantity": 0.01, "price": 65000.00, "stopLossPrice": 64000.00, "takeProfitPrice": 70000.00 }'
Market order: sell 0.5 ETH
市价单:卖出0.5 ETH
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "ETH/USDT:USDT", "side": "sell", "type": "market", "quantity": 0.5 }'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "ETH/USDT:USDT", "side": "sell", "type": "market", "quantity": 0.5 }'
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "ETH/USDT:USDT", "side": "sell", "type": "market", "quantity": 0.5 }'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "ETH/USDT:USDT", "side": "sell", "type": "market", "quantity": 0.5 }'
Stop-loss market order
止损市价单
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "sell", "type": "stop_market", "quantity": 0.01, "triggerPrice": 58000.00 }'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "sell", "type": "stop_market", "quantity": 0.01, "triggerPrice": 58000.00 }'
**Parameters (body):**
| Field | Type | Required | Description |
|---|---|---|---|
| `exchangeId` | String | No | Exchange ID (default: `binance`) |
| `symbol` | String | Yes | Trading pair in CCXT format (e.g., `BTC/USDT:USDT`) |
| `side` | String | Yes | `buy` or `sell` |
| `type` | String | Yes | Order type (see below) |
| `quantity` | Float | Conditional | Base currency quantity |
| `quoteAmount` | Float | Conditional | Quote currency amount (e.g., USDT) |
| `price` | Float | Conditional | Limit price, required for `limit`, `stop_limit`, `take_profit_limit` |
| `triggerPrice` | Float | Conditional | Trigger price, required for `stop_market`, `stop_limit`, `take_profit_market`, `take_profit_limit` |
| `hedged` | Boolean | No | Hedge mode (default: `false`) |
| `stopLossPrice` | Float | No | Attached stop-loss trigger price |
| `takeProfitPrice` | Float | No | Attached take-profit trigger price |
**Order types:**
- `market` — Market order
- `limit` — Limit order
- `oco` — OCO order
- `stop_market` — Stop-loss market order
- `stop_limit` — Stop-loss limit order
- `take_profit_market` — Take-profit market order
- `take_profit_limit` — Take-profit limit order
**Response:**
```json
{
"success": true,
"data": {
"exchange": "binance",
"orderId": "123456789",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"type": "limit",
"amount": 0.01,
"price": 65000.00,
"triggerPrice": 0,
"status": "open",
"filledQty": 0,
"avgPrice": 0,
"reduceOnly": false,
"createdAt": "2026-03-21T10:30:00Z",
"tpsl": {
"tpTriggerPx": 70000.00,
"tpTriggerPxType": "last",
"tpOrdPx": -1,
"slTriggerPx": 64000.00,
"slTriggerPxType": "last",
"slOrdPx": -1,
"attachId": "attach_001",
"closePosition": false
}
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "Order placed! ID: 123456789"
- "Buy 0.01 BTC @ $65,000 (Limit) on Binance"
- "TP: $70,000 | SL: $64,000"
- "Status: Open"
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "sell", "type": "stop_market", "quantity": 0.01, "triggerPrice": 58000.00 }'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{ "exchangeId": "binance", "symbol": "BTC/USDT:USDT", "side": "sell", "type": "stop_market", "quantity": 0.01, "triggerPrice": 58000.00 }'
**参数(请求体):**
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| `exchangeId` | String | 否 | 交易所ID(默认:`binance`) |
| `symbol` | String | 是 | CCXT格式的交易对(例如`BTC/USDT:USDT`) |
| `side` | String | 是 | `buy`(买)或`sell`(卖) |
| `type` | String | 是 | 订单类型(见下方) |
| `quantity` | Float | 条件必填 | 基础币种数量 |
| `quoteAmount` | Float | 条件必填 | 计价币种金额(例如USDT) |
| `price` | Float | 条件必填 | 限价,`limit`、`stop_limit`、`take_profit_limit`类型订单必填 |
| `triggerPrice` | Float | 条件必填 | 触发价格,`stop_market`、`stop_limit`、`take_profit_market`、`take_profit_limit`类型订单必填 |
| `hedged` | Boolean | 否 | 对冲模式(默认:`false`) |
| `stopLossPrice` | Float | 否 | 附带的止损触发价格 |
| `takeProfitPrice` | Float | 否 | 附带的止盈触发价格 |
**订单类型:**
- `market` — 市价单
- `limit` — 限价单
- `oco` — OCO订单
- `stop_market` — 止损市价单
- `stop_limit` — 止损限价单
- `take_profit_market` — 止盈市价单
- `take_profit_limit` — 止盈限价单
**返回结果:**
```json
{
"success": true,
"data": {
"exchange": "binance",
"orderId": "123456789",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"type": "limit",
"amount": 0.01,
"price": 65000.00,
"triggerPrice": 0,
"status": "open",
"filledQty": 0,
"avgPrice": 0,
"reduceOnly": false,
"createdAt": "2026-03-21T10:30:00Z",
"tpsl": {
"tpTriggerPx": 70000.00,
"tpTriggerPxType": "last",
"tpOrdPx": -1,
"slTriggerPx": 64000.00,
"slTriggerPxType": "last",
"slOrdPx": -1,
"attachId": "attach_001",
"closePosition": false
}
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "订单已提交!ID: 123456789"
- "在Binance以$65,000(限价)买入0.01 BTC"
- "止盈: $70,000 | 止损: $64,000"
- "状态: 未成交"
12. Edit Order (Risk Controlled)
12. 编辑订单(受风控)
修改已存在的挂单参数。
This endpoint is protected by the risk engine.
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/orders/edit" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"exchangeId": "binance",
"orderId": "123456789",
"symbol": "BTC/USDT:USDT",
"type": "limit",
"side": "buy",
"quantity": 0.02,
"price": 64500.00
}'Parameters (body):
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | Exchange ID |
| String | No | Order ID (Binance TP/SL orders can omit) |
| String | Yes | Trading pair |
| String | No | Order type |
| String | No | Direction |
| Float | No | New quantity |
| Float | No | New limit price |
| Float | No | New trigger price |
| Float | No | New stop-loss price |
| Float | No | New take-profit price |
| Boolean | No | Hedge mode |
Response: Same structure as Place Order.
OrderResponse修改已存在的挂单参数。
该端点受风险引擎保护。
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/orders/edit" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"exchangeId": "binance",
"orderId": "123456789",
"symbol": "BTC/USDT:USDT",
"type": "limit",
"side": "buy",
"quantity": 0.02,
"price": 64500.00
}'参数(请求体):
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 交易所ID |
| String | 否 | 订单ID(Binance止盈止损订单可省略) |
| String | 是 | 交易对 |
| String | 否 | 订单类型 |
| String | 否 | 交易方向 |
| Float | 否 | 新的数量 |
| Float | 否 | 新的限价 |
| Float | 否 | 新的触发价格 |
| Float | 否 | 新的止损价格 |
| Float | 否 | 新的止盈价格 |
| Boolean | 否 | 对冲模式 |
返回结果: 与下单接口的结构相同。
OrderResponse13. Cancel Order
13. 取消订单
取消指定的挂单。
bash
curl -s -X DELETE "$BASE_URL/open/trader/newsliquid/v1/orders/123456789?exchangeId=binance&symbol=BTC/USDT:USDT" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (path) | Yes | Order ID (in URL path) |
| String (query) | Yes | Exchange ID |
| String (query) | Yes | Trading pair |
| String (query) | No | Order type (required for TP/SL orders) |
Response:
json
{
"success": true,
"data": {
"cancelled": true
},
"usage": {"cost": 1, "quota": 99}
}取消指定的挂单。
bash
curl -s -X DELETE "$BASE_URL/open/trader/newsliquid/v1/orders/123456789?exchangeId=binance&symbol=BTC/USDT:USDT" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(路径参数) | 是 | 订单ID(在URL路径中) |
| String(查询参数) | 是 | 交易所ID |
| String(查询参数) | 是 | 交易对 |
| String(查询参数) | 否 | 订单类型(止盈止损订单必填) |
返回结果:
json
{
"success": true,
"data": {
"cancelled": true
},
"usage": {"cost": 1, "quota": 99}
}14. List Open Orders
14. 列出未成交订单
获取当前所有未成交的挂单。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/orders/open?exchangeId=binance&symbol=BTC/USDT:USDT" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | No | Exchange ID (omit for all exchanges) |
| String (query) | No | Filter by trading pair |
| Integer (query) | No | Filter by creation time (days) |
Response:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"orderId": "123456789",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"type": "limit",
"amount": 0.01,
"price": 65000.00,
"triggerPrice": 0,
"status": "open",
"filledQty": 0,
"avgPrice": 0,
"reduceOnly": false,
"createdAt": "2026-03-21T10:30:00Z",
"tpsl": null
}
],
"usage": {"cost": 1, "quota": 99}
}Display to user:
- Table of open orders with exchange, ID, pair, side, type, amount, price, status
获取当前所有未成交的挂单。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/orders/open?exchangeId=binance&symbol=BTC/USDT:USDT" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 否 | 交易所ID(省略则查询所有交易所) |
| String(查询参数) | 否 | 按交易对过滤 |
| Integer(查询参数) | 否 | 按创建时间过滤(天) |
返回结果:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"orderId": "123456789",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"type": "limit",
"amount": 0.01,
"price": 65000.00,
"triggerPrice": 0,
"status": "open",
"filledQty": 0,
"avgPrice": 0,
"reduceOnly": false,
"createdAt": "2026-03-21T10:30:00Z",
"tpsl": null
}
],
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- 以表格形式展示未成交订单,包含交易所、ID、交易对、方向、类型、数量、价格、状态
15. List Closed Orders
15. 列出已完成订单
获取已完成(成交/取消)的历史订单。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/orders/closed?exchangeId=binance&symbol=BTC/USDT:USDT&days=7" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | No | Exchange ID (omit for all exchanges) |
| String (query) | No | Filter by trading pair |
| Integer (query) | No | Filter by days (default: 7) |
Response: Same structure as List Open Orders.
[]OrderResponse获取已完成(成交/取消)的历史订单。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/orders/closed?exchangeId=binance&symbol=BTC/USDT:USDT&days=7" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 否 | 交易所ID(省略则查询所有交易所) |
| String(查询参数) | 否 | 按交易对过滤 |
| Integer(查询参数) | 否 | 按天数过滤(默认:7) |
返回结果: 与未成交订单列表的结构相同。
[]OrderResponse16. List Current Positions
16. 列出当前持仓
获取当前所有持仓信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/positions?exchangeId=binance" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | No | Exchange ID (omit for all exchanges) |
| String (query) | No | Filter by trading pair |
Response:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"symbol": "BTC/USDT:USDT",
"side": "long",
"contracts": 0.01,
"entryPrice": 65000.00,
"markPrice": 67890.50,
"unrealizedPnl": 28.905,
"leverage": 10,
"liquidationPrice": 58500.00,
"marginMode": "cross",
"hedged": false,
"timestamp": 1679400000000
}
],
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "BTC/USDT:USDT Long 0.01 BTC (Binance)"
- "Entry: $65,000 | Mark: $67,890.50"
- "P&L: +$28.91 (+4.45%)"
- "Leverage: 10x Cross | Liq: $58,500"
获取当前所有持仓信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/positions?exchangeId=binance" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 否 | 交易所ID(省略则查询所有交易所) |
| String(查询参数) | 否 | 按交易对过滤 |
返回结果:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"symbol": "BTC/USDT:USDT",
"side": "long",
"contracts": 0.01,
"entryPrice": 65000.00,
"markPrice": 67890.50,
"unrealizedPnl": 28.905,
"leverage": 10,
"liquidationPrice": 58500.00,
"marginMode": "cross",
"hedged": false,
"timestamp": 1679400000000
}
],
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "BTC/USDT:USDT 多仓 0.01 BTC(Binance)"
- "开仓价: $65,000 | 标记价格: $67,890.50"
- "未实现盈亏: +$28.91 (+4.45%)"
- "杠杆: 10x 全仓 | 爆仓价: $58,500"
17. List Historical Positions
17. 列出历史持仓
获取已平仓的历史持仓记录(包含关联的交易明细)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/positions/history?exchangeId=binance&days=7" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | No | Exchange ID |
| String (query) | No | Filter by trading pair |
| Integer (query) | No | Filter by days (default: 0 = all) |
Response:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"symbol": "BTC/USDT:USDT",
"side": "long",
"marginMode": "cross",
"leverage": 10,
"entryPrice": 65000.00,
"openDateTime": "2026-03-20T08:00:00Z",
"openTimestamp": 1679313600000,
"closePrice": 67500.00,
"fullyClosed": true,
"closeDateTime": "2026-03-21T10:30:00Z",
"closeTimestamp": 1679400600000,
"closedAmount": 0.01,
"totalAmount": 0.01,
"realizedPnl": 25.00,
"totalFee": 1.30,
"tradeCount": 2,
"openTrades": 1,
"closeTrades": 1,
"trades": [
{
"exchange": "binance",
"tradeId": "trade_001",
"orderId": "order_001",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"price": 65000.00,
"amount": 0.01,
"cost": 650.00,
"fee": 0.65,
"pnl": 0,
"reduceOnly": false,
"timestamp": 1679313600000,
"datetime": "2026-03-20T08:00:00Z"
},
{
"exchange": "binance",
"tradeId": "trade_002",
"orderId": "order_002",
"symbol": "BTC/USDT:USDT",
"side": "sell",
"price": 67500.00,
"amount": 0.01,
"cost": 675.00,
"fee": 0.65,
"pnl": 25.00,
"reduceOnly": true,
"timestamp": 1679400600000,
"datetime": "2026-03-21T10:30:00Z"
}
]
}
],
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "BTC/USDT:USDT Long — Closed"
- "Entry: $65,000 → Exit: $67,500"
- "Realized P&L: +$25.00 (Fee: $1.30)"
- "Duration: ~26.5 hours"
获取已平仓的历史持仓记录(包含关联的交易明细)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/positions/history?exchangeId=binance&days=7" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 否 | 交易所ID |
| String(查询参数) | 否 | 按交易对过滤 |
| Integer(查询参数) | 否 | 按天数过滤(默认:0 = 全部) |
返回结果:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"symbol": "BTC/USDT:USDT",
"side": "long",
"marginMode": "cross",
"leverage": 10,
"entryPrice": 65000.00,
"openDateTime": "2026-03-20T08:00:00Z",
"openTimestamp": 1679313600000,
"closePrice": 67500.00,
"fullyClosed": true,
"closeDateTime": "2026-03-21T10:30:00Z",
"closeTimestamp": 1679400600000,
"closedAmount": 0.01,
"totalAmount": 0.01,
"realizedPnl": 25.00,
"totalFee": 1.30,
"tradeCount": 2,
"openTrades": 1,
"closeTrades": 1,
"trades": [
{
"exchange": "binance",
"tradeId": "trade_001",
"orderId": "order_001",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"price": 65000.00,
"amount": 0.01,
"cost": 650.00,
"fee": 0.65,
"pnl": 0,
"reduceOnly": false,
"timestamp": 1679313600000,
"datetime": "2026-03-20T08:00:00Z"
},
{
"exchange": "binance",
"tradeId": "trade_002",
"orderId": "order_002",
"symbol": "BTC/USDT:USDT",
"side": "sell",
"price": 67500.00,
"amount": 0.01,
"cost": 675.00,
"fee": 0.65,
"pnl": 25.00,
"reduceOnly": true,
"timestamp": 1679400600000,
"datetime": "2026-03-21T10:30:00Z"
}
]
}
],
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "BTC/USDT:USDT 多仓 — 已平仓"
- "开仓价: $65,000 → 平仓价: $67,500"
- "已实现盈亏: +$25.00(手续费: $1.30)"
- "持仓时长: ~26.5小时"
18. Close Position (Risk Controlled)
18. 平仓(受风控)
关闭指定的持仓(全部或部分平仓)。
This endpoint is protected by the risk engine.
bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/positions/close" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"exchangeId": "binance",
"symbol": "BTC/USDT:USDT",
"side": "long",
"quantity": 0,
"hedged": false
}'Parameters (body):
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | Exchange ID |
| String | Yes | Trading pair |
| String | Yes | Position side: |
| Float | No | Close quantity (0 = close all) |
| Boolean | No | Hedge mode |
| Float | No | Market price for Hyperliquid |
Response: Same structure as Place Order.
OrderResponseDisplay to user:
- "Position closed! BTC/USDT:USDT Long"
- Show realized P&L from the order response
关闭指定的持仓(全部或部分平仓)。
该端点受风险引擎保护。
bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/positions/close" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"exchangeId": "binance",
"symbol": "BTC/USDT:USDT",
"side": "long",
"quantity": 0,
"hedged": false
}'参数(请求体):
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 交易所ID |
| String | 是 | 交易对 |
| String | 是 | 持仓方向: |
| Float | 否 | 平仓数量(0 = 全部平仓) |
| Boolean | 否 | 对冲模式 |
| Float | 否 | Hyperliquid的市价 |
返回结果: 与下单接口的结构相同。
OrderResponse向用户展示内容:
- "持仓已平仓!BTC/USDT:USDT 多仓"
- 展示订单返回结果中的已实现盈亏
19. Get Trade History
19. 获取交易历史
获取历史成交记录。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/trades/history?exchangeId=binance&symbol=BTC/USDT:USDT&days=7" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | No | Exchange ID |
| String (query) | No | Filter by trading pair |
| Integer (query) | No | Filter by days (default: 7) |
Response:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"tradeId": "trade_001",
"orderId": "order_001",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"price": 65000.00,
"amount": 0.01,
"cost": 650.00,
"fee": 0.65,
"pnl": 0,
"reduceOnly": false,
"timestamp": 1679313600000,
"datetime": "2026-03-20T08:00:00Z"
}
],
"usage": {"cost": 1, "quota": 99}
}Display to user:
- Table of trades with exchange, pair, side, price, amount, cost, fee, P&L
获取历史成交记录。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/trades/history?exchangeId=binance&symbol=BTC/USDT:USDT&days=7" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 否 | 交易所ID |
| String(查询参数) | 否 | 按交易对过滤 |
| Integer(查询参数) | 否 | 按天数过滤(默认:7) |
返回结果:
json
{
"success": true,
"data": [
{
"exchange": "binance",
"tradeId": "trade_001",
"orderId": "order_001",
"symbol": "BTC/USDT:USDT",
"side": "buy",
"price": 65000.00,
"amount": 0.01,
"cost": 650.00,
"fee": 0.65,
"pnl": 0,
"reduceOnly": false,
"timestamp": 1679313600000,
"datetime": "2026-03-20T08:00:00Z"
}
],
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- 以表格形式展示交易记录,包含交易所、交易对、方向、价格、数量、成本、手续费、盈亏
20. Get Leverage Tiers
20. 获取杠杆档位
获取指定交易对的杠杆档位(梯度)信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/leverage?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Trading pair |
| String (query) | Yes | Exchange ID |
Response:
json
{
"success": true,
"data": {
"exchangeId": "binance",
"symbol": "BTC/USDT:USDT",
"tiers": [
{
"tier": 1,
"minNotional": 0,
"maxNotional": 50000,
"maintenanceMarginRate": 0.004,
"initialMarginRate": 0.01,
"maxLeverage": 100
},
{
"tier": 2,
"minNotional": 50000,
"maxNotional": 250000,
"maintenanceMarginRate": 0.005,
"initialMarginRate": 0.02,
"maxLeverage": 50
}
],
"supportsDynamicLeverage": true,
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"settleCurrency": "USDT",
"minNotional": 5.0,
"generatedAt": 1679400000000
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- Table of leverage tiers with max leverage, notional range, and margin rates
获取指定交易对的杠杆档位(梯度)信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/leverage?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 交易对 |
| String(查询参数) | 是 | 交易所ID |
返回结果:
json
{
"success": true,
"data": {
"exchangeId": "binance",
"symbol": "BTC/USDT:USDT",
"tiers": [
{
"tier": 1,
"minNotional": 0,
"maxNotional": 50000,
"maintenanceMarginRate": 0.004,
"initialMarginRate": 0.01,
"maxLeverage": 100
},
{
"tier": 2,
"minNotional": 50000,
"maxNotional": 250000,
"maintenanceMarginRate": 0.005,
"initialMarginRate": 0.02,
"maxLeverage": 50
}
],
"supportsDynamicLeverage": true,
"baseCurrency": "BTC",
"quoteCurrency": "USDT",
"settleCurrency": "USDT",
"minNotional": 5.0,
"generatedAt": 1679400000000
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- 以表格形式展示杠杆档位,包含最大杠杆、名义价值范围和保证金率
21. Get Current Leverage
21. 获取当前杠杆
获取指定交易对当前设置的杠杆倍数和保证金模式。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/leverage/current?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Trading pair |
| String (query) | Yes | Exchange ID |
Response:
json
{
"success": true,
"data": {
"leverage": 10,
"marginMode": "cross"
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "BTC/USDT:USDT: 10x leverage, Cross margin"
获取指定交易对当前设置的杠杆倍数和保证金模式。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/leverage/current?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 交易对 |
| String(查询参数) | 是 | 交易所ID |
返回结果:
json
{
"success": true,
"data": {
"leverage": 10,
"marginMode": "cross"
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "BTC/USDT:USDT: 10倍杠杆,全仓保证金"
22. Set Leverage (Risk Controlled)
22. 设置杠杆(受风控)
设置指定交易对的杠杆倍数。
This endpoint is protected by the risk engine.
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/leverage/current" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"exchangeId":"binance","symbol":"BTC/USDT:USDT","leverage":20}'Parameters (body):
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | Exchange ID |
| String | Yes | Trading pair |
| Integer | Yes | Leverage multiplier (min: 1) |
Response:
json
{
"success": true,
"data": {
"updated": true
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "Leverage updated! BTC/USDT:USDT: 20x"
设置指定交易对的杠杆倍数。
该端点受风险引擎保护。
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/leverage/current" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"exchangeId":"binance","symbol":"BTC/USDT:USDT","leverage":20}'参数(请求体):
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 交易所ID |
| String | 是 | 交易对 |
| Integer | 是 | 杠杆倍数(最小:1) |
返回结果:
json
{
"success": true,
"data": {
"updated": true
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "杠杆已更新!BTC/USDT:USDT: 20x"
23. Get Margin Mode
23. 获取保证金模式
获取指定交易对的保证金模式(cross 全仓 / isolated 逐仓)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/margin/mode?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Trading pair |
| String (query) | Yes | Exchange ID |
Response:
json
{
"success": true,
"data": {
"marginMode": "cross"
},
"usage": {"cost": 1, "quota": 99}
}获取指定交易对的保证金模式(cross 全仓 / isolated 逐仓)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/margin/mode?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 交易对 |
| String(查询参数) | 是 | 交易所ID |
返回结果:
json
{
"success": true,
"data": {
"marginMode": "cross"
},
"usage": {"cost": 1, "quota": 99}
}24. Get Position Mode
24. 获取持仓模式
获取指定交易对的持仓模式(单向/双向)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/position/mode?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | Yes | Trading pair |
| String (query) | Yes | Exchange ID |
Response:
json
{
"success": true,
"data": {
"hedged": false,
"positionMode": "one_way"
},
"usage": {"cost": 1, "quota": 99}
}获取指定交易对的持仓模式(单向/双向)。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/position/mode?symbol=BTC/USDT:USDT&exchangeId=binance" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 是 | 交易对 |
| String(查询参数) | 是 | 交易所ID |
返回结果:
json
{
"success": true,
"data": {
"hedged": false,
"positionMode": "one_way"
},
"usage": {"cost": 1, "quota": 99}
}25. Set Position Mode
25. 设置持仓模式
设置指定交易对的持仓模式。
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/position/mode" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"exchangeId":"binance","symbol":"BTC/USDT:USDT","hedged":true}'Parameters (body):
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | Exchange ID |
| String | Yes | Trading pair |
| Boolean | Yes | |
Response:
json
{
"success": true,
"data": {
"updated": true
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "Position mode updated to Hedge (two-way)"
设置指定交易对的持仓模式。
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/position/mode" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"exchangeId":"binance","symbol":"BTC/USDT:USDT","hedged":true}'参数(请求体):
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 交易所ID |
| String | 是 | 交易对 |
| Boolean | 是 | |
返回结果:
json
{
"success": true,
"data": {
"updated": true
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "持仓模式已更新为对冲(双向)模式"
26. Create Wallet Agent
26. 创建钱包代理
创建一个新的以太坊钱包代理(用于 Aster 或 Hyperliquid 交易)。
bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/walletagent/create" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"exchange":"hyperliquid"}'Parameters (body):
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | Exchange type: |
Response:
json
{
"success": true,
"data": {
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "",
"exchange": "hyperliquid",
"authorized": false,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T10:30:00Z"
},
"usage": {"cost": 1, "quota": 99}
}Display to user:
- "Wallet agent created!"
- "Agent Address: 0x1234..."
- "Exchange: Hyperliquid"
- "Status: Not authorized (run authorize to activate)"
创建一个新的以太坊钱包代理(用于Aster或Hyperliquid交易)。
bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/walletagent/create" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"exchange":"hyperliquid"}'参数(请求体):
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 交易所类型: |
返回结果:
json
{
"success": true,
"data": {
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "",
"exchange": "hyperliquid",
"authorized": false,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T10:30:00Z"
},
"usage": {"cost": 1, "quota": 99}
}向用户展示内容:
- "钱包代理已创建!"
- "代理地址: 0x1234..."
- "交易所: Hyperliquid"
- "状态: 未授权(运行授权接口激活)"
27. List Wallet Agents
27. 列出钱包代理
获取当前用户的所有钱包代理列表。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/walletagent/list?exchange=hyperliquid" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (query) | No | Filter by exchange type: |
Response:
json
{
"success": true,
"data": [
{
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "0xabcdef1234567890...",
"exchange": "hyperliquid",
"authorized": true,
"expiredAt": 1681992600000,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T10:30:00Z"
}
],
"usage": {"cost": 1, "quota": 99}
}获取当前用户的所有钱包代理列表。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/walletagent/list?exchange=hyperliquid" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(查询参数) | 否 | 按交易所类型过滤: |
返回结果:
json
{
"success": true,
"data": [
{
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "0xabcdef1234567890...",
"exchange": "hyperliquid",
"authorized": true,
"expiredAt": 1681992600000,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T10:30:00Z"
}
],
"usage": {"cost": 1, "quota": 99}
}28. Query Wallet Agent by Address
28. 按地址查询钱包代理
根据钱包地址获取钱包代理信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/walletagent/address/0x1234567890abcdef?exchange=hyperliquid" \
-H "$AUTH_HEADER"Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String (path) | Yes | Wallet address (in URL path) |
| String (query) | No | Filter by exchange type |
Response:
json
{
"success": true,
"data": {
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "0xabcdef1234567890...",
"exchange": "hyperliquid",
"authorized": true,
"expiredAt": 1681992600000,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T10:30:00Z"
},
"usage": {"cost": 1, "quota": 99}
}根据钱包地址获取钱包代理信息。
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/walletagent/address/0x1234567890abcdef?exchange=hyperliquid" \
-H "$AUTH_HEADER"参数:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String(路径参数) | 是 | 钱包地址(在URL路径中) |
| String(查询参数) | 否 | 按交易所类型过滤 |
返回结果:
json
{
"success": true,
"data": {
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "0xabcdef1234567890...",
"exchange": "hyperliquid",
"authorized": true,
"expiredAt": 1681992600000,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T10:30:00Z"
},
"usage": {"cost": 1, "quota": 99}
}29. Authorize Wallet Agent
29. 授权钱包代理
设置钱包代理的授权状态。
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/walletagent/authorize" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"agentAddress": "0x1234567890abcdef...",
"exchange": "hyperliquid",
"userAddress": "0xabcdef1234567890...",
"authorized": true,
"expiredAt": 1681992600000
}'Parameters (body):
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | Agent wallet address |
| String | Yes | Exchange type: |
| String | Yes | User's main wallet address |
| Boolean | Yes | |
| Integer | No | Authorization expiry (Unix milliseconds) |
Response:
json
{
"success": true,
"data": {
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "0xabcdef1234567890...",
"exchange": "hyperliquid",
"authorized": true,
"expiredAt": 1681992600000,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T11:00:00Z"
},
"usage": {"cost": 1, "quota": 99}
}设置钱包代理的授权状态。
bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/walletagent/authorize" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{
"agentAddress": "0x1234567890abcdef...",
"exchange": "hyperliquid",
"userAddress": "0xabcdef1234567890...",
"authorized": true,
"expiredAt": 1681992600000
}'参数(请求体):
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 代理钱包地址 |
| String | 是 | 交易所类型: |
| String | 是 | 用户主钱包地址 |
| Boolean | 是 | |
| Integer | 否 | 授权过期时间(Unix毫秒) |
返回结果:
json
{
"success": true,
"data": {
"id": 1,
"userId": "user_001",
"agentAddress": "0x1234567890abcdef...",
"userAddress": "0xabcdef1234567890...",
"exchange": "hyperliquid",
"authorized": true,
"expiredAt": 1681992600000,
"createdAt": "2026-03-21T10:30:00Z",
"updatedAt": "2026-03-21T11:00:00Z"
},
"usage": {"cost": 1, "quota": 99}
}Cross-Skill Workflows
跨技能工作流
Workflow A: CEX Spot Trading
工作流A:CEX现货交易
User: "Buy 0.1 BTC on Binance"
1. opentrade-cex GET /market/ticker?symbol=BTC/USDT&exchangeId=binance → check current price
2. opentrade-cex GET /account/summary?exchangeId=binance → verify available balance
3. opentrade-cex GET /market/metadata?ticker=BTC → confirm pair info/limits
4. opentrade-cex POST /orders → place order
{"symbol":"BTC/USDT:USDT","side":"buy","type":"market","quantity":0.1,"exchangeId":"binance"}
5. opentrade-cex GET /orders/open → confirm order statusData handoff:
- price from step 1 → helps user decide order type (market vs limit)
last - balance from step 2 → validates user can afford the order
available - Market info from step 3 → confirms pair exists and shows limits
用户:"在Binance买0.1 BTC"
1. opentrade-cex GET /market/ticker?symbol=BTC/USDT&exchangeId=binance → 查看当前价格
2. opentrade-cex GET /account/summary?exchangeId=binance → 验证可用余额
3. opentrade-cex GET /market/metadata?ticker=BTC → 确认交易对信息/限制
4. opentrade-cex POST /orders → 下单
{"symbol":"BTC/USDT:USDT","side":"buy","type":"market","quantity":0.1,"exchangeId":"binance"}
5. opentrade-cex GET /orders/open → 确认订单状态数据传递:
- 步骤1返回的最新价格 → 帮助用户决定订单类型(市价还是限价)
last - 步骤2返回的可用余额 → 验证用户是否有足够余额下单
available - 步骤3返回的市场信息 → 确认交易对存在并展示交易限制
Workflow B: CEX Futures Trading
工作流B:CEX期货交易
User: "Open a 10x long on ETH with $1000"
1. opentrade-cex GET /market/ticker?symbol=ETH/USDT&exchangeId=binance → check ETH price
2. opentrade-cex GET /account/summary?exchangeId=binance&symbol=ETH/USDT:USDT&accountType=swap → check margin balance
3. opentrade-cex GET /leverage/current?symbol=ETH/USDT:USDT&exchangeId=binance → check current leverage
4. opentrade-cex PUT /leverage/current → set leverage to 10x (if needed)
{"symbol":"ETH/USDT:USDT","leverage":10,"exchangeId":"binance"}
5. opentrade-cex POST /orders → open long position
{"symbol":"ETH/USDT:USDT","side":"buy","type":"market","quantity":<calculated>,"exchangeId":"binance"}
6. opentrade-cex GET /positions → verify position openedData handoff:
- price from step 1 → calculate quantity:
last$1000 / ETH_price - Leverage 10x means only $100 margin needed for $1000 position
用户:"用1000美元开ETH的10倍多仓"
1. opentrade-cex GET /market/ticker?symbol=ETH/USDT&exchangeId=binance → 查看ETH价格
2. opentrade-cex GET /account/summary?exchangeId=binance&symbol=ETH/USDT:USDT&accountType=swap → 查看保证金余额
3. opentrade-cex GET /leverage/current?symbol=ETH/USDT:USDT&exchangeId=binance → 查看当前杠杆
4. opentrade-cex PUT /leverage/current → 如有需要将杠杆设置为10倍
{"symbol":"ETH/USDT:USDT","leverage":10,"exchangeId":"binance"}
5. opentrade-cex POST /orders → 开多仓
{"symbol":"ETH/USDT:USDT","side":"buy","type":"market","quantity":<计算值>,"exchangeId":"binance"}
6. opentrade-cex GET /positions → 验证持仓已开数据传递:
- 步骤1返回的最新价格 → 计算数量:
last$1000 / ETH价格 - 10倍杠杆意味着1000美元的持仓仅需要100美元的保证金
Workflow C: News-Driven CEX Trading
工作流C:新闻驱动的CEX交易
User: "Check latest crypto news and trade accordingly"
1. [opennews] Search crypto news → get AI ratings and trade signals
2. [opentwitter] Check KOL sentiment on the target token
3. opentrade-cex GET /market/ticker → check CEX price
4. opentrade-cex GET /market/klines?interval=1h → check recent trend
5. opentrade-cex GET /account/summary → check balance
6. opentrade-cex POST /orders → execute trade
7. opentrade-cex GET /positions → monitor position用户:"查看最新加密货币新闻并据此交易"
1. [opennews] 搜索加密货币新闻 → 获取AI评级和交易信号
2. [opentwitter] 查看KOL对目标代币的情绪
3. opentrade-cex GET /market/ticker → 查看CEX价格
4. opentrade-cex GET /market/klines?interval=1h → 查看近期走势
5. opentrade-cex GET /account/summary → 查看余额
6. opentrade-cex POST /orders → 执行交易
7. opentrade-cex GET /positions → 监控持仓Workflow D: CEX-DEX Price Arbitrage
工作流D:CEX-DEX价格套利
User: "Compare BTC price between CEX and DEX"
1. opentrade-cex GET /market/ticker?symbol=BTC/USDT&exchangeId=binance → CEX price
2. [opentrade-market] GET /market/price (on-chain) → DEX price
3. Compare prices → identify arbitrage opportunity
4a. CEX cheaper → opentrade-cex POST /orders (CEX buy) + [opentrade-dex-swap] (DEX sell)
4b. DEX cheaper → [opentrade-dex-swap] (DEX buy) + opentrade-cex POST /orders (CEX sell)
5. Confirm both sides filled → calculate profit用户:"比较CEX和DEX的BTC价格"
1. opentrade-cex GET /market/ticker?symbol=BTC/USDT&exchangeId=binance → 获取CEX价格
2. [opentrade-market] GET /market/price (链上) → 获取DEX价格
3. 对比价格 → 发现套利机会
4a. CEX价格更低 → opentrade-cex POST /orders(CEX买入) + [opentrade-dex-swap](DEX卖出)
4b. DEX价格更低 → [opentrade-dex-swap](DEX买入) + opentrade-cex POST /orders(CEX卖出)
5. 确认两边都成交 → 计算利润Workflow E: CEX Hedge + DEX Spot Holdings
工作流E:CEX对冲 + DEX现货持仓
User: "Hedge my on-chain ETH holdings with a CEX short"
1. [opentrade-portfolio] Check on-chain ETH balance → e.g., 10 ETH
2. opentrade-cex GET /account/summary → check CEX margin
3. opentrade-cex PUT /leverage/current → set leverage
4. opentrade-cex POST /orders → open short position
{"symbol":"ETH/USDT:USDT","side":"sell","type":"market","quantity":10,"exchangeId":"binance"}
5. opentrade-cex GET /positions → confirm hedge position用户:"用CEX空仓对冲我的链上ETH持仓"
1. [opentrade-portfolio] 查看链上ETH余额 → 例如10 ETH
2. opentrade-cex GET /account/summary → 查看CEX保证金
3. opentrade-cex PUT /leverage/current → 设置杠杆
4. opentrade-cex POST /orders → 开空仓
{"symbol":"ETH/USDT:USDT","side":"sell","type":"market","quantity":10,"exchangeId":"binance"}
5. opentrade-cex GET /positions → 确认对冲持仓Workflow F: DEX Discovery + CEX Execution
工作流F:DEX发现 + CEX执行
User: "Find trending tokens and trade on CEX"
1. [opentrade-token] Search trending tokens → discover hot tokens
2. [opentrade-market] Check on-chain trading activity → smart money signals
3. opentrade-cex GET /market/metadata → check if listed on CEX
4. If CEX listed → opentrade-cex POST /orders → trade on CEX (lower fees)
If not listed → [opentrade-dex-swap] → trade on DEX用户:"找到热门代币并在CEX交易"
1. [opentrade-token] 搜索热门代币 → 发现热门代币
2. [opentrade-market] 查看链上交易活动 → 聪明钱信号
3. opentrade-cex GET /market/metadata → 查看是否在CEX上线
4. 如果已在CEX上线 → opentrade-cex POST /orders → 在CEX交易(手续费更低)
如果未在CEX上线 → [opentrade-dex-swap] → 在DEX交易Workflow G: Cross-Venue Portfolio Overview
工作流G:跨场所资产组合概览
User: "Show me all my assets across CEX and DEX"
1. opentrade-cex GET /account/summary → CEX total balance
2. opentrade-cex GET /account/spots → CEX spot assets
3. opentrade-cex GET /positions → CEX open positions
4. [opentrade-portfolio] Get on-chain wallet balances → DEX holdings
5. Combine and present unified portfolio report用户:"展示我在CEX和DEX的所有资产"
1. opentrade-cex GET /account/summary → CEX总余额
2. opentrade-cex GET /account/spots → CEX现货资产
3. opentrade-cex GET /positions → CEX未平仓持仓
4. [opentrade-portfolio] 获取链上钱包余额 → DEX持仓
5. 合并并展示统一的资产组合报告Operation Flow
操作流程
Step 1: Identify Intent
步骤1:识别意图
| User wants to... | Action |
|---|---|
| Check CEX market price | |
| View K-line / chart data | |
| Check account balance | |
| Place a buy/sell order | |
| Modify an existing order | |
| Cancel an order | |
| View open orders | |
| View closed orders | |
| Check current positions | |
| Close a position | |
| Set leverage | |
| Check leverage / margin | |
| View trade history | |
| Manage wallet agents | |
| 用户想要... | 操作 |
|---|---|
| 查看CEX市场价格 | |
| 查看K线/图表数据 | |
| 查看账户余额 | |
| 下买/卖订单 | |
| 修改现有订单 | |
| 取消订单 | |
| 查看未成交订单 | |
| 查看已完成订单 | |
| 查看当前持仓 | |
| 平仓 | |
| 设置杠杆 | |
| 查看杠杆/保证金 | |
| 查看交易历史 | |
| 管理钱包代理 | |
Step 2: Collect Parameters
步骤2:收集参数
- Missing exchangeId → ask user which exchange (e.g., ,
binance,bybit,okx)hyperliquid - Missing symbol → ask user which trading pair; format as CCXT standard (e.g., for spot,
BTC/USDTfor perpetual)BTC/USDT:USDT - Missing side → ask user: buy or sell?
- Missing order type → suggest for immediate execution,
marketfor price controllimit - Missing quantity → ask user; for futures, help calculate based on notional value and leverage
- Missing price → required for limit orders; call to show current price as reference
GET /market/ticker - Missing leverage → check current setting with ; suggest 1x-10x for beginners
GET /leverage/current
- 缺少exchangeId → 询问用户要使用哪个交易所(例如、
binance、bybit、okx)hyperliquid - 缺少symbol → 询问用户要交易的交易对;格式遵循CCXT标准(现货用,永续合约用
BTC/USDT)BTC/USDT:USDT - 缺少side → 询问用户:买还是卖?
- 缺少订单类型 → 建议立即成交用市价单,价格控制用
market限价单limit - 缺少数量 → 询问用户;期货交易可以根据名义价值和杠杆帮助计算
- 缺少价格 → 限价单必填;调用展示当前价格作为参考
GET /market/ticker - 缺少杠杆 → 调用查看当前设置;建议新手使用1x-10x杠杆
GET /leverage/current
Step 3: Execute & Display
步骤3:执行并展示
- Run the API call
- Parse JSON response
- Display human-readable summary with prices, quantities, P&L in friendly format
- For order creation: show order ID, pair, side, type, quantity, price, status
- For positions: show pair, side, entry/mark price, P&L, leverage
- For account: show total/available balance, unrealized P&L
- 运行API调用
- 解析JSON返回结果
- 以友好的格式展示人类可读的摘要,包含价格、数量、盈亏
- 订单创建场景:展示订单ID、交易对、方向、类型、数量、价格、状态
- 持仓场景:展示交易对、方向、开仓/标记价格、盈亏、杠杆
- 账户场景:展示总/可用余额、未实现盈亏
Step 4: Suggest Next Steps
步骤4:建议后续操作
| Just completed | Suggest |
|---|---|
| Checked ticker | 1. Place an order 2. View K-line for trend analysis |
| Checked balance | 1. Place an order 2. Check positions |
| Placed order | 1. Check open orders 2. View positions 3. Set stop-loss |
| Order filled | 1. View positions 2. Set take-profit/stop-loss |
| Position opened | 1. Monitor with ticker 2. Set stop-loss order 3. Close position |
| Position closed | 1. Check realized P&L in trade history 2. Check updated balance |
| Set leverage | 1. Place an order 2. Check position limits |
Present conversationally — never expose endpoint paths to the user.
| 刚刚完成的操作 | 建议操作 |
|---|---|
| 查看了行情 | 1. 下单 2. 查看K线做走势分析 |
| 查看了余额 | 1. 下单 2. 查看持仓 |
| 提交了订单 | 1. 查看未成交订单 2. 查看持仓 3. 设置止损 |
| 订单已成交 | 1. 查看持仓 2. 设置止盈/止损 |
| 开仓成功 | 1. 通过行情监控 2. 设置止损单 3. 平仓 |
| 平仓成功 | 1. 在交易历史中查看已实现盈亏 2. 查看更新后的余额 |
| 设置了杠杆 | 1. 下单 2. 查看持仓限制 |
以对话的形式呈现——切勿向用户暴露端点路径。
Risk Engine Notes
风险引擎说明
All risk-controlled endpoints (marked with "Risk: Yes" in Command Index) pass through a 4-layer risk engine before execution:
| Rule | Name | Trigger | Default Threshold |
|---|---|---|---|
| 1 | Price Deviation Check | Limit orders | Max 10% deviation from market price |
| 2 | Position Size Limit | Order creation, position close | Single: 20% of balance, Total: 80% of balance |
| 3 | Rate Limit | All risk-controlled endpoints | 30 requests per minute |
| 4 | Balance Check | Order creation | Min 5% balance reserve |
What happens when risk check fails:
- The API returns an error with a description of which rule was triggered
- The order/action is NOT executed
- Display the reason to the user clearly (e.g., "Order rejected: price deviates 15% from market price, max allowed is 10%")
- Suggest corrective action (adjust price, reduce quantity, wait and retry, etc.)
Risk engine behavior:
- Rules are checked in priority order (rate limit → price deviation → position limit → balance check)
- First failure stops the chain — remaining rules are not checked
- The risk engine uses a fail-open strategy: if market data or Redis is unavailable, the check passes (prioritizing availability)
所有受风控的端点(在命令索引中标记为"受风控:是")在执行前都会经过四层风险引擎检查:
| 规则编号 | 规则名称 | 触发场景 | 默认阈值 |
|---|---|---|---|
| 1 | 价格偏差检查 | 限价单 | 与市场价格最大偏差10% |
| 2 | 持仓规模限制 | 订单创建、平仓 | 单笔订单:余额的20%,总持仓:余额的80% |
| 3 | 速率限制 | 所有受风控的端点 | 每分钟最多30次请求 |
| 4 | 余额检查 | 订单创建 | 至少保留5%的余额 |
风险检查失败的处理:
- API会返回错误,说明触发了哪条规则
- 订单/操作不会执行
- 清晰地向用户展示失败原因(例如:"订单被拒绝:价格与市场价格偏差15%,最大允许偏差为10%")
- 建议纠正措施(调整价格、减少数量、等待后重试等)
风险引擎行为:
- 规则按优先级顺序检查(速率限制 → 价格偏差 → 持仓限制 → 余额检查)
- 首次失败就会终止检查流程——不会检查剩余规则
- 风险引擎采用故障开放策略:如果市场数据或Redis不可用,检查会通过(优先保障可用性)
Input / Output Examples
输入/输出示例
User says: "What's the BTC price on Binance?"
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/ticker?symbol=BTC/USDT&exchangeId=binance" -H "$AUTH_HEADER"用户说:"Binance上的BTC价格是多少?"
bash
curl -s "$BASE_URL/open/trader/newsliquid/v1/market/ticker?symbol=BTC/USDT&exchangeId=binance" -H "$AUTH_HEADER"→ BTC/USDT: $67,890.50 (Bid: $67,889 | Ask: $67,891)
→ BTC/USDT: $67,890.50(买一价: $67,889 | 卖一价: $67,891)
**User says:** "Buy 0.01 BTC at $65,000"
```bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"symbol":"BTC/USDT:USDT","side":"buy","type":"limit","quantity":0.01,"price":65000,"exchangeId":"binance"}'
**用户说:"以$65,000的价格买0.01 BTC"**
```bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/orders" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"symbol":"BTC/USDT:USDT","side":"buy","type":"limit","quantity":0.01,"price":65000,"exchangeId":"binance"}'→ Order placed! Buy 0.01 BTC @ $65,000 (Limit) — ID: 123456789
→ 订单已提交!以$65,000(限价)买入0.01 BTC — ID: 123456789
**User says:** "Close my BTC position"
```bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/positions/close" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"symbol":"BTC/USDT:USDT","side":"long","quantity":0,"exchangeId":"binance"}'
**用户说:"平掉我的BTC持仓"**
```bash
curl -s -X POST "$BASE_URL/open/trader/newsliquid/v1/positions/close" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"symbol":"BTC/USDT:USDT","side":"long","quantity":0,"exchangeId":"binance"}'→ Position closed! Realized P&L: +$25.00
→ 持仓已平仓!已实现盈亏:+$25.00
**User says:** "Set my ETH leverage to 20x"
```bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/leverage/current" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"symbol":"ETH/USDT:USDT","leverage":20,"exchangeId":"binance"}'
**用户说:"把我的ETH杠杆设置为20倍"**
```bash
curl -s -X PUT "$BASE_URL/open/trader/newsliquid/v1/leverage/current" \
-H "$AUTH_HEADER" -H "Content-Type: application/json" \
-d '{"symbol":"ETH/USDT:USDT","leverage":20,"exchangeId":"binance"}'→ Leverage updated! ETH/USDT:USDT: 20x
→ 杠杆已更新!ETH/USDT:USDT: 20x
undefinedundefinedEdge Cases
边缘情况处理
- Risk engine rejects order: Display the rejection reason clearly. Common causes: price too far from market (>10%), position too large, rate limited, insufficient balance. Suggest the user adjust parameters and retry.
- Insufficient balance: Check balance with first. For futures, consider leverage — required margin = order value / leverage.
GET /account/summary - Rate limited: If 30+ requests in 1 minute, wait 60 seconds before retrying. Inform the user about the cooldown.
- Invalid trading pair: Call to verify the symbol exists on the exchange.
GET /market/metadata - Position mode conflict: Cannot switch position mode while holding open positions. Close all positions first.
- Leverage change with open positions: Some exchanges restrict leverage changes when positions are open. Close positions or reduce size first.
- Order quantity precision: Use to check
GET /market/metadataandamountMin. Ensure order meets minimum requirements.costMin - Minimum notional: Orders below the minimum cost (e.g., $5 ) will be rejected by the exchange.
costMin - Network error: Retry once, then prompt user to try again later.
- Region restriction (error code 50125 or 80001): Do NOT show the raw error code to the user. Instead, display:
Service is not available in your region. Please switch to a supported region and try again.
- 风险引擎拒绝订单:清晰展示拒绝原因。常见原因:价格与市场价偏差过大(>10%)、持仓规模过大、触发速率限制、余额不足。建议用户调整参数后重试。
- 余额不足:先调用检查余额。期货交易可考虑杠杆——所需保证金 = 订单价值 / 杠杆。
GET /account/summary - 触发速率限制:如果1分钟内请求超过30次,等待60秒后再重试。告知用户冷却时间。
- 无效交易对:调用验证交易对在该交易所是否存在。
GET /market/metadata - 持仓模式冲突:持有未平仓持仓时无法切换持仓模式。先平掉所有持仓。
- 有未平仓持仓时修改杠杆:部分交易所有持仓时限制修改杠杆。先平仓或减少持仓规模。
- 订单数量精度问题:调用查看
GET /market/metadata和amountMin,确保订单满足最低要求。costMin - 最低名义价值限制:低于最低成本(例如为5美元)的订单会被交易所拒绝。
costMin - 网络错误:重试一次,然后提示用户稍后再试。
- 区域限制(错误码50125或80001):不要向用户展示原始错误码,而是展示:
您所在的区域暂不支持该服务,请切换到支持的区域后重试。
Amount Display Rules
金额展示规则
- CEX amounts use standard units (e.g., ,
0.1 BTC) — NOT minimal units like DEX100 USDT - Always show currency symbol alongside amounts
- Format large numbers with commas (e.g., )
$67,500.50 - Show P&L with sign and color hint: positive (+$250.00), negative (-$100.00)
- Show percentage changes with sign (e.g., +1.89%, -0.52%)
- Leverage shown as multiplier (e.g., 10x, 20x)
- CEX金额使用标准单位(例如、
0.1 BTC)—— 不像DEX那样使用最小单位100 USDT - 金额旁始终展示币种符号
- 大额数字用逗号分隔(例如)
$67,500.50 - 盈亏展示带符号和颜色提示:正数(+$250.00),负数(-$100.00)
- 涨跌幅展示带符号(例如+1.89%、-0.52%)
- 杠杆展示为倍数(例如10x、20x)
Global Notes
全局说明
- All endpoints require header
Authorization: Bearer <token> - Supported exchanges: ,
binance,bybit,okx,hyperliquidaster - Trading pair format follows CCXT standard: for spot,
BTC/USDTfor USDT perpetual contractsBTC/USDT:USDT - The API routes through the CEX gateway with built-in risk controls — trades execute server-side
- No private keys or transaction signing involved — this is CEX trading via API
- CEX uses standard amount units (e.g., ), unlike DEX which uses minimal units (wei/lamports)
0.1 BTC - Numeric values in request bodies use native types (numbers, not strings): ,
"quantity": 0.01"price": 65000.00 - Risk-controlled endpoints may reject requests — always display the rejection reason to the user
- Query parameters go in the URL, body parameters go in JSON request body
- Wallet Agent feature only supports and
asterexchangeshyperliquid - Each API request consumes 1 quota unit (shown in field of response)
usage - Success response:
{"success": true, "data": {...}, "usage": {"cost": 1, "quota": 99}} - Error response (upstream):
{"success": false, "code": "INVALID_REQUEST", "error": "message"} - Error response (gateway):
{"code": 400, "message": "error message", "error": "details"} - The skill uses the same as all other opentrade skills — no additional configuration needed
OPEN_TOKEN
- 所有端点都需要请求头
Authorization: Bearer <token> - 支持的交易所:、
binance、bybit、okx、hyperliquidaster - 交易对格式遵循CCXT标准:现货用,USDT永续合约用
BTC/USDTBTC/USDT:USDT - API通过内置风控的CEX网关路由——交易在服务端执行
- 不涉及私钥或交易签名——这是通过API实现的CEX交易
- CEX使用标准金额单位(例如),不像DEX使用最小单位(wei/lamports)
0.1 BTC - 请求体中的数值使用原生类型(数字,不是字符串):、
"quantity": 0.01"price": 65000.00 - 受风控的端点可能会拒绝请求——始终向用户展示拒绝原因
- 查询参数放在URL中,请求体参数放在JSON请求体中
- 钱包代理功能仅支持和
aster交易所hyperliquid - 每个API请求消耗1个配额单位(在返回结果的字段中展示)
usage - 成功响应:
{"success": true, "data": {...}, "usage": {"cost": 1, "quota": 99}} - 上游错误响应:
{"success": false, "code": "INVALID_REQUEST", "error": "message"} - 网关错误响应:
{"code": 400, "message": "error message", "error": "details"} - 本技能与其他所有opentrade技能使用相同的——无需额外配置
OPEN_TOKEN