-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(trader): add backend safety checks for partial_close #713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(trader): add backend safety checks for partial_close #713
Conversation
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 🔧 Backend ChecksGo Formatting: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
|
LGTM |
🔒 PR #713 代码审查报告📊 审查结果:
|
代码审查报告 - PR #713审查结果:✅ 通过(有小建议)业务层面审查✅ 需求验证
✅ 功能完整性
✅ Edge Case 处理
技术层面审查✅ 架构合理性
✅ 交易安全
🟡 改进建议(非 BLOCKING)建议1:常量配置化当前: // config.json
{
"min_position_value_usdt": 10.0
}
// 代码中
minPositionValue := at.config.MinPositionValueUSDT
if minPositionValue <= 0 {
minPositionValue = 10.0 // 默认值
}理由:
建议2:添加单元测试func TestPartialCloseMinPositionCheck(t *testing.T) {
tests := []struct {
name string
totalQuantity float64
markPrice float64
closePercentage float64
expectedAction string // "partial_close" or "close_all"
}{
{
name: "剩余价值>10_保持部分平仓",
totalQuantity: 100,
markPrice: 1.0,
closePercentage: 50,
expectedAction: "partial_close", // 剩余50 USDT
},
{
name: "剩余价值<=10_自动全平",
totalQuantity: 15,
markPrice: 1.0,
closePercentage: 80,
expectedAction: "close_all", // 剩余3 USDT
},
}
// ...
}建议3:考虑精度问题当前: // 建议添加精度容差
const EPSILON = 0.0001
if remainingValue > EPSILON && remainingValue <= MIN_POSITION_VALUE {
// 自动全平
}建议4:NewStopLoss/NewTakeProfit 字段验证当前:直接使用 // 验证新止损价格是否合理
if decision.NewStopLoss > 0 {
// 检查止损价格是否在合理范围内
currentPrice, _ := targetPosition["markPrice"].(float64)
if positionSide == "LONG" && decision.NewStopLoss >= currentPrice {
log.Printf(" ⚠️ 多头止损价 %.2f 不应高于当前价 %.2f,跳过设置",
decision.NewStopLoss, currentPrice)
return
}
if positionSide == "SHORT" && decision.NewStopLoss <= currentPrice {
log.Printf(" ⚠️ 空头止损价 %.2f 不应低于当前价 %.2f,跳过设置",
decision.NewStopLoss, currentPrice)
return
}
// 设置止损
err = at.trader.SetStopLoss(...)
}安全审查(Web3 交易系统)✅ 资金保护
✅ 交易验证
|
- Check type assertion success before using markPrice - Return error if markPrice is invalid or <= 0 - Addresses code review feedback from @xqliu in PR NoFxAiOS#713
- Check type assertion success before using markPrice - Return error if markPrice is invalid or <= 0 - Addresses code review feedback from @xqliu in PR NoFxAiOS#713
e4eb400 to
b08e421
Compare
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 🔧 Backend ChecksGo Formatting: Files needing formattingGo Vet: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
1 similar comment
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 🔧 Backend ChecksGo Formatting: Files needing formattingGo Vet: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
系統性修復 38 處類型斷言的錯誤處理: **關鍵修復(trader/auto_trader.go)**: - ✅ markPrice 類型斷言:解析失敗返回錯誤(防止使用 0 值計算) - ✅ side/positionAmt 斷言:在 partial_close、adjust_stop_loss、adjust_take_profit 中添加錯誤處理 - ✅ 持倉查找循環:解析失敗時 continue 跳過 **Aster 交易所修復(trader/aster_trader.go)**: - ✅ 價格解析:entryPrice、markPrice 解析失敗時跳過持倉(記錄警告) - ✅ 訂單處理:orderType、orderID、positionSide 解析失敗時 continue - ✅ Filter 解析:filterType 解析失敗時 continue **日誌修復(logger/decision_logger.go)**: - ✅ posSymbol 斷言:添加 ok 檢查(容忍失敗) **測試結果**: - ✅ 編譯通過 - ✅ go fmt 格式化完成 - ⚡ 修復了 PR NoFxAiOS#713 xqliu 指出的問題 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
单元测试也可以帮忙加一下
严重程度:🟠 HIGH 问题描述: 新增了关键的安全逻辑(MIN_POSITION_VALUE 检查、TP/SL 恢复),但没有单元测试 无法验证边界条件处理是否正确 // 1. 最小仓位价值检查 // 2. TP/SL 恢复逻辑 // 3. 类型断言安全性 // 4. 边界条件 |
74a0529 to
f781fe0
Compare
- Check type assertion success before using markPrice - Return error if markPrice is invalid or <= 0 - Addresses code review feedback from @xqliu in PR NoFxAiOS#713
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 💡 Suggestion: This is a large PR. Consider breaking it into smaller, focused PRs for easier review. 🔧 Backend ChecksGo Formatting: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
|
Could you pls remove unrelated files for this? and then will be merged. Thanks @the-dev-z |
f781fe0 to
4e64702
Compare
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 🔧 Backend ChecksGo Formatting: Files needing formattingGo Vet: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
Problem: - trader/partial_close_test.go defined MockTrader - trader/auto_trader_test.go already has MockTrader - Methods CloseLong, CloseShort, SetStopLoss, SetTakeProfit were declared twice - Compilation failed with 'already declared' errors Solution: - Rename MockTrader to MockPartialCloseTrader in partial_close_test.go - This avoids naming conflict while keeping test logic independent Test Results: - All partial close tests pass - All trader tests pass Related: PR NoFxAiOS#713 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 🔧 Backend ChecksGo Formatting: Files needing formattingGo Vet: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
After PR NoFxAiOS#415 added partial_close functionality, production users reported two critical issues: 1. **Exchange minimum value error**: "Order must have minimum value of $10" when remaining position value falls below exchange threshold 2. **Unprotected positions after partial close**: Exchanges auto-cancel TP/SL orders when position size changes, leaving remaining position exposed to liquidation risk This PR adds **backend safety checks** as a safety net layer that complements the prompt-based rules from PR NoFxAiOS#712. **Protection**: Before executing partial_close, verify remaining position value > $10 ```go const MIN_POSITION_VALUE = 10.0 // Exchange底线 remainingValue := remainingQuantity * markPrice if remainingValue > 0 && remainingValue <= MIN_POSITION_VALUE { // 🔄 Auto-correct to full close decision.Action = "close_long" // or "close_short" return at.executeCloseLongWithRecord(decision, actionRecord) } ``` **Behavior**: - Position $20 → partial_close 50% → remaining $10 ≤ $10 → Auto full close ✅ - Position $30 → partial_close 50% → remaining $15 > $10 → Allow partial close ✅ **Protection**: Restore TP/SL orders for remaining position if AI provides new_stop_loss/new_take_profit ```go // Exchanges auto-cancel TP/SL when position size changes if decision.NewStopLoss > 0 { at.trader.SetStopLoss(symbol, side, remainingQuantity, decision.NewStopLoss) } if decision.NewTakeProfit > 0 { at.trader.SetTakeProfit(symbol, side, remainingQuantity, decision.NewTakeProfit) } // Warning if AI didn't provide new TP/SL if decision.NewStopLoss <= 0 && decision.NewTakeProfit <= 0 { log.Printf("⚠️ ⚠️ ⚠️ Warning: Remaining position has NO TP/SL protection") } ``` **Improvement**: Show position quantity and value to help AI make better decisions ``` Before: | 入场价100.00 当前价105.00 | 盈亏+5.00% | ... After: | 入场价100.00 当前价105.00 | 数量0.5000 | 仓位价值52.50 USDT | 盈亏+5.00% | ... ``` **Benefits**: - AI can now calculate: remaining_value = current_value × (1 - close_percentage/100) - AI can proactively avoid decisions that would violate $10 threshold - Added MIN_POSITION_VALUE check before execution - Auto-correct to full close if remaining value ≤ $10 - Restore TP/SL for remaining position - Warning logs when AI doesn't provide new TP/SL - Import "math" package - Calculate and display position value - Add quantity and position value to prompt - Complements PR NoFxAiOS#712 (Prompt v6.0.0 safety rules) - Addresses NoFxAiOS#301 (Backend layer) - Based on PR NoFxAiOS#415 (Core functionality) | Layer | Location | Purpose | |-------|----------|---------| | **Layer 1: AI Prompt** | PR NoFxAiOS#712 | Prevent bad decisions before they happen | | **Layer 2: Backend** | This PR | Auto-correct and safety net | **Together they provide**: - ✅ AI makes better decisions (sees position value, knows rules) - ✅ Backend catches edge cases (auto-corrects violations) - ✅ User-friendly warnings (explains what happened) - [x] Compiles successfully (`go build ./...`) - [x] MIN_POSITION_VALUE logic correct - [x] TP/SL restoration logic correct - [x] Position value display format validated - [x] Auto-correction flow tested This PR can be merged **independently** of PR NoFxAiOS#712, or together. Suggested merge order: 1. PR NoFxAiOS#712 (Prompt v6.0.0) - AI layer improvements 2. This PR (Backend safety) - Safety net layer Or merge together for complete two-layer protection. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Check type assertion success before using markPrice - Return error if markPrice is invalid or <= 0 - Addresses code review feedback from @xqliu in PR NoFxAiOS#713
…hecks - Test minimum position value check (< 10 USDT triggers full close) - Test boundary condition (exactly 10 USDT also triggers full close) - Test stop-loss/take-profit recovery after partial close - Test edge cases (invalid close percentages) - Test integration scenarios with mock trader All 14 test cases passed, covering: 1. MinPositionCheck (5 cases): normal, small remainder, boundary, edge cases 2. StopLossTakeProfitRecovery (4 cases): both/SL only/TP only/none 3. EdgeCases (4 cases): zero/over 100/negative/normal percentages 4. Integration (2 cases): LONG with SL/TP, SHORT with auto full close 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Only formatting changes: - api/server.go: fix indentation - manager/trader_manager.go: add blank line - trader/partial_close_test.go: align struct fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Problem: - trader/partial_close_test.go defined MockTrader - trader/auto_trader_test.go already has MockTrader - Methods CloseLong, CloseShort, SetStopLoss, SetTakeProfit were declared twice - Compilation failed with 'already declared' errors Solution: - Rename MockTrader to MockPartialCloseTrader in partial_close_test.go - This avoids naming conflict while keeping test logic independent Test Results: - All partial close tests pass - All trader tests pass Related: PR NoFxAiOS#713 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
c1cd77d to
4867ba4
Compare
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 🔧 Backend ChecksGo Formatting: Files needing formattingGo Vet: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
Includes: - PR NoFxAiOS#931: Fix Go formatting for test files - PR NoFxAiOS#800: Data staleness detection (Part 2/3) - already in z-dev-v2 - PR NoFxAiOS#918: Improve UX messages for empty states and error feedback - PR NoFxAiOS#922: Fix missing system_prompt_template field in trader edit - PR NoFxAiOS#921: Remove duplicate exchange config fields (Aster & Hyperliquid) - PR NoFxAiOS#917: Fix two-stage private key input validation (0x prefix support) - PR NoFxAiOS#713: Add backend safety checks for partial_close - PR NoFxAiOS#908: Web Crypto environment check (0xEmberZz) - PR NoFxAiOS#638: Decision limit selector with 5/10/20/50 options (xqliu) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> # Conflicts: # market/data.go # web/src/components/TwoStageKeyModal.tsx
* fix(trader): add backend safety checks for partial_close After PR NoFxAiOS#415 added partial_close functionality, production users reported two critical issues: 1. **Exchange minimum value error**: "Order must have minimum value of $10" when remaining position value falls below exchange threshold 2. **Unprotected positions after partial close**: Exchanges auto-cancel TP/SL orders when position size changes, leaving remaining position exposed to liquidation risk This PR adds **backend safety checks** as a safety net layer that complements the prompt-based rules from PR NoFxAiOS#712. **Protection**: Before executing partial_close, verify remaining position value > $10 ```go const MIN_POSITION_VALUE = 10.0 // Exchange底线 remainingValue := remainingQuantity * markPrice if remainingValue > 0 && remainingValue <= MIN_POSITION_VALUE { // 🔄 Auto-correct to full close decision.Action = "close_long" // or "close_short" return at.executeCloseLongWithRecord(decision, actionRecord) } ``` **Behavior**: - Position $20 → partial_close 50% → remaining $10 ≤ $10 → Auto full close ✅ - Position $30 → partial_close 50% → remaining $15 > $10 → Allow partial close ✅ **Protection**: Restore TP/SL orders for remaining position if AI provides new_stop_loss/new_take_profit ```go // Exchanges auto-cancel TP/SL when position size changes if decision.NewStopLoss > 0 { at.trader.SetStopLoss(symbol, side, remainingQuantity, decision.NewStopLoss) } if decision.NewTakeProfit > 0 { at.trader.SetTakeProfit(symbol, side, remainingQuantity, decision.NewTakeProfit) } // Warning if AI didn't provide new TP/SL if decision.NewStopLoss <= 0 && decision.NewTakeProfit <= 0 { log.Printf("⚠️ ⚠️ ⚠️ Warning: Remaining position has NO TP/SL protection") } ``` **Improvement**: Show position quantity and value to help AI make better decisions ``` Before: | 入场价100.00 当前价105.00 | 盈亏+5.00% | ... After: | 入场价100.00 当前价105.00 | 数量0.5000 | 仓位价值52.50 USDT | 盈亏+5.00% | ... ``` **Benefits**: - AI can now calculate: remaining_value = current_value × (1 - close_percentage/100) - AI can proactively avoid decisions that would violate $10 threshold - Added MIN_POSITION_VALUE check before execution - Auto-correct to full close if remaining value ≤ $10 - Restore TP/SL for remaining position - Warning logs when AI doesn't provide new TP/SL - Import "math" package - Calculate and display position value - Add quantity and position value to prompt - Complements PR NoFxAiOS#712 (Prompt v6.0.0 safety rules) - Addresses NoFxAiOS#301 (Backend layer) - Based on PR NoFxAiOS#415 (Core functionality) | Layer | Location | Purpose | |-------|----------|---------| | **Layer 1: AI Prompt** | PR NoFxAiOS#712 | Prevent bad decisions before they happen | | **Layer 2: Backend** | This PR | Auto-correct and safety net | **Together they provide**: - ✅ AI makes better decisions (sees position value, knows rules) - ✅ Backend catches edge cases (auto-corrects violations) - ✅ User-friendly warnings (explains what happened) - [x] Compiles successfully (`go build ./...`) - [x] MIN_POSITION_VALUE logic correct - [x] TP/SL restoration logic correct - [x] Position value display format validated - [x] Auto-correction flow tested This PR can be merged **independently** of PR NoFxAiOS#712, or together. Suggested merge order: 1. PR NoFxAiOS#712 (Prompt v6.0.0) - AI layer improvements 2. This PR (Backend safety) - Safety net layer Or merge together for complete two-layer protection. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: add error handling for markPrice type assertion - Check type assertion success before using markPrice - Return error if markPrice is invalid or <= 0 - Addresses code review feedback from @xqliu in PR NoFxAiOS#713 * test(trader): add comprehensive unit tests for partial_close safety checks - Test minimum position value check (< 10 USDT triggers full close) - Test boundary condition (exactly 10 USDT also triggers full close) - Test stop-loss/take-profit recovery after partial close - Test edge cases (invalid close percentages) - Test integration scenarios with mock trader All 14 test cases passed, covering: 1. MinPositionCheck (5 cases): normal, small remainder, boundary, edge cases 2. StopLossTakeProfitRecovery (4 cases): both/SL only/TP only/none 3. EdgeCases (4 cases): zero/over 100/negative/normal percentages 4. Integration (2 cases): LONG with SL/TP, SHORT with auto full close 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * style: apply go fmt after rebase Only formatting changes: - api/server.go: fix indentation - manager/trader_manager.go: add blank line - trader/partial_close_test.go: align struct fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix(test): rename MockTrader to MockPartialCloseTrader to avoid conflict Problem: - trader/partial_close_test.go defined MockTrader - trader/auto_trader_test.go already has MockTrader - Methods CloseLong, CloseShort, SetStopLoss, SetTakeProfit were declared twice - Compilation failed with 'already declared' errors Solution: - Rename MockTrader to MockPartialCloseTrader in partial_close_test.go - This avoids naming conflict while keeping test logic independent Test Results: - All partial close tests pass - All trader tests pass Related: PR NoFxAiOS#713 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: ZhouYongyou <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: the-dev-z <[email protected]>
- Integrate 4 high-value upstream commits: * Data staleness detection (NoFxAiOS#800) - prevents trading on frozen market data * Registration toggle (NoFxAiOS#760) - production-ready user registration control * Partial close safety checks (NoFxAiOS#713) - enhanced position management * PNL calculation accuracy (NoFxAiOS#963) - corrected profit/loss computation - Update frontend dependencies: sonner (1.5.0→2.0.7), react-router-dom (^7.9.5) - Remove unused @radix-ui/react-alert-dialog dependency - Standardize code formatting (trailing spaces) - Add VITE_API_URL configuration for Docker and dev environments - Update documentation for API base URL configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Merged 4 critical upstream commits: - PNL calculation fix (NoFxAiOS#963) - Data staleness detection (NoFxAiOS#800) - Registration toggle (NoFxAiOS#760) - Partial close safety checks (NoFxAiOS#713) All tests passing. Zero conflicts. Documentation complete.
Pull Request - Backend
🎯 Problem
After PR #415 added partial_close functionality, production users reported two critical issues:
🔧 Solution
This PR adds backend safety checks as a safety net layer that complements the prompt-based rules from PR #712.
1. Minimum Position Value Check (trader/auto_trader.go:1164-1189)
Protection: Before executing partial_close, verify remaining position value > $10
```go
const MIN_POSITION_VALUE = 10.0 // Exchange底线
remainingValue := remainingQuantity * markPrice
if remainingValue > 0 && remainingValue <= MIN_POSITION_VALUE {
// 🔄 Auto-correct to full close
decision.Action = "close_long" // or "close_short"
return at.executeCloseLongWithRecord(decision, actionRecord)
}
```
Behavior:
2. TP/SL Restoration After partial_close (trader/auto_trader.go:1211-1235)
Protection: Restore TP/SL orders for remaining position if AI provides new_stop_loss/new_take_profit
```go
// Exchanges auto-cancel TP/SL when position size changes
if decision.NewStopLoss > 0 {
at.trader.SetStopLoss(symbol, side, remainingQuantity, decision.NewStopLoss)
}
if decision.NewTakeProfit > 0 {
at.trader.SetTakeProfit(symbol, side, remainingQuantity, decision.NewTakeProfit)
}
// Warning if AI didn't provide new TP/SL⚠️ ⚠️ ⚠️ Warning: Remaining position has NO TP/SL protection")
if decision.NewStopLoss <= 0 && decision.NewTakeProfit <= 0 {
log.Printf("
}
```
3. Enhanced Position Info Display (decision/engine.go:378-384)
Improvement: Show position quantity and value to help AI make better decisions
```
Before: | 入场价100.00 当前价105.00 | 盈亏+5.00% | ...
After: | 入场价100.00 当前价105.00 | 数量0.5000 | 仓位价值52.50 USDT | 盈亏+5.00% | ...
```
Benefits:
📊 Changes
trader/auto_trader.go (+54 lines)
decision/engine.go (+8 lines)
Statistics: +59 lines, -3 lines
🔗 Related
⚡ Two-Layer Protection
Together they provide:
✅ Testing
📝 Notes
This PR can be merged independently of PR #712, or together.
Suggested merge order:
Or merge together for complete two-layer protection.
Both PRs are clean, focused, and have no conflicts with each other.
Co-Authored-By: Claude [email protected]
🎯 Type of Change | 變更類型
🔗 Related Issues | 相關 Issue
🧪 Testing | 測試
Test Environment | 測試環境
Manual Testing | 手動測試
Test Results | 測試結果
🔒 Security Considerations | 安全考慮
Additional security notes:
⚡ Performance Impact | 性能影響
If impacted, explain | 如果受影響,請說明:
僅在 partial_close 操作時增加檢查邏輯,對整體性能無影響。
✅ Checklist | 檢查清單
Code Quality | 代碼質量
go build)go fmt| 已運行go fmtDocumentation | 文檔
Git
devbranch | 已 rebase 到最新dev分支By submitting this PR, I confirm | 提交此 PR,我確認:
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]