ZhouYongyou
|
df2d6533de
|
fix: 修復5個關鍵交易bug(保證金計算、部分平倉統計、止損止盈分離、雙向持倉)
## 修復內容
### 1. 保證金計算錯誤(Critical)
- 修正提示詞中的保證金公式(adaptive.txt, nof1.txt, default.txt)
- 新增代碼級保證金驗證(auto_trader.go)
- 防止開倉時保證金不足錯誤(code=-2019)
### 2. 部分平倉統計錯誤(Medium)
- 修改統計邏輯:多次 partial_close 聚合為一筆交易
- 新增追蹤字段:remainingQuantity, accumulatedPnL
- 只在完全平倉時計入 TotalTrades++
### 3. 前端配置覆蓋問題(Medium)
- 修正 TraderConfigModal.tsx 條件判斷
- 防止空字符串覆蓋用戶選擇的提示詞
### 4/5. 動態止損/止盈刪除配對訂單(Critical)
- 新增接口:CancelStopLossOrders, CancelTakeProfitOrders
- 分離訂單取消邏輯(Binance, Hyperliquid, Aster)
- 調整止損時不刪除止盈,反之亦然
### 7. 雙向持倉模式初始化(Critical)
- 新增 setDualSidePosition() 函數
- 在 NewFuturesTrader() 中初始化 Hedge Mode
- 防止 code=-4061 錯誤(PositionSide 參數錯誤)
## 影響範圍
- 修改文件:10個
- 新增代碼:+480行
- 刪除代碼:-71行
## 測試狀態
- ✅ 編譯通過(go build ./...)
- ✅ 語法檢查通過
- ⚠️ 需要在測試環境運行驗證實際交易效果
|
2025-11-04 18:36:39 +08:00 |
|
ZhouYongyou
|
b3b68b2b62
|
refactor(prompts): unify action schema & optimize trading discipline
## Core Changes
### 1. adaptive.txt - Adopt v5.5.6.1 strict strategy
- Migrate from dual-strategy system to unified adaptive approach
- Maintain strict confidence threshold ≥85 (anti-overtrading)
- Remove complex market state detection, focus on signal quality
- Explicitly disable partial_close (full exit only)
- -160 lines (removed redundant strategy logic)
### 2. nof1.txt - Fix contradictions & align standards
- ✅ Fix: Remove "NO partial exits" contradiction (now explicitly supported)
- ✅ Unify: Change confidence threshold from 60 → 75
- ✅ Unify: Change risk-reward ratio from 2:1 → 3:1
- Add confidence level guidance (75-85: good, 85-100: high)
- +85 lines (enhanced risk management framework)
### 3. default.txt - Add standardized output format
- Add structured thinking summary format
- Add comprehensive JSON schema documentation
- Add required fields rules for all action types
- +36 lines (improved contract clarity)
## Action Schema Migration
All prompts now use unified action naming:
- ✅ open_long / open_short (was: buy_to_enter / sell_to_enter)
- ✅ close_long / close_short (was: close)
- ✅ update_stop_loss / update_take_profit (new)
- ✅ partial_close (new, nof1 only)
- ✅ hold / wait (unchanged)
## Confidence Scale Migration
- ✅ Changed from 0-1 float to 0-100 integer across all prompts
- ✅ Opening threshold: adaptive=85, nof1=75, default=75
- ✅ Prevents overtrading through strict quality control
## Risk-Reward Standardization
- ✅ Minimum RR ratio: 1:3 across all prompts
- ✅ Replaces previous 1:2 requirement in nof1.txt
## Breaking Changes
- Backend must support new action names
- Confidence field now expects integer 0-100 (not float 0-1)
- partial_close action available in nof1.txt only
## Prompt Positioning
- **adaptive.txt**: Strict strategy (conf≥85, RR≥1:3, no partial exits)
- **nof1.txt**: English framework (conf≥75, RR≥1:3, supports partial_close)
- **default.txt**: Balanced CN strategy (conf≥75, RR≥1:3)
Related: feature/partial-close-dynamic-tpsl
|
2025-11-03 14:52:31 +08:00 |
|