Files
Hermes-Skills/signal-confirmation-templates/references/okx-auto-execution-workflow.md
T
mike 657dc41c46 Initial commit: Trading skills collection
- OKX交易自动化 (okx-auto-position, okx-crypto, okx-exchange)
- 交易信号处理 (signal-confirmation-templates, trading-signal-aggregator)
- 量化因子挖掘 (quant-factor-mining)
- 长桥集成 (longbridge-cli, longbridge-python-sdk)
- 六合彩分析 (lottery-hk)
- 股息投资 (dividend-investing, dividend-scanner)
- 日内交易 (intraday-trading)
- 同花顺 (tonghuashun)
2026-07-05 02:39:41 -04:00

103 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# OKX自动开仓工作流
## 概述
当用户没有仓位且信号性价比合理时,自动执行开仓操作,无需等待Y/N确认。
## 前置检查
1. **查账户余额**`GET /api/v5/account/balance` → 获取USDT可用余额
2. **查当前持仓**`GET /api/v5/account/positions` → 确认无持仓
3. **查当前价格**`GET /api/v5/market/ticker?instId={币种}-USDT-SWAP`
## 性价比评估
- **入场价差距**:当前价与信号源入场价差距 <5%
- **ATR检查**4H ATR值合理(SL宽度 ≥ ATR
- **强平距离**:强平价与当前价距离 >3%
## 仓位计算
```python
# 合约规格
ct_val = 0.1 # ETH: 1张 = 0.1 ETH
leverage = 25 # 默认25x
# 计算
max_contracts = balance / (ct_val * price / leverage)
recommended_contracts = int(max_contracts * 0.5) # 50%安全边际
margin_per_contract = (ct_val * price) / leverage
total_margin = recommended_contracts * margin_per_contract
```
## 执行步骤
1. **设置杠杆**`POST /api/v5/account/set-leverage`
```json
{
"instId": "ETH-USDT-SWAP",
"lever": "25",
"mgnMode": "cross"
}
```
2. **市价开仓**`POST /api/v5/trade/order`
```json
{
"instId": "ETH-USDT-SWAP",
"tdMode": "cross",
"side": "buy",
"ordType": "market",
"sz": "9"
}
```
3. **查询成交价**`GET /api/v5/trade/order?instId={instId}&ordId={ordId}`
4. **设置OCO止盈止损**`POST /api/v5/trade/order-algo`
```json
{
"instId": "ETH-USDT-SWAP",
"tdMode": "cross",
"side": "sell",
"sz": "9",
"ordType": "oco",
"tpTriggerPx": "1851.28",
"tpOrdPx": "-1",
"tpTriggerPxType": "last",
"slTriggerPx": "1674.96",
"slOrdPx": "-1",
"slTriggerPxType": "last"
}
```
## 止损止盈计算
- **止损**:入场价 × 0.95-5%
- **止盈**:入场价 × 1.05+5%
- **盈亏比**1:1(默认)
## 推送格式
开仓完成后,推送结果到QQ
```
✅ 自动开仓完成!
📊 交易执行结果:
| 步骤 | 结果 |
|------|------|
| ✅ 杠杆 | 25x |
| ✅ 开仓 | 9张 (0.9 ETH) @ $1,763.12 |
| ✅ 止损 | $1,674.96 (-5%) |
| ✅ 止盈 | $1,851.28 (+5%) |
| ✅ 强平价 | $1,622.07 |
| ✅ 盈亏比 | 1:1 |
💰 账户状态:
• 权益:$133.46
• 可用:$69.99
• 持仓:9张 ETH 多单
📈 跟单麻吉大哥:
• 麻吉:9,350 ETH @ $1,720.83(浮盈+$481k
• 您:0.9 ETH @ $1,763.12(轻仓试水)
```
## 注意事项
1. **posMode=net_mode**:不能传posSideside=buy即开多
2. **OCO合并**:一个持仓对应一个OCO,SL/TP取最新推荐的值
3. **余额不足**:如果余额不足,减少仓位或跳过开仓
4. **强平风险**:25x杠杆下,价格下跌5%即触发强平,务必设置止损