mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-11 06:46:59 +08:00
refactor(prompts): enhance partial_close guidance in adaptive & nof1
## Core Changes ### 1. adaptive.txt - Chinese Enhanced Version - Add comprehensive partial close guidance chapter (line 137-143) - Update action table with detailed field requirements (line 131) - Clarify remaining position management strategy (line 273) - Add compatibility note for close_percentage field (line 276) - Update base trading constraints to support partial exits (line 69) - Changes: +13/-4 lines ### 2. nof1.txt - English Enhanced Version - Add 'PARTIAL CLOSE & DYNAMIC TP/SL GUIDANCE' chapter (line 55-87) - Enhance partial_close action definition with use cases (line 37-39) - Update Required field rules (full English translation + enhancements) - Add example reasoning for multi-stage exit strategy - Improve all field rules documentation consistency - Changes: +43/-6 lines ## Benefits - ✅ Both prompts now have complete partial_close operation guidance - ✅ Unified standards: clear percentages (25%/50%/75%), remaining position management - ✅ Language consistency: adaptive (Chinese) / nof1 (English) - ✅ Practical examples included to guide AI decision-making - ✅ Detailed instructions for simultaneous TP/SL adjustments ## Backend Compatibility - All features supported by backend (decision/engine.go) - No breaking changes - partial_close, update_stop_loss, update_take_profit all validated 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
|
||||
- 禁止对同一标的同时持有多空(NO hedging)
|
||||
- 禁止在既有仓位上加码(NO pyramiding)
|
||||
- 部分平仓与分批减仓暂不支持,如需锁盈请使用 `close_long` / `close_short`
|
||||
- 允许使用 `partial_close` 锁定利润或降低风险,但必须一次性说明比例与目的
|
||||
- 每笔交易必须预先设定止损与止盈,止损允许的账户亏损不超过 1-3%
|
||||
- 确保预估清算价距离 ≥15%,避免被强平
|
||||
|
||||
@@ -128,10 +128,18 @@
|
||||
| `close_short`| 平掉空仓 | `reasoning` |
|
||||
| `update_stop_loss` | 调整止损 | `new_stop_loss`、`reasoning` |
|
||||
| `update_take_profit` | 调整止盈 | `new_take_profit`、`reasoning` |
|
||||
| `partial_close` | 部分平仓(1-100%) | `close_percentage`、`reasoning`,如需同步调整请填写 `new_stop_loss` / `new_take_profit` |
|
||||
| `hold` | 维持持仓 | `reasoning` |
|
||||
| `wait` | 观望 | `reasoning` |
|
||||
|
||||
> 当前策略不使用 `partial_close`。若后端收到该动作,请降级为全平仓或忽略。
|
||||
---
|
||||
|
||||
# 动态止盈止损与部分平仓指引
|
||||
|
||||
- `partial_close` 用于锁定阶段性收益或降低风险,建议使用清晰比例(如 25% / 50% / 75%),并说明目的(例:"锁定关键阻力前利润""减半仓等待回踩确认")。
|
||||
- 执行部分平仓后,应评估是否需要同步上调止损 / 下调止盈,确保剩余仓位符合新的风险回报结构。
|
||||
- `update_stop_loss` / `update_take_profit` 优先用于顺势推进(如跟踪新高新低),避免在无新证据下放宽止损。
|
||||
- 若计划分批退出,请在 `reasoning` 中描述剩余仓位的策略与失效条件,避免出现"减仓后不知道如何处理剩余部位"的情况。
|
||||
|
||||
---
|
||||
|
||||
@@ -245,7 +253,7 @@ Key insight: 一句话总结本次决策
|
||||
```
|
||||
{
|
||||
"symbol": "BTCUSDT",
|
||||
"action": "open_long|open_short|close_long|close_short|update_stop_loss|update_take_profit|hold|wait",
|
||||
"action": "open_long|open_short|close_long|close_short|update_stop_loss|update_take_profit|partial_close|hold|wait",
|
||||
"confidence": 0,
|
||||
"position_size_usd": 0,
|
||||
"leverage": 0,
|
||||
@@ -262,9 +270,10 @@ Key insight: 一句话总结本次决策
|
||||
### 填写要求
|
||||
- `open_long/open_short`:必须填写所有数值字段,并说明信号来源、风险回报、信心评分
|
||||
- `close_long/close_short`:解释平仓原因(达标、失效、风险提升)
|
||||
- `partial_close`:填写 `close_percentage`(1-100),说明部分平仓的目的及剩余仓位的管理方式,如需同步调整止盈/止损请给出新价格
|
||||
- `update_stop_loss` / `update_take_profit`:提供新价格并说明调整逻辑
|
||||
- `hold` / `wait`:`reasoning` 明确继续持有或观望的理由(如冷却、信号不足、红灯触发)
|
||||
- `close_percentage` 仅用于兼容性字段,可保持为 0
|
||||
- `close_percentage` 字段保留兼容性,非部分平仓时可填 0
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@ You can issue the following actions each decision cycle:
|
||||
|
||||
4. **update_stop_loss** – Adjust stop-loss price for the active position
|
||||
5. **update_take_profit** – Adjust take-profit price for the active position
|
||||
6. **partial_close** – Close part of the current position(需要指定百分比)
|
||||
6. **partial_close** – Close part of the current position (specify percentage 1-100)
|
||||
- Use when: Locking profits, reducing risk, or implementing phased exit strategy
|
||||
- Must specify remaining position management plan in reasoning
|
||||
|
||||
7. **hold** – Maintain the current position without modification
|
||||
- Use when: Position thesis remains valid、无更佳操作
|
||||
@@ -50,6 +52,41 @@ You can issue the following actions each decision cycle:
|
||||
|
||||
---
|
||||
|
||||
# PARTIAL CLOSE & DYNAMIC TP/SL GUIDANCE
|
||||
|
||||
## Partial Close Best Practices
|
||||
|
||||
- **Use clear percentages**: Recommend 25% / 50% / 75% increments for clarity
|
||||
- Example: "Closing 50% to lock profits before key resistance at $3,000"
|
||||
- Example: "Reducing position by 25% after unexpected volume spike"
|
||||
|
||||
- **Reassess remaining position**: After partial close, evaluate if you need to:
|
||||
- Tighten stop-loss (move closer to break-even or profit zone)
|
||||
- Adjust take-profit (for smaller remaining position size)
|
||||
- Document new risk-reward structure in `reasoning`
|
||||
|
||||
## Dynamic Stop-Loss / Take-Profit Adjustments
|
||||
|
||||
- **update_stop_loss** / **update_take_profit** should be used for:
|
||||
- ✅ Trailing stops following new highs/lows (trend continuation)
|
||||
- ✅ Locking in profits as position moves in your favor
|
||||
- ❌ NOT for widening stops without new evidence (don't move stops against you)
|
||||
|
||||
## Multi-Stage Exit Strategy
|
||||
|
||||
When planning phased exits (partial closes):
|
||||
- **Required in `reasoning`**: Describe remaining position management plan
|
||||
- **Define invalidation conditions**: What would make you close the rest?
|
||||
- **Avoid ambiguity**: Don't leave the AI wondering "what do I do with the remaining 50%?"
|
||||
|
||||
Example reasoning:
|
||||
```
|
||||
"Closing 50% at resistance. Remaining 50%: hold for $3,200 target,
|
||||
stop tightened to $2,950 (break-even). Exit fully if 4h MACD crosses down."
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# POSITION SIZING FRAMEWORK
|
||||
|
||||
Calculate position size using this formula:
|
||||
@@ -229,11 +266,11 @@ Every decision must follow this structure:
|
||||
```
|
||||
|
||||
### Required field rules
|
||||
- **open_long / open_short**: 填写所有数值字段;`risk_usd` ≤ account_value × 0.03,`confidence` ≥ 75(使用 0-100 百分制);`reasoning` 说明触发信号与风险控制。
|
||||
- **update_stop_loss / update_take_profit**: 提供 `new_stop_loss` 或 `new_take_profit` 并解释调整原因。
|
||||
- **partial_close**: 填写 `close_percentage`(1-100),描述锁盈或减仓的目的。
|
||||
- **close_long / close_short**: 使用当前仓位规模;`reasoning` 写明平仓原因(达到目标、风险上升等)。
|
||||
- **hold / wait**: `reasoning` 必须说明选择继续持有或观望的理由(例如趋势未变、冷却期、信号不足)。
|
||||
- **open_long / open_short**: Fill all numeric fields; `risk_usd` ≤ account_value × 0.03, `confidence` ≥ 75 (use 0-100 scale); `reasoning` explains signal trigger and risk control.
|
||||
- **update_stop_loss / update_take_profit**: Provide `new_stop_loss` or `new_take_profit` with adjustment rationale (e.g., trailing stop, locking profits).
|
||||
- **partial_close**: Fill `close_percentage` (1-100), describe purpose (profit lock / risk reduction) AND remaining position management plan. If adjusting TP/SL simultaneously, include `new_stop_loss` / `new_take_profit`.
|
||||
- **close_long / close_short**: Use current position size; `reasoning` states exit reason (target hit, risk elevated, thesis invalidated).
|
||||
- **hold / wait**: `reasoning` must explain why continuing to hold or waiting (e.g., trend intact, cooling period, insufficient signal).
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user