Commit Graph

484 Commits

Author SHA1 Message Date
Icyoung 7bfefbb356 Merge branch 'dev' into fix/partial-close-stats 2025-11-05 16:11:53 +08:00
Icyoung e9c6424e95 Merge pull request #433 from zhouyongyou/fix/dual-side-position-mode
fix(binance): initialize dual-side position mode to prevent code=-4061 errors
2025-11-05 16:09:37 +08:00
Icyoung c517cde988 Merge pull request #435 from zhouyongyou/fix/trader-config-overwrite
fix(margin): correct position sizing formula to prevent insufficient margin errors
2025-11-05 16:08:18 +08:00
Icyoung 1e2aff80d4 Merge branch 'dev' into fix/trader-config-overwrite 2025-11-05 16:05:40 +08:00
Icyoung c0cb37252b Merge pull request #434 from zhouyongyou/fix/stop-loss-take-profit-separation
fix(trader): separate stop-loss and take-profit order cancellation to prevent accidental deletions
2025-11-05 16:05:00 +08:00
Icyoung ee0e241643 Merge pull request #429 from zhouyongyou/feat/auto-balance-sync
feat(trader): add automatic balance sync every 10 minutes
2025-11-05 16:02:21 +08:00
tinkle-community 7aa24f8593 Merge pull request #493 from simonjiang99/fix/3-minutes-minimum
fix(api):enforce minimum scan interval of three minutes
2025-11-05 16:02:04 +08:00
Icyoung 52f3985408 Merge branch 'dev' into feat/auto-balance-sync 2025-11-05 16:01:57 +08:00
Icyoung 0bcd24c523 Merge pull request #428 from zhouyongyou/fix/initial-balance-sync
fix(api): add balance sync endpoint with smart detection
2025-11-05 15:58:45 +08:00
Icyoung d675c20eed Merge pull request #416 from zhouyongyou/fix/bug-fixes-collection-v2
fix: 修復 6 個 bug(替代 #271)
2025-11-05 15:57:36 +08:00
Icyoung 0da42bd1fd Merge branch 'dev' into fix/bug-fixes-collection-v2 2025-11-05 15:56:58 +08:00
Icyoung 87e2ba8214 Merge pull request #471 from zhouyongyou/fix/hyperliquid-complete-balance-fix
fix(hyperliquid): complete balance detection with 4 critical fixes
2025-11-05 15:47:15 +08:00
Icyoung 90b1b03697 Merge pull request #446 from zhouyongyou/fix/json-fullwidth-characters
fix(decision): handle fullwidth JSON characters from AI responses
2025-11-05 15:46:56 +08:00
Icyoung e33f9babfe Merge pull request #386 from zhouyongyou/feat/configurable-oi-threshold
feat(decision): configurable OI threshold + relaxed trading template
2025-11-05 15:46:25 +08:00
Icyoung 19628fa9df Merge pull request #385 from zhouyongyou/fix/market-price-staleness
fix(market): resolve price staleness causing trade failures
2025-11-05 15:45:52 +08:00
Icyoung cdfe8956ce Merge pull request #414 from zhouyongyou/feat/query-actual-balance-v2
feat(api): query actual exchange balance when creating trader
2025-11-05 15:45:09 +08:00
Icyoung 678392fab1 Merge pull request #325 from zhouyongyou/refactor/enhance-partial-close-guidance
refactor(prompts): 增強部分平倉使用指導 [依賴 #415]
2025-11-05 15:43:08 +08:00
Icyoung 2c122f0c5c Merge pull request #273 from zhouyongyou/feat/logger-dynamic-tpsl
feat(logger): 添加動態 TP/SL 日誌支持 [依賴 #415]
2025-11-05 15:42:33 +08:00
Icyoung af1fc4189a Merge pull request #415 from zhouyongyou/feat/partial-close-core-v2
feat: 部分平倉和動態止盈止損核心實現 / Partial Close & Dynamic TP/SL Core
2025-11-05 15:41:20 +08:00
tinkle-community 07be9065d5 Merge pull request #501 from Hansen1018/add-Hansen-prompt
增加 稳健和风险控制均衡基础策略提示词
2025-11-05 15:33:02 +08:00
tinkle-community 6910a25ae6 Merge pull request #500 from CoderMageFox/feature/aster-field-help-tooltips
feat: add help tooltips for Aster exchange configuration fields
2025-11-05 15:04:27 +08:00
tinkle-community 89b0f71ef6 Merge pull request #498 from tangmengqiu/dev_logs
feat(log): add logrus log lib and add telegram notification push as an option
2025-11-05 14:15:47 +08:00
CoderMageFox c7d7884d2b feat: add Aster API wallet links to help tooltips
Added direct links to Aster API wallet page in help tooltips for easier access.
Changes:
- Added English link: https://www.asterdex.com/en/api-wallet
- Added Chinese link: https://www.asterdex.com/zh-CN/api-wallet
- Updated asterSignerDesc with API wallet URL
- Updated asterPrivateKeyDesc with API wallet URL and security note
- Users can now directly access the API wallet page from tooltips
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 13:26:05 +08:00
CoderMageFox 6bc9a16f4c refactor: merge USDT warning into security warning box
Merged standalone USDT warning into existing security warning section for cleaner UI.
Changes:
- Removed separate red warning box for USDT
- Added USDT warning as first item in security warning box (conditional on Aster exchange)
- Now shows 4 warnings for Aster: USDT requirement + 3 general security warnings
- Cleaner, more organized warning presentation
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 13:19:39 +08:00
Hansen1018 deca0e5427 增加 稳健和风险控制均衡基础策略提示词
主要优化点:

强化风险控制框架 明确单笔风险≤2%,总风险≤6%
添加连续亏损后的仓位调整规则

设置单日和每周最大亏损限制

提高开仓标准 要求至少3个技术指标支持
必须有多时间框架趋势确认

入场时机要求更具体

完善决策流程 增加市场环境评估环节
明确风险回报比计算要求

添加资金保护检查点

细化行为准则 明确等待最佳机会的重要性
强调分批止盈和严格止损

添加情绪控制具体方法

增强绩效反馈机制 不同夏普比率区间的具体行动指南
亏损状态下的仓位控制要求

盈利状态下的纪律保持提醒

这个优化版本更加注重风险控制和稳健性,同时保持了交易的专业性和灵活性。
2025-11-05 13:19:07 +08:00
CoderMageFox 9349438e82 feat: add USDT warning for Aster exchange configuration
Added warning message to inform users that Aster only tracks USDT balance, preventing P&L calculation errors from asset price fluctuations.
Why this is important:
- Aster trader only tracks USDT balance (aster_trader.go:453)
- If users use BNB/ETH as margin, price fluctuations will cause:
  * Initial balance becomes inaccurate
  * P&L statistics will be wrong
  * Example: 10 BNB @ $100 = $1000, if BNB drops to $90, real equity is $900 but system still shows $1000
Changes:
- Added asterUsdtWarning translation in both EN and ZH
- Added red warning box below Aster private key field
- Clear message: "Please use USDT as margin currency"
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 13:15:49 +08:00
CoderMageFox 13dc0213f3 feat: add help tooltips for Aster exchange configuration fields
Added interactive help icons with tooltips for Aster exchange fields (user, signer, privateKey) to guide users through correct configuration.
Changes:
- Added HelpCircle icon from lucide-react
- Created reusable Tooltip component with hover/click interaction
- Added bilingual help descriptions in translations.ts
- User field: explains main wallet address (login address)
- Signer field: explains API wallet address generation
- Private Key field: clarifies local-only usage, never transmitted
This prevents user confusion and configuration errors when setting up Aster exchange.
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 13:03:41 +08:00
CoderMageFox 81e3d3cdb4 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统计不准确问题
- **改进**: 提升用户体验,减少配置错误
- **兼容**: 完全向后兼容,不影响现有功能
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 12:49:55 +08:00
tangmengqiu 9658785c6b log: add logrus log lib and add telegram notification push as an option 2025-11-04 23:48:32 -05:00
simon 97e8240b9d Enforce minimum scan interval of three minutes 2025-11-05 12:25:47 +08:00
SkywalkerJi 638238eb12 Merge pull request #489 from 0xEmberZz/feature/eslint&prettier
Feature/eslint&prettier
2025-11-05 13:01:29 +09:00
Ember b79878ab36 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 aaf1243f20 test: verify pre-commit hook formatting 2025-11-05 11:40:05 +08:00
Ember a89cd722c9 test: add eslint and prettier configuration with pre-commit hook 2025-11-05 11:40:05 +08:00
Ember d1f7ced7e1 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
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 11:40:05 +08:00
Shui 572bc3292d 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 8afbf0b891 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 bb6a1ac073 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 88dae4d87a fix conflict 2025-11-04 21:22:44 -05:00
SkywalkerJi 7fa8414d16 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 aecc875d09 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 e3a9219a4c 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 308f469b9c 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 f8edc0ec11 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 5efc9fc7c5 docs: config.example.jsonc替换成config.json.example 2025-11-05 09:24:38 +08:00
Shui 54f5637e34 Merge pull request #476 from hzb1115/dev
fix(workflow): simplify PR template
2025-11-04 20:18:35 -05:00
Shui 4ff618e424 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 97935a8e07 Fix PR tpl 2025-11-04 16:05:29 -05:00
zbhan caa42ec1a1 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
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-04 15:52:01 -05:00
ZhouYongyou 40ae31b583 fix(hyperliquid): complete balance detection with 4 critical fixes
## 🎯 完整修復 Hyperliquid 餘額檢測的所有問題
### 修復 1:  動態選擇保證金摘要
**問題**: 硬編碼使用 MarginSummary,但預設全倉模式
**修復**: 根據 isCrossMargin 動態選擇
- 全倉模式 → CrossMarginSummary
- 逐倉模式 → MarginSummary
### 修復 2:  查詢 Spot 現貨帳戶
**問題**: 只查詢 Perpetuals,忽略 Spot 餘額
**修復**: 使用 SpotUserState() 查詢 USDC 現貨餘額
- 合併 Spot + Perpetuals 總餘額
- 解決用戶反饋「錢包有錢但顯示 0」的問題
### 修復 3:  使用 Withdrawable 欄位
**問題**: 簡單計算 availableBalance = accountValue - totalMarginUsed 不可靠
**修復**: 優先使用官方 Withdrawable 欄位
- 整合 PR #443 的邏輯
- 降級方案:Withdrawable 不可用時才使用簡單計算
- 防止負數餘額
### 修復 4:  清理混亂註釋
**問題**: 註釋說 CrossMarginSummary 但代碼用 MarginSummary
**修復**: 根據實際使用的摘要類型動態輸出日誌
## 📊 修復對比
| 問題 | 修復前 | 修復後 |
|------|--------|--------|
| 保證金摘要選擇 |  硬編碼 MarginSummary |  動態選擇 |
| Spot 餘額查詢 |  從未查詢 |  完整查詢 |
| 可用餘額計算 |  簡單相減 |  使用 Withdrawable |
| 日誌註釋 |  不一致 |  準確清晰 |
## 🧪 測試場景
-  Spot 有錢,Perp 沒錢 → 正確顯示 Spot 餘額
-  Spot 沒錢,Perp 有錢 → 正確顯示 Perp 餘額
-  兩者都有錢 → 正確合併顯示
-  全倉模式 → 使用 CrossMarginSummary
-  逐倉模式 → 使用 MarginSummary
## 相關 Issue
解決用戶反饋:「錢包中有幣卻沒被檢測到」
整合以下未合併的修復:
- PR #443: Withdrawable 欄位優先
- Spot 餘額遺漏問題
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 03:59:44 +08:00