hedgequantx 1.8.44 → 1.8.46
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 +8 -6
- package/src/pages/accounts.js +118 -63
- package/src/pages/orders.js +104 -58
- package/src/pages/positions.js +105 -59
- package/src/pages/stats.js +450 -424
- package/src/pages/user.js +68 -47
package/src/pages/user.js
CHANGED
|
@@ -13,9 +13,9 @@ const { prompts } = require('../utils');
|
|
|
13
13
|
* Show user info
|
|
14
14
|
*/
|
|
15
15
|
const showUserInfo = async (service) => {
|
|
16
|
-
const spinner = ora({ text: 'Fetching user info...', color: 'yellow' }).start();
|
|
17
16
|
const boxWidth = getLogoWidth();
|
|
18
17
|
const { col1, col2 } = getColWidths(boxWidth);
|
|
18
|
+
let spinner;
|
|
19
19
|
|
|
20
20
|
const fmtRow = (label, value, colW) => {
|
|
21
21
|
const labelStr = ' ' + label.padEnd(14);
|
|
@@ -24,54 +24,75 @@ const showUserInfo = async (service) => {
|
|
|
24
24
|
return chalk.white(labelStr) + value + ' '.repeat(padding);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
userInfo =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
27
|
+
try {
|
|
28
|
+
// Step 1: Get user info
|
|
29
|
+
spinner = ora({ text: 'Loading user info...', color: 'yellow' }).start();
|
|
30
|
+
|
|
31
|
+
let userInfo = null;
|
|
32
|
+
|
|
33
|
+
if (service?.user) {
|
|
34
|
+
userInfo = service.user;
|
|
35
|
+
} else if (service && typeof service.getUser === 'function') {
|
|
36
|
+
try {
|
|
37
|
+
const result = await service.getUser();
|
|
38
|
+
if (result.success) userInfo = result.user;
|
|
39
|
+
} catch (e) {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
spinner.succeed('User info loaded');
|
|
43
|
+
|
|
44
|
+
// Step 2: Get account count
|
|
45
|
+
spinner = ora({ text: 'Counting accounts...', color: 'yellow' }).start();
|
|
46
|
+
|
|
47
|
+
let accountCount = 0;
|
|
48
|
+
|
|
49
|
+
if (connections.count() > 0) {
|
|
50
|
+
try {
|
|
51
|
+
const accounts = await connections.getAllAccounts();
|
|
52
|
+
accountCount = accounts.length;
|
|
53
|
+
} catch (e) {}
|
|
54
|
+
} else if (service && typeof service.getTradingAccounts === 'function') {
|
|
55
|
+
try {
|
|
56
|
+
const result = await service.getTradingAccounts();
|
|
57
|
+
if (result.success) accountCount = result.accounts.length;
|
|
58
|
+
} catch (e) {}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
spinner.succeed(`Found ${accountCount} account(s)`);
|
|
62
|
+
console.log();
|
|
63
|
+
|
|
64
|
+
// Display
|
|
65
|
+
drawBoxHeader('USER INFO', boxWidth);
|
|
66
|
+
|
|
67
|
+
if (!userInfo) {
|
|
68
|
+
console.log(chalk.cyan('║') + padText(chalk.gray(' No user info available'), boxWidth - 2) + chalk.cyan('║'));
|
|
69
|
+
} else {
|
|
70
|
+
draw2ColHeader('PROFILE', 'CONNECTIONS', boxWidth);
|
|
71
|
+
|
|
72
|
+
const username = userInfo.userName || userInfo.username || 'Unknown';
|
|
73
|
+
const connCount = connections.count() || 1;
|
|
74
|
+
console.log(chalk.cyan('║') + fmtRow('Username:', chalk.cyan(username.toUpperCase()), col1) + chalk.cyan('│') + fmtRow('Connections:', chalk.cyan(String(connCount)), col2) + chalk.cyan('║'));
|
|
75
|
+
|
|
76
|
+
const email = userInfo.email || 'N/A';
|
|
77
|
+
console.log(chalk.cyan('║') + fmtRow('Email:', chalk.white(email), col1) + chalk.cyan('│') + fmtRow('Accounts:', chalk.cyan(String(accountCount)), col2) + chalk.cyan('║'));
|
|
78
|
+
|
|
79
|
+
const userId = userInfo.userId || userInfo.id || 'N/A';
|
|
80
|
+
const platform = service?.propfirm?.name || 'ProjectX';
|
|
81
|
+
console.log(chalk.cyan('║') + fmtRow('User ID:', chalk.gray(String(userId)), col1) + chalk.cyan('│') + fmtRow('Platform:', chalk.magenta(platform), col2) + chalk.cyan('║'));
|
|
82
|
+
|
|
83
|
+
const firstName = userInfo.firstName || '';
|
|
84
|
+
const lastName = userInfo.lastName || '';
|
|
85
|
+
const fullName = (firstName + ' ' + lastName).trim() || 'N/A';
|
|
86
|
+
console.log(chalk.cyan('║') + fmtRow('Name:', chalk.white(fullName), col1) + chalk.cyan('│') + padText('', col2) + chalk.cyan('║'));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
drawBoxFooter(boxWidth);
|
|
90
|
+
console.log();
|
|
91
|
+
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (spinner) spinner.fail('Error: ' + error.message);
|
|
70
94
|
}
|
|
71
95
|
|
|
72
|
-
drawBoxFooter(boxWidth);
|
|
73
|
-
console.log();
|
|
74
|
-
|
|
75
96
|
await prompts.waitForEnter();
|
|
76
97
|
};
|
|
77
98
|
|