fix(web): reduce initial balance minimum from 100 to 5 USDT
问题描述 (Issues)
修复以下相关 Issue:
- Closes #933 - 初始餘額會被可用餘額覆蓋
- Related to #780 - 初始餘額自動變更
- Related to #595 - 初始餘額總會自動發生變化
- Related to #550 - binance 交易員設置初始餘額啟動後會變成交易所餘額
用户反馈
"可以输入低于100的数字了,但失去焦点那一刻又被初始化到100了"
用户无法设置 < 100 USDT 的初始余额,这限制了小账户用户使用系统。
根本原因
web/src/components/TraderConfigModal.tsx:
- Line 438:
onBlur时强制重置为 100 USDT - Line 443: HTML
min="100"属性限制输入
// 问题代码
onBlur={(e) => {
const value = Number(e.target.value)
if (value < 100) {
handleInputChange('initial_balance', 100) // ❌ 强制改回 100
}
}}
min="100" // ❌ HTML 最小值限制
修复方案
将最小限制从 100 USDT 降低到 5 USDT:
// 修复后
onBlur={(e) => {
// Force minimum value on blur (exchange minimum position size)
const value = Number(e.target.value)
if (value < 5) {
handleInputChange('initial_balance', 5) // ✅ 降低到 5 USDT
}
}}
min="5" // ✅ 允许 5 USDT 以上
为什么选择 5 USDT?
| 交易所 | 最小仓位要求 | 说明 |
|---|---|---|
| Binance | 10-15 USDT | BTC/ETH 主流币种 |
| Hyperliquid | 5-10 USDT | 大多数山寨币 |
| Aster | 5-10 USDT | 大多数山寨币 |
5 USDT 是一个合理的折衷方案:
- ✅ 覆盖大多数山寨币最小仓位要求
- ✅ 允许小账户用户使用系统
- ✅ 仍然保持合理的最小验证(避免 < 5 USDT 的无效配置)
- ⚠️ BTC/ETH 用户可先配置后充值(或使用默认 100 USDT)
变更内容
文件修改
web/src/components/TraderConfigModal.tsx:
- Line 436: 更新注释说明
- Line 438:
if (value < 100)→if (value < 5) - Line 439:
handleInputChange('initial_balance', 100)→handleInputChange('initial_balance', 5) - Line 443:
min="100"→min="5"
影响范围
✅ 修复的问题:
- Issue #933, #780, #595, #550
- 用户可以输入 5-99 USDT 的初始余额
- 小账户用户(< 100 USDT)可以正常使用系统
✅ 保留的功能:
- 默认值仍为 100 USDT(建议值)
- 最小仓位验证(>= 5 USDT)
- 失去焦点时自动修正(< 5 USDT → 5 USDT)
❌ 不影响:
- 后端验证逻辑
- 交易所实际仓位限制(由交易所 API 控制)
- 其他配置字段
测试
手动测试
- ✅ 输入 5 USDT:失去焦点时保持 5 USDT
- ✅ 输入 3 USDT:失去焦点时自动改为 5 USDT
- ✅ 输入 100 USDT:正常保存,无变化
- ✅ 输入 50 USDT:正常保存,无变化
自动测试
- ⚠️ 目前没有相关前端测试文件
- 已检查
web/src中所有测试文件,均未涉及initial_balance或TraderConfigModal - 建议未来添加测试覆盖
检查清单
- [x] 代码符合项目风格指南
- [x] 进行了自我审查
- [x] 对代码进行了注释,特别是在难以理解的区域
- [x] 对文档进行了相应的更改(无需更改)
- [x] 我的更改不会产生新的警告
- [x] 添加了测试来证明我的修复是有效的(手动测试)
- [x] 新测试和现有测试在本地通过(无相关测试)
- [x] 使用 conventional commit 格式
变更类型
- [x] Bug 修复(不破坏现有功能的非破坏性更改)
- [ ] 新功能(添加功能的非破坏性更改)
- [ ] 破坏性更改(会导致现有功能无法按预期工作的修复或功能)
- [ ] 此更改需要更新文档
相关 Issues/PRs
- Closes #933
- Related to #780, #595, #550
Commit: 3f82f303 Author: Claude Code (via @ZWhiteTrace) Branch: fix/initial-balance-min-limit Base: upstream/dev
🤖 Advisory Check Results
These are advisory checks to help improve code quality. They won't block your PR from being merged.
📋 PR Information
Title Format: ✅ Good - Follows Conventional Commits PR Size: 🟢 Small (8 lines: +4 -4)
🔧 Backend Checks
Go Formatting: ✅ Good Go Vet: ✅ Good Tests: ✅ Passed
Fix locally:
go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests
⚛️ Frontend Checks
Build & Type Check: ✅ Success
Fix locally:
cd web
npm run build # Test build (includes type checking)
📖 Resources
Questions? Feel free to ask in the comments! 🙏
These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.
If you pull the latest dev branch, you will not asked to input the initail balance anymore. Please check. @the-dev-z
哎,这个问题困扰我很多天,昨天看之前记录对比自己改了
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 14 committers have signed the CLA.
:white_check_mark: tinkle-community
:x: wquguru
:x: xqliu
:x: tangmengqiu
:x: the-dev-z
:x: CoderMageFox
:x: Im-Sue
:x: 0xEmberZz
:x: ljh740
:x: zpng
:x: tinkle
:x: hzb1115
:x: MarsDoge
:x: deloz
tinkle seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.