hedgequantx 2.6.2 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -652,6 +652,30 @@ const copyTradingMenu = async () => {
|
|
|
652
652
|
]);
|
|
653
653
|
if (showNames === null) return;
|
|
654
654
|
|
|
655
|
+
// Step 7: AI Agents option
|
|
656
|
+
const aiAgents = aiService.getAgents();
|
|
657
|
+
let enableAI = false;
|
|
658
|
+
|
|
659
|
+
if (aiAgents.length > 0) {
|
|
660
|
+
console.log();
|
|
661
|
+
console.log(chalk.magenta(` ${aiAgents.length} AI AGENT(S) AVAILABLE:`));
|
|
662
|
+
aiAgents.forEach((agent, i) => {
|
|
663
|
+
const modelInfo = agent.model ? chalk.gray(` (${agent.model})`) : '';
|
|
664
|
+
console.log(chalk.white(` ${i + 1}. ${agent.name}${modelInfo}`));
|
|
665
|
+
});
|
|
666
|
+
console.log();
|
|
667
|
+
|
|
668
|
+
enableAI = await prompts.confirmPrompt('CONNECT AI AGENTS TO ALGO?', true);
|
|
669
|
+
if (enableAI === null) return;
|
|
670
|
+
|
|
671
|
+
if (enableAI) {
|
|
672
|
+
const mode = aiAgents.length >= 2 ? 'CONSENSUS' : 'INDIVIDUAL';
|
|
673
|
+
console.log(chalk.green(` AI MODE: ${mode} (${aiAgents.length} agent${aiAgents.length > 1 ? 's' : ''})`));
|
|
674
|
+
} else {
|
|
675
|
+
console.log(chalk.gray(' AI AGENTS DISABLED FOR THIS SESSION'));
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
655
679
|
// Summary
|
|
656
680
|
console.log();
|
|
657
681
|
console.log(chalk.white.bold(' ═══════════════════════════════════════'));
|
|
@@ -677,6 +701,7 @@ const copyTradingMenu = async () => {
|
|
|
677
701
|
dailyTarget,
|
|
678
702
|
maxRisk,
|
|
679
703
|
showNames,
|
|
704
|
+
enableAI,
|
|
680
705
|
});
|
|
681
706
|
};
|
|
682
707
|
|
|
@@ -810,7 +835,7 @@ const getContractsFromAPI = async () => {
|
|
|
810
835
|
* Launch Copy Trading session
|
|
811
836
|
*/
|
|
812
837
|
const launchCopyTrading = async (config) => {
|
|
813
|
-
const { lead, followers, dailyTarget, maxRisk, showNames } = config;
|
|
838
|
+
const { lead, followers, dailyTarget, maxRisk, showNames, enableAI } = config;
|
|
814
839
|
|
|
815
840
|
const leadName = showNames
|
|
816
841
|
? (lead.account.accountName || lead.account.accountId)
|
|
@@ -837,12 +862,14 @@ const launchCopyTrading = async (config) => {
|
|
|
837
862
|
aiMode: null
|
|
838
863
|
};
|
|
839
864
|
|
|
840
|
-
// Initialize AI Supervisor
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
865
|
+
// Initialize AI Supervisor - only if user enabled it
|
|
866
|
+
if (enableAI) {
|
|
867
|
+
const aiAgents = aiService.getAgents();
|
|
868
|
+
if (aiAgents.length > 0) {
|
|
869
|
+
const supervisorResult = StrategySupervisor.initialize(null, aiAgents, lead.service, lead.account.accountId);
|
|
870
|
+
stats.aiSupervision = supervisorResult.success;
|
|
871
|
+
stats.aiMode = supervisorResult.mode;
|
|
872
|
+
}
|
|
846
873
|
}
|
|
847
874
|
|
|
848
875
|
// Startup logs
|
|
@@ -162,6 +162,32 @@ const configureAlgo = async (account, contract) => {
|
|
|
162
162
|
const showName = await prompts.confirmPrompt('SHOW ACCOUNT NAME?', false);
|
|
163
163
|
if (showName === null) return null;
|
|
164
164
|
|
|
165
|
+
// Check if AI agents are available
|
|
166
|
+
const aiAgents = aiService.getAgents();
|
|
167
|
+
let enableAI = false;
|
|
168
|
+
|
|
169
|
+
if (aiAgents.length > 0) {
|
|
170
|
+
// Show available agents
|
|
171
|
+
console.log();
|
|
172
|
+
console.log(chalk.magenta(` ${aiAgents.length} AI AGENT(S) AVAILABLE:`));
|
|
173
|
+
aiAgents.forEach((agent, i) => {
|
|
174
|
+
const modelInfo = agent.model ? chalk.gray(` (${agent.model})`) : '';
|
|
175
|
+
console.log(chalk.white(` ${i + 1}. ${agent.name}${modelInfo}`));
|
|
176
|
+
});
|
|
177
|
+
console.log();
|
|
178
|
+
|
|
179
|
+
enableAI = await prompts.confirmPrompt('CONNECT AI AGENTS TO ALGO?', true);
|
|
180
|
+
if (enableAI === null) return null;
|
|
181
|
+
|
|
182
|
+
if (enableAI) {
|
|
183
|
+
const mode = aiAgents.length >= 2 ? 'CONSENSUS' : 'INDIVIDUAL';
|
|
184
|
+
console.log(chalk.green(` AI MODE: ${mode} (${aiAgents.length} agent${aiAgents.length > 1 ? 's' : ''})`));
|
|
185
|
+
} else {
|
|
186
|
+
console.log(chalk.gray(' AI AGENTS DISABLED FOR THIS SESSION'));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
console.log();
|
|
165
191
|
const confirm = await prompts.confirmPrompt('START ALGO TRADING?', true);
|
|
166
192
|
if (!confirm) return null;
|
|
167
193
|
|
|
@@ -170,7 +196,7 @@ const configureAlgo = async (account, contract) => {
|
|
|
170
196
|
await new Promise(r => setTimeout(r, 500));
|
|
171
197
|
initSpinner.succeed('LAUNCHING ALGO...');
|
|
172
198
|
|
|
173
|
-
return { contracts, dailyTarget, maxRisk, showName };
|
|
199
|
+
return { contracts, dailyTarget, maxRisk, showName, enableAI };
|
|
174
200
|
};
|
|
175
201
|
|
|
176
202
|
/**
|
|
@@ -317,11 +343,14 @@ const launchAlgo = async (service, account, contract, config) => {
|
|
|
317
343
|
}
|
|
318
344
|
|
|
319
345
|
// Initialize AI Strategy Supervisor - agents observe, learn & optimize
|
|
320
|
-
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
346
|
+
// Only if user enabled AI in config
|
|
347
|
+
if (config.enableAI) {
|
|
348
|
+
const aiAgents = aiService.getAgents();
|
|
349
|
+
if (aiAgents.length > 0) {
|
|
350
|
+
const supervisorResult = StrategySupervisor.initialize(strategy, aiAgents, service, account.accountId);
|
|
351
|
+
stats.aiSupervision = supervisorResult.success;
|
|
352
|
+
stats.aiMode = supervisorResult.mode;
|
|
353
|
+
}
|
|
325
354
|
}
|
|
326
355
|
|
|
327
356
|
// Initialize Market Data Feed
|
package/src/services/ai/index.js
CHANGED
|
@@ -68,6 +68,7 @@ const generateAgentId = () => {
|
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Get all connected agents
|
|
71
|
+
* IMPORTANT: Includes credentials for API calls in StrategySupervisor
|
|
71
72
|
*/
|
|
72
73
|
const getAgents = () => {
|
|
73
74
|
const aiSettings = getAISettings();
|
|
@@ -82,6 +83,7 @@ const getAgents = () => {
|
|
|
82
83
|
providerId: agent.provider,
|
|
83
84
|
option: agent.option,
|
|
84
85
|
model: agent.model || provider?.defaultModel,
|
|
86
|
+
credentials: agent.credentials, // CRITICAL: Required for API calls
|
|
85
87
|
createdAt: agent.createdAt,
|
|
86
88
|
isActive: agent.id === aiSettings.activeAgentId
|
|
87
89
|
};
|