hedgequantx 2.9.166 → 2.9.168

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.9.166",
3
+ "version": "2.9.168",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -85,17 +85,23 @@ const fetchAllFrontMonths = (service) => {
85
85
 
86
86
  const tickerState = service.tickerConn.connectionState;
87
87
  const tickerConnected = service.tickerConn.isConnected;
88
- log.debug('fetchAllFrontMonths starting', { tickerState, tickerConnected });
88
+
89
+ // Direct console.log for daemon broker.log (always visible)
90
+ const brokerLog = (msg, data) => console.log(`[CONTRACTS] ${msg}`, JSON.stringify(data));
91
+
92
+ brokerLog('fetchAllFrontMonths starting', { tickerState, tickerConnected });
89
93
 
90
94
  return new Promise((resolve) => {
91
95
  const contracts = new Map();
92
96
  const productsToCheck = new Map();
93
97
  let msgCount = 0;
98
+ let productMsgCount = 0;
94
99
 
95
100
  // Handler for ProductCodes responses
96
101
  const productHandler = (msg) => {
97
102
  msgCount++;
98
103
  if (msg.templateId !== 112) return;
104
+ productMsgCount++;
99
105
 
100
106
  const decoded = decodeProductCodes(msg.data);
101
107
  if (!decoded.productCode || !decoded.exchange) return;
@@ -135,23 +141,28 @@ const fetchAllFrontMonths = (service) => {
135
141
  service.tickerConn.on('message', frontMonthHandler);
136
142
 
137
143
  // Request all product codes
138
- log.debug('Sending RequestProductCodes');
144
+ brokerLog('Sending RequestProductCodes', { templateId: 111 });
139
145
  try {
140
146
  service.tickerConn.send('RequestProductCodes', {
141
147
  templateId: 111,
142
148
  userMsg: ['get-products'],
143
149
  });
150
+ brokerLog('RequestProductCodes sent OK', {});
144
151
  } catch (err) {
145
- log.warn('Failed to send RequestProductCodes', { error: err.message });
152
+ brokerLog('FAILED to send RequestProductCodes', { error: err.message });
146
153
  }
147
154
 
148
155
  // After timeout, request front months
149
156
  setTimeout(() => {
150
157
  service.tickerConn.removeListener('message', productHandler);
151
- log.debug('Collected products', { count: productsToCheck.size, totalMsgs: msgCount });
158
+ brokerLog('ProductCodes phase complete', {
159
+ productsFound: productsToCheck.size,
160
+ totalMsgs: msgCount,
161
+ productMsgs: productMsgCount
162
+ });
152
163
 
153
164
  if (productsToCheck.size === 0) {
154
- log.warn('No products collected - TICKER may not be working');
165
+ brokerLog('WARNING: No products collected - TICKER may not be responding', {});
155
166
  }
156
167
 
157
168
  for (const product of productsToCheck.values()) {
@@ -163,7 +174,7 @@ const fetchAllFrontMonths = (service) => {
163
174
  exchange: product.exchange,
164
175
  });
165
176
  } catch (err) {
166
- log.warn('Failed to send RequestFrontMonthContract', { product: product.productCode, error: err.message });
177
+ brokerLog('Failed to send RequestFrontMonthContract', { product: product.productCode, error: err.message });
167
178
  }
168
179
  }
169
180
 
@@ -191,7 +202,7 @@ const fetchAllFrontMonths = (service) => {
191
202
  // Sort alphabetically by base symbol
192
203
  results.sort((a, b) => a.baseSymbol.localeCompare(b.baseSymbol));
193
204
 
194
- log.debug('Got contracts from API', { count: results.length, totalMsgs: msgCount });
205
+ brokerLog('FrontMonth phase complete', { contractsFound: results.length, totalMsgs: msgCount });
195
206
  resolve(results);
196
207
  }, TIMEOUTS.RITHMIC_PRODUCTS);
197
208
  }, TIMEOUTS.RITHMIC_CONTRACTS);
@@ -359,53 +359,12 @@ class RithmicBrokerDaemon {
359
359
  error: result.error
360
360
  });
361
361
 
362
- // If no contracts found, return fallback list for common futures
363
- if (!result.success || result.contracts?.length === 0) {
364
- log('WARN', 'Using fallback contracts list');
365
- const fallbackContracts = this._getFallbackContracts();
366
- return { type: 'contracts', payload: { success: true, contracts: fallbackContracts, source: 'fallback' }, requestId };
367
- }
368
-
369
362
  return { type: 'contracts', payload: result, requestId };
370
363
  } catch (err) {
371
364
  log('ERROR', 'getContracts exception', { propfirm: payload.propfirmKey, error: err.message, stack: err.stack?.split('\n')[1] });
372
- // Return fallback on error
373
- log('WARN', 'Using fallback contracts due to error');
374
- const fallbackContracts = this._getFallbackContracts();
375
- return { type: 'contracts', payload: { success: true, contracts: fallbackContracts, source: 'fallback' }, requestId };
365
+ return { type: 'contracts', payload: { success: false, error: err.message, contracts: [] }, requestId };
376
366
  }
