shinchan-zhai
3c39d1efbe
fix: consistent safe type helpers in auto_trader, log emergency exit errors
...
- Replace all raw pos["key"].(type) assertions with posFloat64/posString/posInt64 helpers
across auto_trader_decision, auto_trader_grid, auto_trader_grid_orders,
auto_trader_grid_regime, auto_trader_loop, auto_trader_orders, auto_trader_risk
- Add posInt64 helper for int64 extraction (createdTime etc)
- Fix emergencyExit: log CloseLong/CloseShort errors instead of silently dropping
- Fix emergencyExit: log GetPositions error on failure
- Upgrade closeAllPositions log level from Infof to Warnf for close failures
- Zero raw type assertions remaining in auto_trader_* files
2026-03-25 01:05:54 +08:00
shinchan-zhai
6911bc3e2b
fix: prevent panics from unsafe type assertions in trading code + add request body limit
...
Security & Reliability:
- Add requestBodyLimitMiddleware (1MB) to prevent OOM from oversized API payloads
- Fix defer resp.Body.Close() inside loop in getPublicIPFromAPI (connection leak)
- Add posFloat64/posString safe helpers for position map access
Panic Prevention (critical for trading):
- Convert 30+ unsafe type assertions (pos["key"].(type)) to safe comma-ok
pattern across all exchange traders: OKX, Hyperliquid, Aster, Bybit,
KuCoin, Gate, Bitget, Binance
- Fix auto_trader_risk.go: drawdown monitor could panic and silently stop
monitoring, leaving positions unprotected
- Fix auto_trader_decision.go & auto_trader_loop.go: core trading loop
position parsing now crash-proof
- All trader/ code now has zero unsafe type assertions
Frontend:
- Fix config.ts: rejected promise cached forever on network error (never retries)
2026-03-25 01:05:54 +08:00
shinchan-zhai
4e4b4ceed7
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
2026-03-21 19:59:00 +08:00
shinchan-zhai
fd77f2df3e
feat: AI cost tracking, pre-launch balance check, low balance alerts
...
- store/ai_charge.go: local AI cost tracking per call (SQLite)
- wallet/usdc.go: shared USDC balance query (Base chain RPC)
- Pre-launch: estimate daily cost + runway days
- Low balance: warn <$1, error at $0 (every 10 cycles)
- API: GET /api/ai-costs for cost history
- Frontend: model cards show price per call
- Frontend: wallet create + QR deposit + balance display
2026-03-21 12:31:20 +08:00
tinkle-community
736d2d385d
refactor: optimize codebase encoding
2026-03-12 16:14:56 +08:00
tinkle-community
8e294a5eed
refactor: restructure project directories for better modularity
...
- Delete llm/ dead code (3 files, zero references)
- Split mcp/ into sub-packages: mcp/provider/ (8 providers) and
mcp/payment/ (4 payment clients) with registry pattern
- Export Client internal fields and ClientHooks interface for
sub-package access
- Split api/server.go (3892 lines) into 8 domain-specific handler files
- Split trader/auto_trader.go (2296 lines) into 5 focused files
- Reorganize web/src/components/ flat files into auth/, charts/,
trader/, common/, modals/, backtest/ subdirectories
- Update all consumer imports to use registry-based provider creation
2026-03-11 23:58:13 +08:00