fix(prompts): add explicit stop-loss direction logic for long/short positions

Address DaDaManMan's error where AI set stop-loss incorrectly for short position.

## Problem
AI attempted to set stop-loss at $107,500 for SHORT position at $108,230,
causing validation error: "空单止损必须高于当前价格"

Root cause: Prompts lacked explicit guidance on stop-loss direction logic.

## Solution

### adaptive.txt (Chinese):
- Add "止损方向逻辑" section with clear rules
- Long position: stop_loss < entry_price (protect downside)
- Short position: stop_loss > entry_price (protect upside)
- Include examples and common mistakes to avoid

### nof1.txt (English):
- Add "Stop-Loss Direction Logic" section
- Same directional rules with detailed explanations
- Include real error example from production logs
- Emphasize validation failures when rules are violated

## Impact
-  Prevents AI from setting illogical stop-loss prices
-  Reduces validation errors and failed trades
-  Provides clear examples with entry/stop-loss pairs
-  Addresses DaDaManMan's reported issue directly

## Files Changed
- prompts/adaptive.txt (+19 lines)
- prompts/nof1.txt (+25 lines)

Fixes: #272 (DaDaManMan's comment)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ZhouYongyou
2025-11-03 20:21:47 +08:00
parent 1e1f4cc36b
commit 041d6d4048
2 changed files with 43 additions and 0 deletions

View File

@@ -72,6 +72,31 @@ You can issue the following actions each decision cycle:
- ✅ Locking in profits as position moves in your favor
- ❌ NOT for widening stops without new evidence (don't move stops against you)
## ⚠️ Stop-Loss Direction Logic (Critical Rule)
**Long Position:**
- Stop-loss MUST be **below** entry price (`stop_loss < entry_price`)
- Reason: Protects against downside risk, exits when price drops below threshold
- Example: Entry $100, stop-loss $95 (5% loss protection)
**Short Position:**
- Stop-loss MUST be **above** entry price (`stop_loss > entry_price`)
- Reason: Protects against upside risk, exits when price rises above threshold
- Example: Entry $100, stop-loss $105 (5% loss protection)
**Common Mistakes (Must Avoid):**
- ❌ Short position with `stop_loss < entry_price` (WRONG! Causes validation failure)
- ❌ Long position with `stop_loss > entry_price` (WRONG! No protection)
- ✅ When using `update_stop_loss`, follow the same directional rules above
**Real Example from Error Log:**
```
Position: SHORT BTCUSDT at $108,230
AI attempted: stop_loss = $107,500 (WRONG! Below entry)
Correct: stop_loss should be > $108,230 (e.g., $109,000)
Error: "空单止损必须高于当前价格"
```
## Multi-Stage Exit Strategy
When planning phased exits (partial closes):