hedgequantx 2.9.8 → 2.9.10

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.9.8",
3
+ "version": "2.9.10",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
package/src/app.js CHANGED
@@ -7,7 +7,7 @@ const chalk = require('chalk');
7
7
  const ora = require('ora');
8
8
 
9
9
  const { connections } = require('./services');
10
- const { getLogoWidth, centerText, prepareStdin } = require('./ui');
10
+ const { getLogoWidth, centerText, prepareStdin, clearScreen } = require('./ui');
11
11
  const { logger, prompts } = require('./utils');
12
12
  const { setCachedStats, clearCachedStats } = require('./services/stats-cache');
13
13
 
@@ -30,7 +30,7 @@ let currentService = null;
30
30
 
31
31
  const restoreTerminal = () => {
32
32
  try {
33
- process.stdout.write('\x1B[?1049l');
33
+ // Show cursor
34
34
  process.stdout.write('\x1B[?25h');
35
35
  if (process.stdin.isTTY && process.stdin.isRaw) {
36
36
  process.stdin.setRawMode(false);
@@ -110,7 +110,7 @@ const refreshStats = async () => {
110
110
  // ==================== BANNER ====================
111
111
 
112
112
  const banner = async () => {
113
- console.clear();
113
+ clearScreen();
114
114
 
115
115
  const termWidth = process.stdout.columns || 100;
116
116
  const isMobile = termWidth < 60;
@@ -8,7 +8,7 @@ const ora = require('ora');
8
8
  const { connections } = require('../services');
9
9
  const { RithmicService } = require('../services/rithmic');
10
10
  const { PROPFIRM_CHOICES } = require('../config');
11
- const { getLogoWidth, centerText, prepareStdin, displayBanner } = require('../ui');
11
+ const { getLogoWidth, centerText, prepareStdin, displayBanner , clearScreen } = require('../ui');
12
12
  const { validateUsername, validatePassword } = require('../security');
13
13
  const { prompts } = require('../utils');
14
14
 
@@ -39,7 +39,7 @@ const loginPrompt = async (propfirmName) => {
39
39
  */
40
40
  const rithmicMenu = async () => {
41
41
  // Clear screen and show banner
42
- console.clear();
42
+ clearScreen();
43
43
  displayBanner();
44
44
 
45
45
  const propfirms = PROPFIRM_CHOICES;
@@ -7,7 +7,7 @@ const ora = require('ora');
7
7
  const { execSync, spawn } = require('child_process');
8
8
 
9
9
  const { connections } = require('../services');
10
- const { getLogoWidth, centerText, prepareStdin, displayBanner } = require('../ui');
10
+ const { getLogoWidth, centerText, prepareStdin, displayBanner, clearScreen } = require('../ui');
11
11
  const { getCachedStats } = require('../services/stats-cache');
12
12
  const { prompts } = require('../utils');
13
13
 
@@ -24,7 +24,7 @@ const dashboardMenu = async (service) => {
24
24
  }
25
25
 
26
26
  // Clear screen and show banner (always closed)
27
- console.clear();
27
+ clearScreen();
28
28
  displayBanner();
29
29
 
30
30
  const boxWidth = getLogoWidth();
@@ -159,7 +159,7 @@ const dashboardMenu = async (service) => {
159
159
  * Handle update process
160
160
  */
161
161
  const handleUpdate = async () => {
162
- console.clear();
162
+ clearScreen();
163
163
  displayBanner();
164
164
  prepareStdin();
165
165
 
@@ -7,7 +7,7 @@ const ora = require('ora');
7
7
 
8
8
  const { connections } = require('../services');
9
9
  const { ACCOUNT_STATUS, ACCOUNT_TYPE } = require('../config');
10
- const { getLogoWidth, getColWidths, drawBoxHeader, drawBoxFooter, draw2ColHeader, visibleLength, displayBanner } = require('../ui');
10
+ const { getLogoWidth, getColWidths, drawBoxHeader, drawBoxFooter, draw2ColHeader, visibleLength, displayBanner, clearScreen } = require('../ui');
11
11
  const { prompts } = require('../utils');
12
12
 
13
13
  /**
@@ -15,7 +15,7 @@ const { prompts } = require('../utils');
15
15
  */
16
16
  const showAccounts = async (service) => {
17
17
  // Clear screen and show banner
18
- console.clear();
18
+ clearScreen();
19
19
  displayBanner();
20
20
 
21
21
  const boxWidth = getLogoWidth();
@@ -84,7 +84,7 @@ const showAccounts = async (service) => {
84
84
  spinner.stop();
85
85
 
86
86
  // Clear and show banner again before displaying accounts
87
- console.clear();
87
+ clearScreen();
88
88
  displayBanner();
89
89
 
90
90
  // Display accounts
@@ -6,7 +6,7 @@ const path = require('path');
6
6
  const fs = require('fs');
7
7
  const ora = require('ora');
8
8
 
9
- const { getLogoWidth, displayBanner } = require('../ui');
9
+ const { getLogoWidth, displayBanner, clearScreen } = require('../ui');
10
10
  const { prompts } = require('../utils');
11
11
  const { fetchModelsFromApi } = require('./ai-models');
12
12
  const { drawProvidersTable, drawModelsTable, drawProviderWindow, drawConnectionTest } = require('./ai-agents-ui');
@@ -14,7 +14,7 @@ const cliproxy = require('../services/cliproxy');
14
14
 
15
15
  /** Clear screen and show banner (always closed) */
16
16
  const clearWithBanner = () => {
17
- console.clear();
17
+ clearScreen();
18
18
  displayBanner(); // Banner always closed
19
19
  };
20
20
 
@@ -9,7 +9,7 @@ const path = require('path');
9
9
  const os = require('os');
10
10
  const ora = require('ora');
11
11
 
12
- const { getLogoWidth, centerText, displayBanner } = require('../../ui');
12
+ const { getLogoWidth, centerText, displayBanner , clearScreen } = require('../../ui');
13
13
  const { prompts } = require('../../utils');
14
14
  const { connections } = require('../../services');
15
15
  const { getActiveProvider, getActiveAgents } = require('../ai-agents');
@@ -155,7 +155,7 @@ const strategyChat = async (config, service) => {
155
155
  const { account, contract, contracts, dailyTarget, maxRisk, showName, aiSupervision, aiProvider } = config;
156
156
  const accountName = showName ? (account.accountName || account.rithmicAccountId || account.accountId) : 'HQX *****';
157
157
 
158
- console.clear();
158
+ clearScreen();
159
159
  displayBanner();
160
160
 
161
161
  const W = getLogoWidth() - 2;
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  const chalk = require('chalk');
6
- const { getLogoWidth, centerText, displayBanner } = require('../../ui');
6
+ const { getLogoWidth, centerText, displayBanner , clearScreen } = require('../../ui');
7
7
  const { logger, prompts } = require('../../utils');
8
8
  const { getActiveProvider } = require('../ai-agents');
9
9
 
@@ -21,7 +21,7 @@ const algoTradingMenu = async (service) => {
21
21
 
22
22
  try {
23
23
  // Clear screen and show banner
24
- console.clear();
24
+ clearScreen();
25
25
  displayBanner();
26
26
 
27
27
  const boxWidth = getLogoWidth();
@@ -371,7 +371,7 @@ const renderSessionSummary = (stats, stopReason) => {
371
371
  const colR = W - colL - 1;
372
372
  const version = require('../../../package.json').version;
373
373
 
374
- console.clear();
374
+ process.stdout.write('\x1B[2J\x1B[H');
375
375
  console.log();
376
376
 
377
377
  // Top border
@@ -7,7 +7,7 @@ const ora = require('ora');
7
7
 
8
8
  const { connections } = require('../services');
9
9
  const { ORDER_STATUS, ORDER_TYPE, ORDER_SIDE } = require('../config');
10
- const { getLogoWidth, drawBoxHeader, drawBoxFooter, drawBoxRow, drawBoxSeparator, displayBanner } = require('../ui');
10
+ const { getLogoWidth, drawBoxHeader, drawBoxFooter, drawBoxRow, drawBoxSeparator, displayBanner, clearScreen } = require('../ui');
11
11
  const { prompts } = require('../utils');
12
12
 
13
13
  /**
@@ -15,7 +15,7 @@ const { prompts } = require('../utils');
15
15
  */
16
16
  const showOrders = async (service) => {
17
17
  // Clear screen and show banner
18
- console.clear();
18
+ clearScreen();
19
19
  displayBanner();
20
20
 
21
21
  const boxWidth = getLogoWidth();
@@ -7,7 +7,7 @@ const ora = require('ora');
7
7
 
8
8
  const { connections } = require('../services');
9
9
  const { ORDER_SIDE } = require('../config');
10
- const { getLogoWidth, drawBoxHeader, drawBoxFooter, drawBoxRow, drawBoxSeparator, displayBanner } = require('../ui');
10
+ const { getLogoWidth, drawBoxHeader, drawBoxFooter, drawBoxRow, drawBoxSeparator, displayBanner, clearScreen } = require('../ui');
11
11
  const { prompts } = require('../utils');
12
12
 
13
13
  /**
@@ -15,7 +15,7 @@ const { prompts } = require('../utils');
15
15
  */
16
16
  const showPositions = async (service) => {
17
17
  // Clear screen and show banner
18
- console.clear();
18
+ clearScreen();
19
19
  displayBanner();
20
20
 
21
21
  const boxWidth = getLogoWidth();
@@ -11,7 +11,7 @@ const ora = require('ora');
11
11
 
12
12
  const { connections } = require('../../services');
13
13
  const { prompts } = require('../../utils');
14
- const { displayBanner } = require('../../ui');
14
+ const { displayBanner , clearScreen } = require('../../ui');
15
15
  const { aggregateStats, calculateDerivedMetrics, calculateQuantMetrics, calculateHQXScore } = require('./metrics');
16
16
  const { renderOverview, renderPnLMetrics, renderQuantMetrics, renderTradesHistory, renderHQXScore, renderNotice } = require('./display');
17
17
  const { renderEquityCurve } = require('./chart');
@@ -162,7 +162,7 @@ const aggregateAccountData = async (activeAccounts) => {
162
162
  */
163
163
  const showStats = async (service) => {
164
164
  // Clear screen and show banner
165
- console.clear();
165
+ clearScreen();
166
166
  displayBanner();
167
167
 
168
168
  let spinner;
@@ -199,7 +199,7 @@ const showStats = async (service) => {
199
199
  spinner.stop();
200
200
 
201
201
  // Clear and show banner before displaying stats
202
- console.clear();
202
+ clearScreen();
203
203
  displayBanner();
204
204
 
205
205
  // Calculate stats from API data
package/src/pages/user.js CHANGED
@@ -6,7 +6,7 @@ const chalk = require('chalk');
6
6
  const ora = require('ora');
7
7
 
8
8
  const { connections } = require('../services');
9
- const { getLogoWidth, getColWidths, drawBoxHeader, drawBoxFooter, draw2ColHeader, visibleLength, padText, displayBanner } = require('../ui');
9
+ const { getLogoWidth, getColWidths, drawBoxHeader, drawBoxFooter, draw2ColHeader, visibleLength, padText, displayBanner, clearScreen } = require('../ui');
10
10
  const { prompts } = require('../utils');
11
11
 
12
12
  /**
@@ -14,7 +14,7 @@ const { prompts } = require('../utils');
14
14
  */
15
15
  const showUserInfo = async (service) => {
16
16
  // Clear screen and show banner
17
- console.clear();
17
+ clearScreen();
18
18
  displayBanner();
19
19
 
20
20
  const boxWidth = getLogoWidth();
package/src/ui/index.js CHANGED
@@ -76,6 +76,15 @@ const displayBanner = () => {
76
76
  console.log(chalk.cyan('╚' + '═'.repeat(innerWidth) + '╝'));
77
77
  };
78
78
 
79
+ /**
80
+ * Clear screen without using alternate screen buffer
81
+ * Uses ANSI escape codes directly to avoid terminal state issues
82
+ */
83
+ const clearScreen = () => {
84
+ // ESC[2J = clear entire screen, ESC[H = move cursor to home
85
+ process.stdout.write('\x1B[2J\x1B[H');
86
+ };
87
+
79
88
  /**
80
89
  * Ensure stdin is ready for inquirer prompts
81
90
  * This fixes input leaking to bash after session restore or algo trading
@@ -123,5 +132,7 @@ module.exports = {
123
132
  // Stdin
124
133
  prepareStdin,
125
134
  // Banner
126
- displayBanner
135
+ displayBanner,
136
+ // Screen
137
+ clearScreen
127
138
  };