mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-06-06 05:51:19 +08:00
## Summary - Add POST /traders/:id/sync-balance endpoint (Option B) - Add smart detection showing balance change percentage (Option C) - Fix balance display bug caused by commit2b9c4d2## Changes ### api/server.go - Add handleSyncBalance() handler - Query actual exchange balance via trader.GetBalance() - Calculate change percentage for smart detection - Update initial_balance in database - Reload trader into memory after update ### config/database.go - Add UpdateTraderInitialBalance() method - Update traders.initial_balance field ## Root Cause Commit2b9c4d2auto-queries exchange balance at trader creation time, but never updates after user deposits more funds, causing: - Wrong initial_balance (400 USDT vs actual 3000 USDT) - Wrong P&L calculations (-2598.55 USDT instead of actual) ## Solution Provides manual sync API + smart detection to update initial_balance when user deposits funds after trader creation. Co-Authored-By: tinkle-community <tinklefund@gmail.com>