hedgequantx 1.2.96 → 1.2.98
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 +22 -12
package/package.json
CHANGED
package/src/pages/algo.js
CHANGED
|
@@ -454,16 +454,17 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
454
454
|
};
|
|
455
455
|
|
|
456
456
|
const getIcon = (type) => {
|
|
457
|
+
// Fixed width tags (10 chars) for alignment
|
|
457
458
|
switch(type) {
|
|
458
|
-
case 'signal':
|
|
459
|
-
case 'trade':
|
|
460
|
-
case 'order':
|
|
459
|
+
case 'signal': return '[SIGNAL] ';
|
|
460
|
+
case 'trade': return '[TRADE] ';
|
|
461
|
+
case 'order': return '[ORDER] ';
|
|
461
462
|
case 'position': return '[POSITION]';
|
|
462
|
-
case 'error':
|
|
463
|
-
case 'warning':
|
|
464
|
-
case 'success':
|
|
463
|
+
case 'error': return '[ERROR] ';
|
|
464
|
+
case 'warning': return '[WARNING] ';
|
|
465
|
+
case 'success': return '[OK] ';
|
|
465
466
|
case 'analysis': return '[ANALYSIS]';
|
|
466
|
-
default:
|
|
467
|
+
default: return '[INFO] ';
|
|
467
468
|
}
|
|
468
469
|
};
|
|
469
470
|
|
|
@@ -787,11 +788,14 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
787
788
|
|
|
788
789
|
hqxServer.on('disconnected', () => {
|
|
789
790
|
hqxConnected = false;
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
stopReason
|
|
794
|
-
|
|
791
|
+
// Only log error if not intentionally stopped by user
|
|
792
|
+
if (!stopReason || stopReason === 'user') {
|
|
793
|
+
// Don't show error for user-initiated stop
|
|
794
|
+
if (!stopReason) {
|
|
795
|
+
printLog('error', 'Connection lost - Stopping algo');
|
|
796
|
+
stopReason = 'disconnected';
|
|
797
|
+
algoRunning = false;
|
|
798
|
+
}
|
|
795
799
|
}
|
|
796
800
|
});
|
|
797
801
|
|
|
@@ -854,6 +858,7 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
854
858
|
if (!key) return;
|
|
855
859
|
const keyName = key.name?.toLowerCase();
|
|
856
860
|
if (keyName === 'x' || (key.ctrl && keyName === 'c')) {
|
|
861
|
+
stopReason = 'user'; // Set stop reason before cleanup
|
|
857
862
|
cleanup();
|
|
858
863
|
}
|
|
859
864
|
});
|
|
@@ -920,6 +925,9 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
920
925
|
hqxServer.disconnect();
|
|
921
926
|
algoRunning = false;
|
|
922
927
|
|
|
928
|
+
// Clear screen and show final result
|
|
929
|
+
console.clear();
|
|
930
|
+
|
|
923
931
|
console.log();
|
|
924
932
|
if (stopReason === 'target') {
|
|
925
933
|
console.log(chalk.green.bold(' [OK] Daily target reached! Algo stopped.'));
|
|
@@ -927,6 +935,8 @@ const launchAlgo = async (service, account, contract, numContracts, dailyTarget,
|
|
|
927
935
|
console.log(chalk.red.bold(' [X] Max risk reached! Algo stopped.'));
|
|
928
936
|
} else if (stopReason === 'disconnected' || stopReason === 'connection_error') {
|
|
929
937
|
console.log(chalk.red.bold(' [X] Connection lost! Algo stopped.'));
|
|
938
|
+
} else if (stopReason === 'user') {
|
|
939
|
+
console.log(chalk.yellow(' [OK] Algo stopped by user'));
|
|
930
940
|
} else {
|
|
931
941
|
console.log(chalk.yellow(' [OK] Algo stopped by user'));
|
|
932
942
|
}
|