mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-13 07:46:54 +08:00
feat(api): add manual balance sync endpoint to z-dev
- Add POST /traders/:id/sync-balance endpoint - Query actual exchange balance and update initial_balance - Smart detection: shows balance change percentage - Supports Binance, Hyperliquid, Aster exchanges - Reload trader into memory after update This complements the existing auto-query feature (feat/query-actual-balance-v2): - Auto-query: Prevents issue at creation time - Manual sync: Fixes issue after deposits/withdrawals 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -863,6 +863,12 @@ func (d *Database) UpdateTraderCustomPrompt(userID, id string, customPrompt stri
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateTraderInitialBalance 更新交易员初始余额(用于同步交易所实际余额)
|
||||
func (d *Database) UpdateTraderInitialBalance(userID, id string, newBalance float64) error {
|
||||
_, err := d.db.Exec(`UPDATE traders SET initial_balance = ? WHERE id = ? AND user_id = ?`, newBalance, id, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteTrader 删除交易员
|
||||
func (d *Database) DeleteTrader(userID, id string) error {
|
||||
_, err := d.db.Exec(`DELETE FROM traders WHERE id = ? AND user_id = ?`, id, userID)
|
||||
|
||||
Reference in New Issue
Block a user