hedgequantx 1.2.135 → 1.2.137

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/bin/cli.js CHANGED
@@ -27,7 +27,8 @@ process.on('unhandledRejection', (err) => {
27
27
  program
28
28
  .name('hedgequantx')
29
29
  .description('Prop Futures Algo Trading CLI')
30
- .version(pkg.version);
30
+ .version(pkg.version)
31
+ .option('-u, --update', 'Update HQX to latest version');
31
32
 
32
33
  program
33
34
  .command('start', { isDefault: true })
@@ -44,5 +45,18 @@ program
44
45
  console.log(`HedgeQuantX CLI v${pkg.version}`);
45
46
  });
46
47
 
48
+ // Handle -u flag before parsing commands
49
+ if (process.argv.includes('-u') || process.argv.includes('--update')) {
50
+ const { execSync } = require('child_process');
51
+ console.log('Updating HedgeQuantX...');
52
+ try {
53
+ execSync('npm install -g hedgequantx@latest', { stdio: 'inherit' });
54
+ console.log('Update complete! Run "hqx" to start.');
55
+ } catch (e) {
56
+ console.error('Update failed:', e.message);
57
+ }
58
+ process.exit(0);
59
+ }
60
+
47
61
  // Parse and run
48
62
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "1.2.135",
3
+ "version": "1.2.137",
4
4
  "description": "Prop Futures Algo Trading CLI - Connect to Topstep, Alpha Futures, and other prop firms",
5
5
  "main": "src/app.js",
6
6
  "bin": {
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');