377
367
  }
378
-
379
- /**
380
- * Get fallback contracts list when TICKER_PLANT fails
381
- * These are common futures that most prop firms support
382
- */
383
- _getFallbackContracts() {
384
- const now = new Date();
385
- const month = now.getMonth();
386
- const year = now.getFullYear();
387
-
388
- // Determine front month code (H=Mar, M=Jun, U=Sep, Z=Dec for indices)
389
- const monthCodes = ['H', 'H', 'H', 'M', 'M', 'M', 'U', 'U', 'U', 'Z', 'Z', 'Z'];
390
- const frontMonth = monthCodes[month];
391
- const yearCode = String(year).slice(-1);
392
- const suffix = frontMonth + yearCode;
393
-
394
- return [
395
- { symbol: `MNQ${suffix}`, baseSymbol: 'MNQ', name: 'Micro E-mini Nasdaq-100', exchange: 'CME', tickSize: 0.25 },
396
- { symbol: `MES${suffix}`, baseSymbol: 'MES', name: 'Micro E-mini S&P 500', exchange: 'CME', tickSize: 0.25 },
397
- { symbol: `NQ${suffix}`, baseSymbol: 'NQ', name: 'E-mini Nasdaq-100', exchange: 'CME', tickSize: 0.25 },
398
- { symbol: `ES${suffix}`, baseSymbol: 'ES', name: 'E-mini S&P 500', exchange: 'CME', tickSize: 0.25 },
399
- { symbol: `MCL${suffix}`, baseSymbol: 'MCL', name: 'Micro WTI Crude Oil', exchange: 'NYMEX', tickSize: 0.01 },
400
- { symbol: `MGC${suffix}`, baseSymbol: 'MGC', name: 'Micro Gold', exchange: 'COMEX', tickSize: 0.10 },
401
- { symbol: `M2K${suffix}`, baseSymbol: 'M2K', name: 'Micro E-mini Russell 2000', exchange: 'CME', tickSize: 0.10 },
402
- { symbol: `MYM${suffix}`, baseSymbol: 'MYM', name: 'Micro E-mini Dow', exchange: 'CBOT', tickSize: 0.50 },
403
- { symbol: `RTY${suffix}`, baseSymbol: 'RTY', name: 'E-mini Russell 2000', exchange: 'CME', tickSize: 0.10 },
404
- { symbol: `YM${suffix}`, baseSymbol: 'YM', name: 'E-mini Dow', exchange: 'CBOT', tickSize: 1.00 },
405
- { symbol: `CL${suffix}`, baseSymbol: 'CL', name: 'Crude Oil', exchange: 'NYMEX', tickSize: 0.01 },
406
- { symbol: `GC${suffix}`, baseSymbol: 'GC', name: 'Gold', exchange: 'COMEX', tickSize: 0.10 },
407
- ];
408
- }
409
368
 
410
369
  async _handleSearchContracts(payload, requestId) {
411
370
  const conn = this.connections.get(payload.propfirmKey);