hedgequantx 2.9.107 → 2.9.108

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.107",
3
+ "version": "2.9.108",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -20,7 +20,7 @@ const smartLogs = require('../../lib/smart-logs');
20
20
  */
21
21
  const executeAlgo = async ({ service, account, contract, config, strategy: strategyInfo, options = {} }) => {
22
22
  const { contracts, dailyTarget, maxRisk, showName } = config;
23
- const { supervisionConfig, subtitle } = options;
23
+ const { supervisionConfig, subtitle, startSpinner } = options;
24
24
 
25
25
  const strategyId = strategyInfo?.id || 'ultra-scalping';
26
26
  const strategyName = strategyInfo?.name || 'HQX Scalping';
@@ -83,6 +83,9 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
83
83
 
84
84
  const marketFeed = new MarketDataFeed();
85
85
 
86
+ // Stop the initialization spinner before UI takes over
87
+ if (startSpinner) startSpinner.succeed('Algo initialized');
88
+
86
89
  ui.addLog('system', `Strategy: ${strategyName}${supervisionEnabled ? ' + AI' : ''}`);
87
90
  ui.addLog('system', `Account: ${accountName}`);
88
91
  ui.addLog('system', `Symbol: ${symbolName} | Qty: ${contracts}`);
@@ -471,13 +474,23 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
471
474
  pollPnL();
472
475
 
473
476
  const setupKeyHandler = () => {
474
- if (!process.stdin.isTTY) return;
477
+ if (!process.stdin.isTTY) return null;
475
478
  readline.emitKeypressEvents(process.stdin);
476
479
  process.stdin.setRawMode(true);
477
480
  process.stdin.resume();
478
- const onKey = (str, key) => { if (key && (key.name === 'x' || key.name === 'X' || (key.ctrl && key.name === 'c'))) { running = false; stopReason = 'manual'; } };
481
+ const onKey = (str, key) => {
482
+ // Handle 'x', 'X', or Ctrl+C to stop
483
+ const keyName = key?.name?.toLowerCase();
484
+ if (keyName === 'x' || (key?.ctrl && keyName === 'c')) {
485
+ running = false;
486
+ stopReason = 'manual';
487
+ }
488
+ };
479
489
  process.stdin.on('keypress', onKey);
480
- return () => { process.stdin.removeListener('keypress', onKey); if (process.stdin.isTTY) process.stdin.setRawMode(false); };
490
+ return () => {
491
+ process.stdin.removeListener('keypress', onKey);
492
+ if (process.stdin.isTTY) process.stdin.setRawMode(false);
493
+ };
481
494
  };
482
495
  const cleanupKeys = setupKeyHandler();
483
496
 
@@ -496,7 +509,6 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
496
509
  stats.duration = h > 0 ? `${h}h ${m}m ${s}s` : m > 0 ? `${m}m ${s}s` : `${s}s`;
497
510
  renderSessionSummary(stats, stopReason);
498
511
 
499
- const readline = require('readline');
500
512
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
501
513
  await new Promise(resolve => {
502
514
  rl.question('\n Press Enter to return to menu...', () => {
@@ -329,7 +329,9 @@ const setupKeyHandler = (onStop) => {
329
329
  process.stdin.resume();
330
330
 
331
331
  const onKey = (str, key) => {
332
- if (key && (key.name === 'x' || key.name === 'X' || (key.ctrl && key.name === 'c'))) {
332
+ // Handle 'x', 'X', or Ctrl+C to stop
333
+ const keyName = key?.name?.toLowerCase();
334
+ if (keyName === 'x' || (key?.ctrl && keyName === 'c')) {
333
335
  onStop();
334
336
  }
335
337
  };
@@ -235,17 +235,13 @@ const oneAccountMenu = async (service) => {
235
235
 
236
236
  const startSpinner = ora({ text: 'Initializing algo trading...', color: 'cyan' }).start();
237
237
 
238
- // Small delay to show spinner then stop before executeAlgo takes over the screen
239
- await new Promise(resolve => setTimeout(resolve, 500));
240
- startSpinner.succeed('Algo initialized');
241
-
242
238
  await executeAlgo({
243
239
  service: accountService,
244
240
  account: selectedAccount,
245
241
  contract,
246
242
  config,
247
243
  strategy,
248
- options: { supervisionConfig }
244
+ options: { supervisionConfig, startSpinner }
249
245
  });
250
246
  };
251
247