hedgequantx 1.8.45 → 1.8.47
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/menus/dashboard.js +48 -22
package/package.json
CHANGED
package/src/menus/dashboard.js
CHANGED
|
@@ -43,7 +43,7 @@ const dashboardMenu = async (service) => {
|
|
|
43
43
|
console.log(makeLine(propfirmText, 'center'));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// Stats bar
|
|
46
|
+
// Stats bar with yellow icons
|
|
47
47
|
const statsInfo = getCachedStats();
|
|
48
48
|
if (statsInfo) {
|
|
49
49
|
console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
|
|
@@ -60,15 +60,17 @@ const dashboardMenu = async (service) => {
|
|
|
60
60
|
pnlDisplay = '--';
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
// Yellow icons: ✔ for each stat
|
|
64
|
+
const icon = chalk.yellow('✔ ');
|
|
65
|
+
const statsPlain = `✔ Connections: ${statsInfo.connections} ✔ Accounts: ${statsInfo.accounts} ✔ Balance: ${balStr} ✔ P&L: ${pnlDisplay}`;
|
|
64
66
|
const statsLeftPad = Math.floor((W - statsPlain.length) / 2);
|
|
65
67
|
const statsRightPad = W - statsPlain.length - statsLeftPad;
|
|
66
68
|
|
|
67
69
|
console.log(chalk.cyan('║') + ' '.repeat(statsLeftPad) +
|
|
68
|
-
chalk.white(`Connections: ${statsInfo.connections}`) + ' ' +
|
|
69
|
-
chalk.white(`Accounts: ${statsInfo.accounts}`) + ' ' +
|
|
70
|
-
chalk.white('Balance: ') + balColor(balStr) + ' ' +
|
|
71
|
-
chalk.white('P&L: ') + pnlColor(pnlDisplay) +
|
|
70
|
+
icon + chalk.white(`Connections: ${statsInfo.connections}`) + ' ' +
|
|
71
|
+
icon + chalk.white(`Accounts: ${statsInfo.accounts}`) + ' ' +
|
|
72
|
+
icon + chalk.white('Balance: ') + balColor(balStr) + ' ' +
|
|
73
|
+
icon + chalk.white('P&L: ') + pnlColor(pnlDisplay) +
|
|
72
74
|
' '.repeat(Math.max(0, statsRightPad)) + chalk.cyan('║'));
|
|
73
75
|
}
|
|
74
76
|
|
|
@@ -119,59 +121,83 @@ const handleUpdate = async () => {
|
|
|
119
121
|
currentVersion = require('../../package.json').version || 'unknown';
|
|
120
122
|
} catch (e) {}
|
|
121
123
|
|
|
124
|
+
console.log(chalk.cyan(`\n Current version: v${currentVersion}`));
|
|
122
125
|
spinner = ora({ text: 'Checking for updates...', color: 'yellow' }).start();
|
|
123
126
|
|
|
124
127
|
let latestVersion;
|
|
125
128
|
try {
|
|
126
|
-
latestVersion = execSync('npm view hedgequantx version
|
|
127
|
-
stdio: 'pipe',
|
|
129
|
+
latestVersion = execSync('npm view hedgequantx version', {
|
|
130
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
131
|
+
timeout: 30000,
|
|
132
|
+
encoding: 'utf8'
|
|
128
133
|
}).trim();
|
|
129
134
|
|
|
130
135
|
if (!latestVersion || !/^\d+\.\d+\.\d+/.test(latestVersion)) {
|
|
131
|
-
throw new Error('Invalid version');
|
|
136
|
+
throw new Error('Invalid version format');
|
|
132
137
|
}
|
|
133
138
|
} catch (e) {
|
|
134
139
|
spinner.fail('Cannot reach npm registry');
|
|
140
|
+
console.log(chalk.gray(` Error: ${e.message}`));
|
|
141
|
+
console.log(chalk.yellow(' Try manually: npm install -g hedgequantx@latest'));
|
|
135
142
|
await prompts.waitForEnter();
|
|
136
143
|
return;
|
|
137
144
|
}
|
|
138
145
|
|
|
146
|
+
spinner.succeed(`Latest version: v${latestVersion}`);
|
|
147
|
+
|
|
139
148
|
if (currentVersion === latestVersion) {
|
|
140
|
-
|
|
141
|
-
await
|
|
149
|
+
console.log(chalk.green(' Already up to date!'));
|
|
150
|
+
await prompts.waitForEnter();
|
|
142
151
|
return;
|
|
143
152
|
}
|
|
144
153
|
|
|
145
|
-
|
|
154
|
+
console.log(chalk.yellow(` Update available: v${currentVersion} → v${latestVersion}`));
|
|
155
|
+
spinner = ora({ text: 'Installing update...', color: 'yellow' }).start();
|
|
146
156
|
|
|
147
157
|
try {
|
|
148
|
-
|
|
149
|
-
|
|
158
|
+
// Try with sudo first on Unix systems
|
|
159
|
+
const isWindows = process.platform === 'win32';
|
|
160
|
+
const cmd = isWindows
|
|
161
|
+
? 'npm install -g hedgequantx@latest'
|
|
162
|
+
: 'npm install -g hedgequantx@latest';
|
|
163
|
+
|
|
164
|
+
execSync(cmd, {
|
|
165
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
166
|
+
timeout: 180000,
|
|
167
|
+
encoding: 'utf8'
|
|
150
168
|
});
|
|
151
169
|
} catch (e) {
|
|
152
|
-
spinner.fail('Update failed');
|
|
153
|
-
console.log(chalk.
|
|
170
|
+
spinner.fail('Update failed - permission denied?');
|
|
171
|
+
console.log(chalk.gray(` Error: ${e.message}`));
|
|
172
|
+
console.log(chalk.yellow(' Try manually with sudo:'));
|
|
173
|
+
console.log(chalk.white(' sudo npm install -g hedgequantx@latest'));
|
|
154
174
|
await prompts.waitForEnter();
|
|
155
175
|
return;
|
|
156
176
|
}
|
|
157
177
|
|
|
158
|
-
spinner.succeed(`Updated
|
|
159
|
-
console.log(chalk.cyan(' Restarting...'));
|
|
178
|
+
spinner.succeed(`Updated to v${latestVersion}!`);
|
|
179
|
+
console.log(chalk.cyan(' Restarting HQX...'));
|
|
160
180
|
|
|
161
|
-
await new Promise(r => setTimeout(r,
|
|
181
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
162
182
|
|
|
163
183
|
try {
|
|
164
|
-
const child = spawn('
|
|
184
|
+
const child = spawn('hqx', [], {
|
|
185
|
+
stdio: 'inherit',
|
|
186
|
+
detached: true,
|
|
187
|
+
shell: true
|
|
188
|
+
});
|
|
165
189
|
child.unref();
|
|
166
190
|
process.exit(0);
|
|
167
191
|
} catch (e) {
|
|
168
|
-
console.log(chalk.yellow(' Please
|
|
192
|
+
console.log(chalk.yellow('\n Please restart HQX manually:'));
|
|
193
|
+
console.log(chalk.white(' hqx'));
|
|
169
194
|
await prompts.waitForEnter();
|
|
170
195
|
}
|
|
171
196
|
|
|
172
197
|
} catch (error) {
|
|
173
198
|
if (spinner) spinner.fail('Update error');
|
|
174
|
-
console.log(chalk.
|
|
199
|
+
console.log(chalk.gray(` Error: ${error.message}`));
|
|
200
|
+
console.log(chalk.yellow(' Try manually: npm install -g hedgequantx@latest'));
|
|
175
201
|
await prompts.waitForEnter();
|
|
176
202
|
}
|
|
177
203
|
};
|