hedgequantx 2.9.107 → 2.9.109
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
|
};
|
|
@@ -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
|
|
package/src/pages/algo/ui.js
CHANGED
|
@@ -289,10 +289,8 @@ class AlgoUI {
|
|
|
289
289
|
const { W, logs, maxLogs } = this;
|
|
290
290
|
|
|
291
291
|
// Activity header - HF style with animated spinner
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const elapsed = Date.now() - this.startTime;
|
|
295
|
-
this.spinnerFrame = Math.floor(elapsed / 100) % SPINNER.length;
|
|
292
|
+
// Increment spinner frame each render (250ms interval = visible rotation)
|
|
293
|
+
this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER.length;
|
|
296
294
|
const spinner = SPINNER[this.spinnerFrame];
|
|
297
295
|
const now = new Date();
|
|
298
296
|
const timeStr = now.toLocaleTimeString('en-US', { hour12: false });
|