mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-04 11:30:58 +08:00
Feat: Add configurable leverage settings for BTC/ETH and altcoins (v2.0.3)
- Add LeverageConfig struct with btc_eth_leverage and altcoin_leverage fields - Set default leverage to 5x (safe for Binance subaccounts) - Add validation warnings for leverage >5x (subaccount restrictions) - Update config.json.example with leverage configuration Breaking changes: - None (backward compatible with default 5x leverage) Migration: - Existing configs will auto-default to 5x leverage (safe) - Main accounts can increase to 20x (altcoins) or 50x (BTC/ETH) in config.json - Subaccounts must keep leverage ≤5x to avoid trade failures Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
"scan_interval_minutes": 3
|
||||
}
|
||||
],
|
||||
"leverage": {
|
||||
"btc_eth_leverage": 5,
|
||||
"altcoin_leverage": 5
|
||||
},
|
||||
"use_default_coins": true,
|
||||
"coin_pool_api_url": "",
|
||||
"oi_top_api_url": "",
|
||||
|
||||
@@ -20,6 +20,12 @@ type TraderConfig struct {
|
||||
ScanIntervalMinutes int `json:"scan_interval_minutes"`
|
||||
}
|
||||
|
||||
// LeverageConfig 杠杆配置
|
||||
type LeverageConfig struct {
|
||||
BTCETHLeverage int `json:"btc_eth_leverage"` // BTC和ETH的杠杆倍数(主账户建议5-50,子账户≤5)
|
||||
AltcoinLeverage int `json:"altcoin_leverage"` // 山寨币的杠杆倍数(主账户建议5-20,子账户≤5)
|
||||
}
|
||||
|
||||
// Config 总配置
|
||||
type Config struct {
|
||||
Traders []TraderConfig `json:"traders"`
|
||||
@@ -30,6 +36,7 @@ type Config struct {
|
||||
MaxDailyLoss float64 `json:"max_daily_loss"`
|
||||
MaxDrawdown float64 `json:"max_drawdown"`
|
||||
StopTradingMinutes int `json:"stop_trading_minutes"`
|
||||
Leverage LeverageConfig `json:"leverage"` // 杠杆配置
|
||||
}
|
||||
|
||||
// LoadConfig 从文件加载配置
|
||||
@@ -100,6 +107,20 @@ func (c *Config) Validate() error {
|
||||
c.APIServerPort = 8080 // 默认8080端口
|
||||
}
|
||||
|
||||
// 设置杠杆默认值(适配币安子账户限制,最大5倍)
|
||||
if c.Leverage.BTCETHLeverage <= 0 {
|
||||
c.Leverage.BTCETHLeverage = 5 // 默认5倍(安全值,适配子账户)
|
||||
}
|
||||
if c.Leverage.BTCETHLeverage > 5 {
|
||||
fmt.Printf("⚠️ 警告: BTC/ETH杠杆设置为%dx,如果使用子账户可能会失败(子账户限制≤5x)\n", c.Leverage.BTCETHLeverage)
|
||||
}
|
||||
if c.Leverage.AltcoinLeverage <= 0 {
|
||||
c.Leverage.AltcoinLeverage = 5 // 默认5倍(安全值,适配子账户)
|
||||
}
|
||||
if c.Leverage.AltcoinLeverage > 5 {
|
||||
fmt.Printf("⚠️ 警告: 山寨币杠杆设置为%dx,如果使用子账户可能会失败(子账户限制≤5x)\n", c.Leverage.AltcoinLeverage)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user