hedgequantx 1.2.135 → 1.2.136
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/app.js +35 -0
- package/src/pages/algo.js +10 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -26,6 +26,41 @@ const { algoTradingMenu } = require('./pages/algo');
|
|
|
26
26
|
let currentService = null;
|
|
27
27
|
let currentPlatform = null; // 'projectx' or 'rithmic'
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Global terminal restoration - ensures terminal is always restored on exit
|
|
31
|
+
*/
|
|
32
|
+
const restoreTerminal = () => {
|
|
33
|
+
try {
|
|
34
|
+
// Exit alternate screen buffer
|
|
35
|
+
process.stdout.write('\x1B[?1049l');
|
|
36
|
+
// Show cursor
|
|
37
|
+
process.stdout.write('\x1B[?25h');
|
|
38
|
+
// Disable raw mode
|
|
39
|
+
if (process.stdin.isTTY && process.stdin.isRaw) {
|
|
40
|
+
process.stdin.setRawMode(false);
|
|
41
|
+
}
|
|
42
|
+
// Remove all keypress listeners
|
|
43
|
+
process.stdin.removeAllListeners('keypress');
|
|
44
|
+
} catch (e) {
|
|
45
|
+
// Ignore errors during cleanup
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Register global handlers to restore terminal on exit/crash
|
|
50
|
+
process.on('exit', restoreTerminal);
|
|
51
|
+
process.on('SIGINT', () => { restoreTerminal(); process.exit(0); });
|
|
52
|
+
process.on('SIGTERM', () => { restoreTerminal(); process.exit(0); });
|
|
53
|
+
process.on('uncaughtException', (err) => {
|
|
54
|
+
restoreTerminal();
|
|
55
|
+
console.error(chalk.red('Uncaught Exception:'), err.message);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
58
|
+
process.on('unhandledRejection', (reason) => {
|
|
59
|
+
restoreTerminal();
|
|
60
|
+
console.error(chalk.red('Unhandled Rejection:'), reason);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
|
63
|
+
|
|
29
64
|
/**
|
|
30
65
|
* Displays the application banner with stats if connected
|
|
31
66
|
*/
|
package/src/pages/algo.js
CHANGED
|
@@ -2137,6 +2137,16 @@ const launchCopyTrading = async (config) => {
|
|
|
2137
2137
|
await closePositionsOnBothAccounts('user_stop');
|
|
2138
2138
|
}
|
|
2139
2139
|
|
|
2140
|
+
// Restore stdin to normal mode
|
|
2141
|
+
try {
|
|
2142
|
+
if (process.stdin.isTTY) {
|
|
2143
|
+
process.stdin.setRawMode(false);
|
|
2144
|
+
}
|
|
2145
|
+
process.stdin.removeAllListeners('keypress');
|
|
2146
|
+
} catch (e) {
|
|
2147
|
+
// Ignore stdin restoration errors
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2140
2150
|
// Exit alternate screen buffer and show cursor
|
|
2141
2151
|
process.stdout.write('\x1B[?1049l');
|
|
2142
2152
|
process.stdout.write('\x1B[?25h');
|