hedgequantx 1.2.113 → 1.2.115
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 +1 -1
- package/src/pages/algo.js +57 -64
package/package.json
CHANGED
package/src/pages/algo.js
CHANGED
|
@@ -178,29 +178,31 @@ const selectSymbolMenu = async (service, account) => {
|
|
|
178
178
|
const result = await service.searchContracts(search, false);
|
|
179
179
|
if (result.success && result.contracts && result.contracts.length > 0) {
|
|
180
180
|
for (const contract of result.contracts) {
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
181
|
+
// ProjectX API returns:
|
|
182
|
+
// id: "CON.F.US.ENQ.H26" (contract ID)
|
|
183
|
+
// name: "NQH6" (short symbol with month/year)
|
|
184
|
+
// description: "E-mini NASDAQ-100: March 2026"
|
|
185
|
+
|
|
186
|
+
const contractId = contract.id || contract.contractId;
|
|
187
|
+
if (!contractId) continue;
|
|
188
|
+
|
|
189
|
+
const existing = availableSymbols.find(s => s.id === contractId);
|
|
190
|
+
if (existing) continue;
|
|
191
|
+
|
|
192
|
+
// Use 'name' field which contains the symbol code like "NQH6", "ESH6", "MNQH6"
|
|
193
|
+
const symbolCode = contract.name || contract.symbol || '';
|
|
194
|
+
if (!symbolCode) continue;
|
|
195
|
+
|
|
196
|
+
availableSymbols.push({
|
|
197
|
+
id: contractId,
|
|
198
|
+
name: symbolCode,
|
|
199
|
+
symbol: symbolCode,
|
|
200
|
+
description: contract.description || '',
|
|
201
|
+
tickSize: contract.tickSize,
|
|
202
|
+
tickValue: contract.tickValue,
|
|
203
|
+
exchange: contract.exchange || 'CME',
|
|
204
|
+
activeContract: contract.activeContract || false
|
|
205
|
+
});
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
}
|
|
@@ -208,22 +210,6 @@ const selectSymbolMenu = async (service, account) => {
|
|
|
208
210
|
// Fallback to static list
|
|
209
211
|
}
|
|
210
212
|
|
|
211
|
-
// Add micro contracts if not found from API
|
|
212
|
-
const microContracts = [
|
|
213
|
-
{ symbol: 'MNQ', name: 'Micro E-mini NASDAQ-100' },
|
|
214
|
-
{ symbol: 'MES', name: 'Micro E-mini S&P 500' },
|
|
215
|
-
{ symbol: 'MYM', name: 'Micro E-mini Dow Jones' },
|
|
216
|
-
{ symbol: 'M2K', name: 'Micro E-mini Russell 2000' },
|
|
217
|
-
{ symbol: 'MCL', name: 'Micro Crude Oil' },
|
|
218
|
-
{ symbol: 'MGC', name: 'Micro Gold' }
|
|
219
|
-
];
|
|
220
|
-
|
|
221
|
-
// Get current month code for front month
|
|
222
|
-
const now = new Date();
|
|
223
|
-
const monthCodes = ['F', 'G', 'H', 'J', 'K', 'M', 'N', 'Q', 'U', 'V', 'X', 'Z'];
|
|
224
|
-
const currentMonthCode = monthCodes[now.getMonth()];
|
|
225
|
-
const yearCode = (now.getFullYear() % 100).toString();
|
|
226
|
-
|
|
227
213
|
for (const micro of microContracts) {
|
|
228
214
|
const hasMicro = availableSymbols.some(s =>
|
|
229
215
|
(s.symbol && s.symbol.toUpperCase().startsWith(micro.symbol)) ||
|
|
@@ -294,42 +280,49 @@ const selectSymbolMenu = async (service, account) => {
|
|
|
294
280
|
'ZW': 'Wheat'
|
|
295
281
|
};
|
|
296
282
|
|
|
297
|
-
// Format symbols for display -
|
|
298
|
-
const
|
|
283
|
+
// Format symbols for display - show ALL contracts from API
|
|
284
|
+
const seenIds = new Set();
|
|
299
285
|
const symbolChoices = [];
|
|
300
286
|
|
|
301
|
-
for (const
|
|
302
|
-
|
|
287
|
+
for (const contract of availableSymbols) {
|
|
288
|
+
// Skip duplicates by contract ID
|
|
289
|
+
const contractId = contract.id || '';
|
|
290
|
+
if (seenIds.has(contractId)) continue;
|
|
291
|
+
seenIds.add(contractId);
|
|
303
292
|
|
|
304
|
-
//
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
let monthYear = '';
|
|
293
|
+
// Get the symbol code - API returns 'name' field with code like "NQH6"
|
|
294
|
+
const symbolCode = contract.name || contract.symbol || '';
|
|
295
|
+
if (!symbolCode) continue;
|
|
308
296
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
monthYear = (monthCodes[monthCode] || monthCode) + year;
|
|
297
|
+
// Get description from API or our mapping
|
|
298
|
+
let description = '';
|
|
299
|
+
if (contract.description) {
|
|
300
|
+
// API format: "E-mini NASDAQ-100: March 2026" -> extract instrument name
|
|
301
|
+
description = contract.description.split(':')[0].trim();
|
|
315
302
|
}
|
|
316
303
|
|
|
317
|
-
//
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
304
|
+
// Fallback to our symbol descriptions
|
|
305
|
+
if (!description) {
|
|
306
|
+
// Extract base symbol (NQ from NQH6)
|
|
307
|
+
const baseMatch = symbolCode.match(/^([A-Z0-9]{1,4})[FGHJKMNQUVXZ]\d{1,2}$/i);
|
|
308
|
+
const baseSymbol = baseMatch ? baseMatch[1] : symbolCode;
|
|
309
|
+
description = symbolDescriptions[baseSymbol] || symbolCode;
|
|
310
|
+
}
|
|
324
311
|
|
|
325
|
-
// Format: "
|
|
326
|
-
const symbolDisplay = monthYear ? `${baseSymbol}.${monthYear}` : baseSymbol;
|
|
312
|
+
// Format: "NQH6 E-mini NASDAQ-100"
|
|
327
313
|
symbolChoices.push({
|
|
328
|
-
name: chalk.yellow(
|
|
329
|
-
value:
|
|
314
|
+
name: chalk.yellow(symbolCode.padEnd(12)) + chalk.white(description),
|
|
315
|
+
value: contract
|
|
330
316
|
});
|
|
331
317
|
}
|
|
332
318
|
|
|
319
|
+
// Sort by symbol code for better organization
|
|
320
|
+
symbolChoices.sort((a, b) => {
|
|
321
|
+
const aCode = a.value.name || a.value.symbol || '';
|
|
322
|
+
const bCode = b.value.name || b.value.symbol || '';
|
|
323
|
+
return aCode.localeCompare(bCode);
|
|
324
|
+
});
|
|
325
|
+
|
|
333
326
|
symbolChoices.push(new inquirer.Separator());
|
|
334
327
|
symbolChoices.push({ name: chalk.yellow('< Back'), value: 'back' });
|
|
335
328
|
|