mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-12 15:26:55 +08:00
feat: Add Hyperliquid exchange support with unified trader interface
Major changes: - Add full Hyperliquid trading support (long/short, leverage, SL/TP) - Create unified Trader interface for multi-exchange support - Implement automatic precision handling for orders and prices - Fix balance calculation and unrealized P&L display - Add comprehensive configuration guide in README New features: - Support for both Binance and Hyperliquid exchanges - Automatic order size precision based on szDecimals - Price formatting with 5 significant figures - Non-custodial trading with Ethereum private key - Seamless exchange switching via configuration Technical details: - Add trader/interface.go for unified trader interface - Add trader/hyperliquid_trader.go for Hyperliquid implementation - Update manager and auto_trader to support multiple exchanges - Add go-hyperliquid SDK dependency - Fix precision errors (float_to_wire, invalid price) Fixes: - Correct calculation of wallet balance and unrealized P&L - Proper handling of AccountValue vs TotalRawUsd - Frontend display issues for total equity and P&L Documentation: - Add Hyperliquid setup guide in README - Update config.json.example with both exchanges - Add troubleshooting section for common errors Tested with live trading on Hyperliquid mainnet. No breaking changes - backward compatible with existing configs.
This commit is contained in:
@@ -33,20 +33,23 @@ func (tm *TraderManager) AddTrader(cfg config.TraderConfig, coinPoolURL string,
|
||||
|
||||
// 构建AutoTraderConfig
|
||||
traderConfig := trader.AutoTraderConfig{
|
||||
ID: cfg.ID,
|
||||
Name: cfg.Name,
|
||||
AIModel: cfg.AIModel,
|
||||
BinanceAPIKey: cfg.BinanceAPIKey,
|
||||
BinanceSecretKey: cfg.BinanceSecretKey,
|
||||
CoinPoolAPIURL: coinPoolURL,
|
||||
UseQwen: cfg.AIModel == "qwen",
|
||||
DeepSeekKey: cfg.DeepSeekKey,
|
||||
QwenKey: cfg.QwenKey,
|
||||
ScanInterval: cfg.GetScanInterval(),
|
||||
InitialBalance: cfg.InitialBalance,
|
||||
MaxDailyLoss: maxDailyLoss,
|
||||
MaxDrawdown: maxDrawdown,
|
||||
StopTradingTime: time.Duration(stopTradingMinutes) * time.Minute,
|
||||
ID: cfg.ID,
|
||||
Name: cfg.Name,
|
||||
AIModel: cfg.AIModel,
|
||||
Exchange: cfg.Exchange,
|
||||
BinanceAPIKey: cfg.BinanceAPIKey,
|
||||
BinanceSecretKey: cfg.BinanceSecretKey,
|
||||
HyperliquidPrivateKey: cfg.HyperliquidPrivateKey,
|
||||
HyperliquidTestnet: cfg.HyperliquidTestnet,
|
||||
CoinPoolAPIURL: coinPoolURL,
|
||||
UseQwen: cfg.AIModel == "qwen",
|
||||
DeepSeekKey: cfg.DeepSeekKey,
|
||||
QwenKey: cfg.QwenKey,
|
||||
ScanInterval: cfg.GetScanInterval(),
|
||||
InitialBalance: cfg.InitialBalance,
|
||||
MaxDailyLoss: maxDailyLoss,
|
||||
MaxDrawdown: maxDrawdown,
|
||||
StopTradingTime: time.Duration(stopTradingMinutes) * time.Minute,
|
||||
}
|
||||
|
||||
// 创建trader实例
|
||||
|
||||
Reference in New Issue
Block a user