CoderMageFox
970fa61f09
fix: 修复InitialBalance配置错误导致的P&L统计不准确问题
...
用户在使用Aster交易员时发现,即使没有开始交易,P&L统计也显示了12.5 USDT (83.33%)的盈亏。经过调查发现:
**根本原因**:
- 实际Aster账户余额:27.5 USDT
- Web界面配置的InitialBalance:15 USDT ❌
- 错误的P&L计算:27.5 - 15 = 12.5 USDT (83.33%)
**问题根源**:
1. Web界面创建交易员时默认initial_balance为1000 USDT
2. 用户手动修改时容易输入错误的值
3. 缺少自动获取实际余额的功能
4. 缺少明确的警告提示
**文件**: `trader/aster_trader.go`
- ✅ 验证Aster API完全兼容Binance格式
- 添加详细的注释说明字段含义
- 添加调试日志以便排查问题
- 确认balance字段不包含未实现盈亏(与Binance一致)
**关键确认**:
```go
// ✅ Aster API完全兼容Binance API格式
// balance字段 = wallet balance(不包含未实现盈亏)
// crossUnPnl = unrealized profit(未实现盈亏)
// crossWalletBalance = balance + crossUnPnl(全仓钱包余额,包含盈亏)
```
**文件**: `web/src/components/TraderConfigModal.tsx`
**新增功能**:
1. **编辑模式**:添加"获取当前余额"按钮
- 一键从交易所API获取当前账户净值
- 自动填充到InitialBalance字段
- 显示加载状态和错误提示
2. **创建模式**:添加警告提示
- ⚠️ 提醒用户必须输入交易所的当前实际余额
- 警告:如果输入不准确,P&L统计将会错误
3. **改进输入体验**:
- 支持小数输入(step="0.01")
- 必填字段标记(创建模式)
- 实时错误提示
**代码实现**:
```typescript
const handleFetchCurrentBalance = async () => {
const response = await fetch(`/api/account?trader_id=${traderData.trader_id}`);
const data = await response.json();
const currentBalance = data.total_equity; // 当前净值
setFormData(prev => ({ ...prev, initial_balance: currentBalance }));
};
```
通过查阅Binance官方文档确认:
| 项目 | Binance | Aster (修复后) |
|------|---------|----------------|
| **余额字段** | balance = 钱包余额(不含盈亏) | ✅ 相同 |
| **盈亏字段** | crossUnPnl = 未实现盈亏 | ✅ 相同 |
| **总权益** | balance + crossUnPnl | ✅ 相同 |
| **P&L计算** | totalEquity - initialBalance | ✅ 相同 |
1. 编辑交易员配置
2. 点击"获取当前余额"按钮
3. 系统自动填充正确的InitialBalance
4. 保存配置
1. 查看交易所账户的实际余额
2. 准确输入到InitialBalance字段
3. 注意查看警告提示
4. 完成创建
- [x] 确认Aster API返回格式与Binance一致
- [x] 验证"获取当前余额"功能正常工作
- [x] 确认P&L计算公式正确
- [x] 前端构建成功
- [x] 警告提示正常显示
- **修复**: 解决InitialBalance配置错误导致的P&L统计不准确问题
- **改进**: 提升用户体验,减少配置错误
- **兼容**: 完全向后兼容,不影响现有功能
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-05 12:49:55 +08:00
SkywalkerJi
e11e72dfe3
Merge pull request #489 from 0xEmberZz/feature/eslint&prettier
...
Feature/eslint&prettier
2025-11-05 13:01:29 +09:00
Ember
4978f9e8b8
feat: add ESLint and Prettier with pre-commit hook
...
- Install ESLint 9 with TypeScript and React support
- Install Prettier with custom configuration (no semicolons)
- Add husky and lint-staged for pre-commit hooks
- Configure lint-staged to auto-fix and format on commit
- Relax ESLint rules to avoid large-scale code changes
- Format all existing code with Prettier (no semicolons)
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-05 11:41:14 +08:00
Ember
c276eba151
test: verify pre-commit hook formatting
2025-11-05 11:40:05 +08:00
Ember
6f760c3b0f
test: add eslint and prettier configuration with pre-commit hook
2025-11-05 11:40:05 +08:00
Ember
8350c31406
fix: resolve Web UI display issues ( #365 )
...
## Fixes
### 1. Typewriter Component - Missing First Character
- Fix character loss issue where first character of each line was missing
- Add proper state reset logic before starting typing animation
- Extract character before setState to avoid closure issues
- Add setTimeout(0) to ensure state is updated before typing starts
- Change dependency from `lines` to `sanitizedLines` for correct updates
- Use `??` instead of `||` for safer null handling
### 2. Chinese Translation - Leading Spaces
- Remove leading spaces from startupMessages1/2/3 in Chinese translations
- Ensures proper display of startup messages in terminal simulation
### 3. Dynamic GitHub Stats with Animation
- Add useGitHubStats hook to fetch real-time GitHub repository data
- Add useCounterAnimation hook with easeOutExpo easing for smooth number animation
- Display dynamic star count with smooth counter animation (2s duration)
- Display dynamic days count (static, no animation)
- Support bilingual display (EN/ZH) with proper formatting
## Changes
- web/src/components/Typewriter.tsx: Fix first character loss bug
- web/src/i18n/translations.ts: Remove leading spaces in Chinese messages
- web/src/components/landing/HeroSection.tsx: Add dynamic GitHub stats
- web/src/hooks/useGitHubStats.ts: New hook for GitHub API integration
- web/src/hooks/useCounterAnimation.ts: New hook for number animations
Fixes #365
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-05 11:40:05 +08:00
Shui
0474c455c9
Merge pull request #444 from 0xEmberZz/fix/login-redirect-loop-422
...
fix: resolve login redirect loop issue (#422 )
2025-11-04 22:08:27 -05:00
Shui
c2afaaa533
Merge pull request #421 from Im-Sue/fix/trader-manager-hyperliquid-testnet-clean
...
fix(trader): add missing HyperliquidTestnet configuration in loadSing…
2025-11-04 22:04:13 -05:00
Diego
8d36a5affa
Merge pull request #399 from tangmengqiu/fix/hyperliquid_setup
...
fix(setup): hyperliquid setup, no need to enter the wallet address, improve user experience
2025-11-05 10:23:26 +08:00
tangmengqiu
7434039efc
fix conflict
2025-11-04 21:22:44 -05:00
SkywalkerJi
160efc5410
Merge pull request #480 from SkywalkerJi/dev
...
fix(AI): Change the default model to qwen3-max to mitigate output quality issues caused by model downgrading.
2025-11-05 11:02:06 +09:00
Shui
d2ede535a1
Merge pull request #477 from xqliu/fix/ai-max-tokens-env-var
...
fix: add AI_MAX_TOKENS environment variable to prevent response truncation
2025-11-04 20:54:15 -05:00
Shui
335a88b74a
Merge pull request #478 from ERIC961/docs/config-file-name
...
docs: config.example.jsonc替换成config.json.example
2025-11-04 20:52:46 -05:00
SkywalkerJi
96e5d4b56c
Change the default model to qwen3-max to mitigate output quality issues caused by model downgrading.
2025-11-05 09:50:05 +08:00
Liu Xiang Qian
edea0209a0
fix: add AI_MAX_TOKENS environment variable to prevent response truncation
...
## Problem
AI responses were being truncated due to a hardcoded max_tokens limit of 2000,
causing JSON parsing failures. The error occurred when:
1. AI's thought process analysis was cut off mid-response
2. extractDecisions() incorrectly extracted MACD data arrays from the input prompt
3. Go failed to unmarshal numbers into Decision struct
Error message:
```
json: cannot unmarshal number into Go value of type decision.Decision
JSON内容: [-867.759, -937.406, -1020.435, ...]
```
## Solution
- Add MaxTokens field to mcp.Client struct
- Read AI_MAX_TOKENS from environment variable (default: 2000)
- Set AI_MAX_TOKENS=4000 in docker-compose.yml for production use
- This provides enough tokens for complete analysis with the 800-line trading strategy prompt
## Testing
- Verify environment variable is read correctly
- Confirm AI responses are no longer truncated
- Check decision logs for complete JSON output
2025-11-05 09:31:58 +08:00
liangjiahao
186908ff4e
docs: config.example.jsonc替换成config.json.example
2025-11-05 09:24:38 +08:00
Shui
5b8cb47b99
Merge pull request #476 from hzb1115/dev
...
fix(workflow): simplify PR template
2025-11-04 20:18:35 -05:00
Shui
3b55d7e307
Merge pull request #3 from hzb1115/feature/pr-template-automation
...
feat(templates): add intelligent PR template selection system
2025-11-04 16:05:50 -05:00
zbhan
43816cc073
Fix PR tpl
2025-11-04 16:05:29 -05:00
zbhan
c851e1c7cd
feat(templates): add intelligent PR template selection system
...
- Created specialized PR templates for different change types:
- Backend template for Go/API changes
- Frontend template for UI/UX changes
- Documentation template for docs updates
- General template for mixed changes
- Simplified default template from 270 to 115 lines
- Added GitHub Action for automatic template suggestion based on file types
- Auto-labels PRs with appropriate categories (backend/frontend/documentation)
- Provides friendly suggestions when default template is used
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-04 15:52:01 -05:00
Icyoung
e0ba0098c9
Merge pull request #466 from zhouyongyou/fix/websocket-crash
...
fix(market): prevent program crash on WebSocket failure
2025-11-05 02:14:23 +08:00
ZhouYongyou
beaa90e0b0
fix(market): prevent program crash on WebSocket failure
...
## Problem
- Program crashes with log.Fatalf when WebSocket connection fails
- Triggered by WebSocket hijacking issue (157.240.12.50)
- Introduced in commit 3b1db6f (K-line WebSocket migration)
## Solution
- Replace 4x log.Fatalf with log.Printf in monitor.go
- Lines 177, 183, 189, 215
- Program now logs error and continues running
## Changes
1. Initialize failure: Fatalf → Printf (line 177)
2. Connection failure: Fatalf → Printf (line 183)
3. Subscribe failure: Fatalf → Printf (line 189)
4. K-line subscribe: Fatalf → Printf + dynamic period (line 215)
## Fallback
- System automatically uses API when WebSocket cache is empty
- GetCurrentKlines() has built-in degradation mechanism
- No data loss, slightly slower API calls as fallback
## Impact
- ✅ Program stability: Won't crash on network issues
- ✅ Error visibility: Clear error messages in logs
- ✅ Data integrity: API fallback ensures K-line availability
Related: websocket-hijack-fix.md, auto-stop-bug-analysis.md
2025-11-05 02:06:54 +08:00
SkywalkerJi
aaef9fe447
Merge pull request #464 from SkywalkerJi/dev
...
fix: Fix code formatting to avoid PR Checks / Backend Code Quality (Go) checks reporting errors.
2025-11-05 03:03:09 +09:00
SkywalkerJi
8a877fe5dc
Fixed go fmt code formatting issues.
2025-11-05 01:42:36 +08:00
SkywalkerJi
87c99dae3b
log.Printf mandates that its first argument must be a compile-time constant string.
2025-11-05 01:36:44 +08:00
Ember
ed09482f4b
fix: resolve login redirect loop issue ( #422 )
...
- Redirect to /traders instead of / after successful login/registration
- Make 'Get Started Now' button redirect logged-in users to /traders
- Prevent infinite loop where logged-in users are shown landing page repeatedly
Fixes issue where after login success, clicking "Get Started Now" would
show login modal again instead of entering the main application.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-04 22:30:31 +08:00
SkywalkerJi
b407abe1da
Merge pull request #425 from zhouyongyou/fix/prompts-action-names-minimal
...
fix(prompts): rename actions to match backend implementation
提示词对齐
2025-11-04 21:27:50 +09:00
ZhouYongyou
f35982cde5
fix(prompts): rename actions to match backend implementation
...
## Problem
Backend code expects these action names:
- `open_long`, `open_short`, `close_long`, `close_short`
But prompts use outdated names:
- `buy_to_enter`, `sell_to_enter`, `close`
This causes all trading decisions to fail with unknown action errors.
## Solution
Minimal changes to fix action name compatibility:
### prompts/nof1.txt
- ✅ `buy_to_enter` → `open_long`
- ✅ `sell_to_enter` → `open_short`
- ✅ `close` → `close_long` / `close_short`
- ✅ Explicitly list `wait` action
- +18 lines, -6 lines (only action definitions section)
### prompts/adaptive.txt
- ✅ `buy_to_enter` → `open_long`
- ✅ `sell_to_enter` → `open_short`
- ✅ `close` → `close_long` / `close_short`
- +15 lines, -6 lines (only action definitions section)
## Impact
- ✅ Trading decisions now execute successfully
- ✅ Maintains all existing functionality
- ✅ No new features added (minimal diff)
## Verification
```bash
# Backend expects these actions:
grep 'Action string' decision/engine.go
# "open_long", "open_short", "close_long", "close_short", ...
# Old names removed:
grep -r "buy_to_enter\|sell_to_enter" prompts/
# (no results)
```
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-04 19:41:23 +08:00
sue
aa558b6a66
fix(trader): add missing HyperliquidTestnet configuration in loadSingleTrader
...
修复了 loadSingleTrader 函数中缺失的 HyperliquidTestnet 配置项,
确保 Hyperliquid 交易所的测试网配置能够正确传递到 trader 实例。
Changes:
- 在 loadSingleTrader 中添加 HyperliquidTestnet 字段配置
- 代码格式优化(空格对齐)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-04 19:02:39 +08:00
tinkle-community
b4313daaf4
Merge pull request #404 from 0xEmberZz/feature/binance-guide
...
feat: Add Binance setup guide with tutorial modal
2025-11-04 15:35:19 +08:00
Ember
cd9cd42267
feat: Add Binance setup guide with tutorial modal
...
- Add Binance configuration tutorial image (guide.png)
- Implement "View Guide" button in exchange configuration modal
- Add tutorial display modal with image viewer
- Add i18n support for guide-related text (EN/ZH)
- Button only appears when configuring Binance exchange
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-04 14:50:38 +08:00
tangmengqiu
64f6be492b
fix print
2025-11-04 00:29:37 -05:00
tangmengqiu
09c88f8777
fix go vet check
2025-11-04 00:24:34 -05:00
tangmengqiu
9b006654b4
fix pk prefix handle
2025-11-04 00:03:56 -05:00
tangmengqiu
1b7632bfb2
fix
2025-11-03 23:43:06 -05:00
tangmengqiu
a81cc7c745
feat(hyperliquid): Auto-generate wallet address from private key
...
Enable automatic wallet address generation from private key for Hyperliquid
exchange, simplifying user onboarding and reducing configuration errors.
Backend Changes (trader/hyperliquid_trader.go):
- Import crypto/ecdsa package for ECDSA public key operations
- Enable wallet address auto-generation when walletAddr is empty
- Use crypto.PubkeyToAddress() to derive address from private key
- Add logging for both auto-generated and manually provided addresses
Frontend Changes (web/src/components/AITradersPage.tsx):
- Remove wallet address required validation (only private key required)
- Update button disabled state to only check private key
- Add "Optional" label to wallet address field
- Add dynamic placeholder with bilingual hint
- Show context-aware helper text based on input state
- Remove HTML required attribute from input field
Translation Updates (web/src/i18n/translations.ts):
- Add 'optional' translation (EN: "Optional", ZH: "可选")
- Add 'hyperliquidWalletAddressAutoGenerate' translation
EN: "Leave blank to automatically generate wallet address from private key"
ZH: "留空将自动从私钥生成钱包地址"
Benefits:
✅ Simplified UX - Users only need to provide private key
✅ Error prevention - Auto-generated address always matches private key
✅ Backward compatible - Manual address input still supported
✅ Better UX - Clear visual indicators for optional fields
Technical Details:
- Uses Ethereum standard ECDSA public key to address conversion
- Implementation was already present but commented out (lines 37-43)
- No database schema changes required (hyperliquid_wallet_addr already nullable)
- Fallback behavior: manual input > auto-generation
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-03 23:15:38 -05:00
SkywalkerJi
92272fc2b0
fix the main branch history issue from November 3rd.
...
Merge pull request #395 from NoFxAiOS/beta
fix:fix the main branch history issue from November 3rd.
2025-11-04 13:00:05 +09:00
tinkle-community
3843ed4842
Merge pull request #389 from NoFxAiOS/beta
...
Fix:fix the main branch history issue from November 3rd.
2025-11-04 11:22:10 +08:00
Shui
f574aafddb
Merge pull request #354 from zhouyongyou/fix/trader-config-missing-fields
...
fix(database): GetTraderConfig missing critical fields causes edit to fail
2025-11-03 21:57:48 -05:00
Shui
017c30fa4e
Merge pull request #373 from hzb1115/dev
...
fix(readme): update readme and pr reviewer
2025-11-03 21:07:31 -05:00
zbhan
9a2991fd92
Fix owner
2025-11-03 21:06:25 -05:00
zbhan
f92d0cbe83
fix owner
2025-11-03 20:56:16 -05:00
zbhan
0fb9fa8a2e
fix(readme): update readme and pr reviewer
2025-11-03 20:50:56 -05:00
Luna Martinez
50044837ed
Merge pull request #362 from hzb1115/dev
...
Fix(workflow): add title and size validation comments
2025-11-03 13:20:02 -05:00
Luna Martinez
5ff6cdbb1c
Merge branch 'NoFxAiOS:dev' into dev
2025-11-03 13:16:11 -05:00
Icyoung
24798a4fc6
Merge pull request #361 from Icyoung/beta
...
Beta bugfix
2025-11-04 02:14:54 +08:00
zbhan
18d648a411
Fix PR check
2025-11-03 13:12:47 -05:00
icy
14a0ef090e
Add NOFX watermarks to charts and fix empty state internationalization
...
- Add NOFX watermark to ComparisonChart (competition page)
- Add NOFX watermark to EquityChart (dashboard page)
- Fix empty state handling and internationalization in CompetitionPage
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-04 02:08:38 +08:00
icy
ab41d5a73d
Fix ComparisonChart data display issue
...
The chart was not showing data because the API response format changed.
Fixed the calculation of PnL percentage by computing it from total_pnl
and balance values (initial_balance = balance - total_pnl).
Now the AI competition chart should properly display performance comparison data.
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: tinkle-community <tinklefund@gmail.com >
2025-11-04 01:54:21 +08:00
Icyoung
6f9510e458
Merge pull request #359 from Icyoung/beta
...
Beta Merge dev、Bug fix
2025-11-04 01:50:34 +08:00