hedgequantx 2.9.106 → 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
|
@@ -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) => {
|
|
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 () => {
|
|
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
|
-
|
|
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
|
};
|
|
@@ -233,13 +233,15 @@ const oneAccountMenu = async (service) => {
|
|
|
233
233
|
const proceed = await prompts.confirmPrompt(startPrompt, true);
|
|
234
234
|
if (!proceed) return;
|
|
235
235
|
|
|
236
|
+
const startSpinner = ora({ text: 'Initializing algo trading...', color: 'cyan' }).start();
|
|
237
|
+
|
|
236
238
|
await executeAlgo({
|
|
237
239
|
service: accountService,
|
|
238
240
|
account: selectedAccount,
|
|
239
241
|
contract,
|
|
240
242
|
config,
|
|
241
243
|
strategy,
|
|
242
|
-
options: { supervisionConfig }
|
|
244
|
+
options: { supervisionConfig, startSpinner }
|
|
243
245
|
});
|
|
244
246
|
};
|
|
245
247
|
|