feat: safe mode — auto-protect positions when AI fails 3+ times

- Track consecutive AI failures
- After 3 failures: activate safe mode (no new positions, close/hold only)
- Auto-deactivate when AI recovers
- Keep loop running in safe mode (retry each cycle)
- Log clearly: 🛡️ SAFE MODE ACTIVATED/DEACTIVATED
This commit is contained in:
shinchan-zhai
2026-03-21 19:59:00 +08:00
parent fd77f2df3e
commit 4e4b4ceed7
2 changed files with 48 additions and 0 deletions

View File

@@ -148,6 +148,9 @@ type AutoTrader struct {
userID string // User ID
gridState *GridState // Grid trading state (only used when StrategyType == "grid_trading")
claw402WalletAddr string // Claw402 wallet address (derived from private key at start)
consecutiveAIFailures int // Consecutive AI call failures
safeMode bool // Safe mode: no new positions, protect existing ones
safeModeReason string // Why safe mode was activated
}
// NewAutoTrader creates an automatic trader