hedgequantx 2.6.151 → 2.6.152

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.6.151",
3
+ "version": "2.6.152",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -19,6 +19,7 @@ const readline = require('readline');
19
19
 
20
20
  const { connections } = require('../../services');
21
21
  const { AlgoUI, renderSessionSummary, renderMultiSymbolSummary } = require('./ui');
22
+ const { displayBanner } = require('../../ui');
22
23
  const { prompts } = require('../../utils');
23
24
  const { checkMarketHours } = require('../../services/projectx/market');
24
25
  const { FAST_SCALPING } = require('../../config/settings');
@@ -28,6 +29,7 @@ const { algoLogger } = require('./logger');
28
29
  const { recoveryMath } = require('../../services/strategy/recovery-math');
29
30
  const aiService = require('../../services/ai');
30
31
  const { launchMultiSymbolRithmic } = require('./one-account');
32
+ const aiClient = require('../../services/ai/client');
31
33
 
32
34
  // Strategy template that the AI will fill
33
35
  const STRATEGY_TEMPLATE = `/**
@@ -127,16 +129,21 @@ function getStrategyDir() {
127
129
  * Generate strategy code using AI agent
128
130
  */
129
131
  async function generateStrategyCode(description, agentName) {
130
- const agent = aiService.getAgents().find(a => a.name === agentName || a.provider === agentName);
132
+ const agents = aiService.getAgents();
133
+ const agent = agents.find(a => a.name === agentName || a.provider === agentName);
131
134
  if (!agent) {
132
135
  return { success: false, error: 'No AI agent available' };
133
136
  }
134
137
 
135
- const prompt = `You are a trading strategy code generator. Generate a trading strategy based on this description:
138
+ const systemPrompt = `You are a trading strategy code generator for HQX-CLI.
139
+ Generate trading strategies based on user descriptions.
140
+ You must output ONLY valid JSON with the strategy components, no markdown, no explanation.`;
141
+
142
+ const prompt = `Generate a trading strategy based on this description:
136
143
 
137
144
  "${description}"
138
145
 
139
- You must output ONLY valid JavaScript code that fills in these template sections:
146
+ Fill in these template sections:
140
147
 
141
148
  1. STRATEGY_NAME: A short name for the strategy (string)
142
149
  2. STRATEGY_DESCRIPTION: One line description (string)
@@ -153,7 +160,7 @@ Available in processTick:
153
160
  - this.tickSize, this.tickValue (contract specs)
154
161
  - this.tickCount (number of ticks processed)
155
162
 
156
- Output format (JSON):
163
+ Output format (JSON only):
157
164
  {
158
165
  "STRATEGY_NAME": "...",
159
166
  "STRATEGY_DESCRIPTION": "...",
@@ -161,29 +168,26 @@ Output format (JSON):
161
168
  "STRATEGY_LOGIC": "...",
162
169
  "STRATEGY_GET_STATE": "...",
163
170
  "STRATEGY_RESET": "..."
164
- }
165
-
166
- IMPORTANT: Output ONLY the JSON, no markdown, no explanation.`;
171
+ }`;
167
172
 
168
173
  try {
169
- const response = await aiService.chat(agentName, [
170
- { role: 'user', content: prompt }
171
- ]);
174
+ // Use aiClient.callAI which handles all providers correctly
175
+ const response = await aiClient.callAI(agent, prompt, systemPrompt);
172
176
 
173
- if (!response.success) {
174
- return { success: false, error: response.error || 'AI request failed' };
177
+ if (!response) {
178
+ return { success: false, error: 'AI request failed - no response' };
175
179
  }
176
180
 
177
181
  // Parse JSON response
178
182
  let strategyParts;
179
183
  try {
180
184
  // Extract JSON from response (might have markdown)
181
- let jsonStr = response.content || response.message || '';
182
- const jsonMatch = jsonStr.match(/\{[\s\S]*\}/);
185
+ const jsonMatch = response.match(/\{[\s\S]*\}/);
183
186
  if (jsonMatch) {
184
- jsonStr = jsonMatch[0];
187
+ strategyParts = JSON.parse(jsonMatch[0]);
188
+ } else {
189
+ return { success: false, error: 'AI response did not contain valid JSON' };
185
190
  }
186
- strategyParts = JSON.parse(jsonStr);
187
191
  } catch (parseError) {
188
192
  return { success: false, error: `Failed to parse AI response: ${parseError.message}` };
189
193
  }
@@ -288,6 +292,7 @@ async function validateStrategyCode(code, filepath) {
288
292
  */
289
293
  const customStrategyMenu = async (service) => {
290
294
  console.clear();
295
+ displayBanner();
291
296
 
292
297
  // Check if AI agent is connected
293
298
  const agents = aiService.getAgents();