Commit Graph

11 Commits

Author SHA1 Message Date
ZhouYongyou
e8f05d1761 feat(trader): add automatic balance sync every 30 minutes
## Summary
Automatically sync trader's initial_balance when exchange balance changes
significantly (>5%), eliminating the need for manual intervention after
deposits/withdrawals.

## Changes

### trader/auto_trader.go
- Add fields: lastBalanceSyncTime, database, userID
- Add autoSyncBalanceIfNeeded() method:
  * Check every 30 minutes (配合3分钟扫描周期,约10次扫描触发一次)
  * Query exchange balance via trader.GetBalance()
  * Update if change >5%
  * Log changes with emoji indicators
- Integrate into runCycle() before trading decisions

### manager/trader_manager.go
- Update NewAutoTrader() calls to pass database and userID
- Update method signatures:
  * addTraderFromDB()
  * AddTraderFromDB()
  * loadSingleTrader()

## Configuration

- Check interval: 30 minutes
- Change threshold: 5%
- Automatic detection and update

## Benefits

 完全自动化,无需手动调用API
 30分钟检查间隔,及时又不频繁
 智能判断(变化>5%才更新)
 充值/提现后自动更新initial_balance
 前端P&L显示自动修正

## Example Logs

🔄 [DS-BF] 开始自动检查余额变化...
🔔 [DS-BF] 检测到余额大幅变化: 693.00 → 3000.00 USDT (333.33%)
 [DS-BF] 已自动同步余额到数据库

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 20:31:40 +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
SkywalkerJi
4250c11ddf Supports custom system prompts and custom models. 2025-11-01 19:45:54 +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
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
nobody
e1d5a6405c feat: Add Hyperliquid exchange support with unified trader interface
Major changes:
- Add full Hyperliquid trading support (long/short, leverage, SL/TP)
- Create unified Trader interface for multi-exchange support
- Implement automatic precision handling for orders and prices
- Fix balance calculation and unrealized P&L display
- Add comprehensive configuration guide in README

New features:
- Support for both Binance and Hyperliquid exchanges
- Automatic order size precision based on szDecimals
- Price formatting with 5 significant figures
- Non-custodial trading with Ethereum private key
- Seamless exchange switching via configuration

Technical details:
- Add trader/interface.go for unified trader interface
- Add trader/hyperliquid_trader.go for Hyperliquid implementation
- Update manager and auto_trader to support multiple exchanges
- Add go-hyperliquid SDK dependency
- Fix precision errors (float_to_wire, invalid price)

Fixes:
- Correct calculation of wallet balance and unrealized P&L
- Proper handling of AccountValue vs TotalRawUsd
- Frontend display issues for total equity and P&L

Documentation:
- Add Hyperliquid setup guide in README
- Update config.json.example with both exchanges
- Add troubleshooting section for common errors

Tested with live trading on Hyperliquid mainnet.
No breaking changes - backward compatible with existing configs.
2025-10-29 20:00:30 +08:00
tinkle
7e8a494ed3 Initial commit: NOFX AI Trading System
- Multi-AI competition mode (Qwen vs DeepSeek)
- Binance Futures integration
- AI self-learning mechanism
- Professional web dashboard
- Complete risk management system
2025-10-28 15:47:34 +08:00