mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-13 15:57:01 +08:00
Feat: Integrate leverage configuration across trading system
- Pass leverage config through TraderManager to AutoTrader - Add BTCETHLeverage and AltcoinLeverage fields to Context and AutoTraderConfig - Update decision validation to use configured leverage limits - Display configured leverage in startup message - Update error messages to show current leverage limits Changes: - main.go: Pass leverage config to AddTrader, update startup message - manager/trader_manager.go: Accept and forward leverage config - trader/auto_trader.go: Store leverage config, pass to Context - decision/engine.go: Use dynamic leverage limits in validation This completes the leverage configuration feature implementation. Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
@@ -36,6 +36,10 @@ type AutoTraderConfig struct {
|
||||
// 账户配置
|
||||
InitialBalance float64 // 初始金额(用于计算盈亏,需手动设置)
|
||||
|
||||
// 杠杆配置
|
||||
BTCETHLeverage int // BTC和ETH的杠杆倍数
|
||||
AltcoinLeverage int // 山寨币的杠杆倍数
|
||||
|
||||
// 风险控制(仅作为提示,AI可自主决定)
|
||||
MaxDailyLoss float64 // 最大日亏损百分比(提示)
|
||||
MaxDrawdown float64 // 最大回撤百分比(提示)
|
||||
@@ -459,9 +463,11 @@ func (at *AutoTrader) buildTradingContext() (*decision.Context, error) {
|
||||
|
||||
// 6. 构建上下文
|
||||
ctx := &decision.Context{
|
||||
CurrentTime: time.Now().Format("2006-01-02 15:04:05"),
|
||||
RuntimeMinutes: int(time.Since(at.startTime).Minutes()),
|
||||
CallCount: at.callCount,
|
||||
CurrentTime: time.Now().Format("2006-01-02 15:04:05"),
|
||||
RuntimeMinutes: int(time.Since(at.startTime).Minutes()),
|
||||
CallCount: at.callCount,
|
||||
BTCETHLeverage: at.config.BTCETHLeverage, // 使用配置的杠杆倍数
|
||||
AltcoinLeverage: at.config.AltcoinLeverage, // 使用配置的杠杆倍数
|
||||
Account: decision.AccountInfo{
|
||||
TotalEquity: totalEquity,
|
||||
AvailableBalance: availableBalance,
|
||||
|
||||
Reference in New Issue
Block a user