ZhouYongyou
|
8a1e931857
|
fix: prevent initial_balance modification and fix equity history calculation
## 核心問題修復
1. **API 層保護** (api/server.go - handleUpdateTrader)
- 檢測並阻止任何修改 initial_balance 的嘗試
- 強制使用原始 initial_balance 值
- 記錄詳細的警告日誌和嘗試修改的細節
- 返回友善的錯誤訊息給用戶
2. **資料庫層保護** (config/database.go - UpdateTrader)
- 從 UPDATE SQL 語句中移除 initial_balance 欄位
- 雙重防護:即使 API 層被繞過,DB 也不會更新
3. **修復盈虧計算錯誤** (api/server.go - handleEquityHistory)
- ✅ 修復:從資料庫讀取 initial_balance 作為唯一真實來源
- ❌ 移除:錯誤的後備邏輯(使用 records[0].TotalBalance)
- ✅ 重新計算:基於正確的 initial_balance 重算所有盈虧百分比
## 影響範圍
- 用戶無法再通過 UpdateTrader API 修改 initial_balance
- 解決「初始餘額異常變動」的根本原因
- 確保盈虧計算始終基於正確的基準值
## 技術細節
- 浮點數比較容差:0.01 USDT (避免浮點數精度問題)
- 錯誤碼:INITIAL_BALANCE_IMMUTABLE
- 日誌格式:包含 user_id, trader_id, 原值, 請求值, 差異
Related-Issue: 用戶報告「初始餘額變少」問題
|
2025-11-05 01:54:36 +08:00 |
|
ZhouYongyou
|
e36ffc5a18
|
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>
|
2025-11-04 20:11:40 +08:00 |
|
ZhouYongyou
|
16c3745afd
|
fix: GetTraderConfig missing critical fields in SELECT/Scan
**Problem**:
- GetTraderConfig was missing 9 critical fields in SELECT statement
- Missing corresponding Scan variables
- Caused trader edit UI to show 0 for leverage and empty trading_symbols
**Root Cause**:
Database query only selected basic fields (id, name, balance, etc.)
but missed leverage, trading_symbols, prompts, and all custom configs
**Fix**:
- Added missing fields to SELECT:
* btc_eth_leverage, altcoin_leverage
* trading_symbols
* use_coin_pool, use_oi_top
* custom_prompt, override_base_prompt
* system_prompt_template
* is_cross_margin
* AI model custom_api_url, custom_model_name
- Added corresponding Scan variables to match SELECT order
**Impact**:
✅ Trader edit modal now displays correct leverage values
✅ Trading symbols list properly populated
✅ All custom configurations preserved and displayed
✅ API endpoint /traders/:id/config returns complete data
**Testing**:
- ✅ Go compilation successful
- ✅ All fields aligned (31 SELECT = 31 Scan)
- ✅ API layer verified (api/server.go:887-904)
Reported by: 寒江孤影
Issue: Trader config edit modal showing 0 leverage and empty symbols
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-03 23:18:47 +08:00 |
|
vicnoah
|
89814b612e
|
Merge branch 'dev' into dev
|
2025-11-02 22:14:42 +08:00 |
|
yuanshi2016
|
3b1db6f64f
|
K线获取方式改为websocket组合流. 带重拨机制
流程为下:
1. 启动时使用所有交易员设置的币种(去重) 如果交易员未配置,则使用系统默认
2. 在决策获取K线时 如果没有缓存 则先实时获取后再添加订阅. ps: 适用于Api方式的币种列表
|
2025-11-02 14:03:13 +08:00 |
|
wwg
|
d2af549bac
|
feat(config): 增加新闻源配置与数据库迁移支持
- 在config.json.example中添加新闻源相关配置示例,支持telegram频道订阅
- 扩展数据库表结构,新增traders表多字段支持信号源和杠杆参数
- 新增NewsConfig结构体及相关telegram新闻配置数据模型
- 在交易决策上下文结构Context中添加新闻数据news字段支持传递新闻
- 在交易决策构建用户提示信息时加入相关新闻内容
- 优化数据库操作代码,支持交易所和交易员配置的完整字段读取与更新
- 添加数据库exchanges表迁移逻辑,重建表结构和触发器以支持新字段
- 引入第三方库github.com/samber/lo用于集合操作
- 在go.mod添加新的依赖模块,并更新相关依赖版本
|
2025-11-01 23:10:02 +08:00 |
|
icy
|
2538d2f928
|
Merge branch 'dev' of https://github.com/tinkle-community/nofx
|
2025-11-01 20:09:17 +08:00 |
|
SkywalkerJi
|
4250c11ddf
|
Supports custom system prompts and custom models.
|
2025-11-01 19:45:54 +08:00 |
|
icy
|
996b152eba
|
Resolve merge conflicts in AITradersPage.tsx
- Fixed import statement conflict (using 'type Language')
- Merged exchange configuration logic preserving support for multiple exchange types
- Kept comprehensive form handling for Binance, Hyperliquid, Aster, and OKX exchanges
- Updated security warning messages to use proper translation keys
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-01 19:01:44 +08:00 |
|
icy
|
f413f87f39
|
Fixed health check; Fixed dex config; Add rank trader info view;
|
2025-11-01 18:58:32 +08:00 |
|
SkywalkerJi
|
48d1320209
|
* Fixed the custom model URL.
* Added functionality for custom model names.
|
2025-11-01 16:09:15 +08:00 |
|
icy
|
a7cc5e5ed4
|
竞赛fix、交易员新增参数
|
2025-11-01 02:17:11 +08:00 |
|
icy
|
8296d9843a
|
Sync config.json to config.db for manual modify admin_mode and other configs
|
2025-10-31 15:24:18 +08:00 |
|
icy
|
517d0caf6f
|
admin_mode config
|
2025-10-31 14:34:53 +08:00 |
|
icy
|
d0621265aa
|
Add MarginMode configration
|
2025-10-31 13:14:24 +08:00 |
|
icy
|
a85d38cb59
|
rename fix
|
2025-10-31 04:07:14 +08:00 |
|
icy
|
ac7c40632d
|
account system、custom prompt
|
2025-10-31 03:42:01 +08:00 |
|
icy
|
4f5b8b250a
|
sync fork
|
2025-10-30 20:51:22 +08:00 |
|