mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-11 14:56:57 +08:00
feat(nofxi): Phase 3 complete - Exchange factory, Web UI, Strategy runner, Docker
Exchange Factory: - CreateTrader() supports Binance/OKX/Bybit/Bitget/KuCoin/Gate - Auto-registers traders from config on startup - Direct import of nofx/trader packages (merged into main module) Web UI: - Dark theme chat interface at :8900 - Quick action sidebar (analyze, watch, positions, balance) - Real-time health check indicator - Mobile responsive Strategy Runner: - /strategy start BTC 1h - AI auto-analyzes on interval - /strategy stop <id> - stop strategy - /strategy list - view active strategies - Notifications pushed to Telegram on signals - Configurable intervals: 15m/30m/1h/4h Docker: - Multi-stage Dockerfile (alpine, ~20MB) - docker-compose.yml with volume persistence Bug fixes: - Fixed panic on empty exchanges config - Fixed thinking mode response parsing (qwen3 content:null) - Added request timeout (55s) in Telegram handler - Better error logging
This commit is contained in:
52
nofxi/internal/execution/factory.go
Normal file
52
nofxi/internal/execution/factory.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package execution
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"nofx/trader/binance"
|
||||
"nofx/trader/bitget"
|
||||
"nofx/trader/bybit"
|
||||
"nofx/trader/gate"
|
||||
"nofx/trader/kucoin"
|
||||
"nofx/trader/okx"
|
||||
)
|
||||
|
||||
// ExchangeConfig holds credentials for creating a trader.
|
||||
type ExchangeConfig struct {
|
||||
Name string
|
||||
APIKey string
|
||||
APISecret string
|
||||
Passphrase string
|
||||
Testnet bool
|
||||
}
|
||||
|
||||
// CreateTrader creates a NofxTrader for the given exchange.
|
||||
func CreateTrader(cfg ExchangeConfig) (NofxTrader, error) {
|
||||
switch strings.ToLower(cfg.Name) {
|
||||
case "binance":
|
||||
return binance.NewFuturesTrader(cfg.APIKey, cfg.APISecret, "nofxi"), nil
|
||||
|
||||
case "okx":
|
||||
return okx.NewOKXTrader(cfg.APIKey, cfg.APISecret, cfg.Passphrase), nil
|
||||
|
||||
case "bybit":
|
||||
return bybit.NewBybitTrader(cfg.APIKey, cfg.APISecret), nil
|
||||
|
||||
case "bitget":
|
||||
return bitget.NewBitgetTrader(cfg.APIKey, cfg.APISecret, cfg.Passphrase), nil
|
||||
|
||||
case "kucoin":
|
||||
return kucoin.NewKuCoinTrader(cfg.APIKey, cfg.APISecret, cfg.Passphrase), nil
|
||||
|
||||
case "gate":
|
||||
return gate.NewGateTrader(cfg.APIKey, cfg.APISecret), nil
|
||||
|
||||
// Hyperliquid needs private key, not API key/secret
|
||||
// case "hyperliquid":
|
||||
// return hyperliquid.NewHyperliquidTrader(cfg.APIKey, "", cfg.Testnet)
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported exchange: %s", cfg.Name)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user