NewStrategyEngine creates strategy execution engine. claw402WalletKey is optional — if provided, nofxos data requests are routed through claw402.
(config *store.StrategyConfig, claw402WalletKey ...string)
| 195 | // NewStrategyEngine creates strategy execution engine. |
| 196 | // claw402WalletKey is optional — if provided, nofxos data requests are routed through claw402. |
| 197 | func NewStrategyEngine(config *store.StrategyConfig, claw402WalletKey ...string) *StrategyEngine { |
| 198 | // Create NofxOS client with API key from config |
| 199 | apiKey := config.Indicators.NofxOSAPIKey |
| 200 | if apiKey == "" { |
| 201 | apiKey = nofxos.DefaultAuthKey |
| 202 | } |
| 203 | client := nofxos.NewClient(nofxos.DefaultBaseURL, apiKey) |
| 204 | |
| 205 | // If claw402 wallet key is provided (from trader's AI config), route through claw402 |
| 206 | walletKey := "" |
| 207 | if len(claw402WalletKey) > 0 { |
| 208 | walletKey = claw402WalletKey[0] |
| 209 | } |
| 210 | if walletKey == "" { |
| 211 | walletKey = os.Getenv("CLAW402_WALLET_KEY") |
| 212 | } |
| 213 | if walletKey != "" { |
| 214 | claw402URL := os.Getenv("CLAW402_URL") |
| 215 | if claw402URL == "" { |
| 216 | claw402URL = "https://claw402.ai" |
| 217 | } |
| 218 | claw402Client, err := nofxos.NewClaw402DataClient(claw402URL, walletKey, &logger.MCPLogger{}) |
| 219 | if err == nil { |
| 220 | client.SetClaw402(claw402Client) |
| 221 | logger.Infof("🔗 NofxOS data routed through claw402 (%s)", claw402URL) |
| 222 | } else { |
| 223 | logger.Warnf("⚠️ Failed to init claw402 data client: %v (using direct nofxos.ai)", err) |
| 224 | } |
| 225 | |
| 226 | vergexClient, err := vergex.NewClient(claw402URL, walletKey, &logger.MCPLogger{}) |
| 227 | if err == nil { |
| 228 | logger.Infof("🔗 Vergex signals routed through claw402 (%s)", claw402URL) |
| 229 | } else { |
| 230 | logger.Warnf("⚠️ Failed to init Vergex claw402 client: %v", err) |
| 231 | } |
| 232 | return &StrategyEngine{ |
| 233 | config: config, |
| 234 | nofxosClient: client, |
| 235 | vergexClient: vergexClient, |
| 236 | vergexRankingCache: make(map[string]*vergex.SignalRankItem), |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | return &StrategyEngine{ |
| 241 | config: config, |
| 242 | nofxosClient: client, |
| 243 | vergexRankingCache: make(map[string]*vergex.SignalRankItem), |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | func (e *StrategyEngine) usesHyperliquidNativeUniverse() bool { |
| 248 | if e == nil || e.config == nil { |