hedgequantx 1.5.9 → 1.5.11
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 +6 -16
- package/src/menus/dashboard.js +3 -4
- package/src/services/stats-cache.js +23 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -10,6 +10,7 @@ const ora = require('ora');
|
|
|
10
10
|
const { connections } = require('./services');
|
|
11
11
|
const { getLogoWidth, centerText, prepareStdin } = require('./ui');
|
|
12
12
|
const { logger } = require('./utils');
|
|
13
|
+
const { setCachedStats, clearCachedStats } = require('./services/stats-cache');
|
|
13
14
|
|
|
14
15
|
const log = logger.scope('App');
|
|
15
16
|
|
|
@@ -25,9 +26,6 @@ const { projectXMenu, rithmicMenu, tradovateMenu, addPropAccountMenu, dashboardM
|
|
|
25
26
|
let currentService = null;
|
|
26
27
|
let currentPlatform = null; // 'projectx' or 'rithmic'
|
|
27
28
|
|
|
28
|
-
// Cached stats for banner (avoid refetching on every screen)
|
|
29
|
-
let cachedStats = null;
|
|
30
|
-
|
|
31
29
|
/**
|
|
32
30
|
* Global terminal restoration - ensures terminal is always restored on exit
|
|
33
31
|
*/
|
|
@@ -92,18 +90,18 @@ const refreshStats = async () => {
|
|
|
92
90
|
}
|
|
93
91
|
});
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
setCachedStats({
|
|
96
94
|
connections: connections.count(),
|
|
97
95
|
accounts: activeAccounts.length,
|
|
98
96
|
balance: hasBalanceData ? totalBalance : null,
|
|
99
97
|
pnl: hasPnlData ? totalPnl : null,
|
|
100
98
|
pnlPercent: null
|
|
101
|
-
};
|
|
99
|
+
});
|
|
102
100
|
} catch (e) {
|
|
103
101
|
// Ignore errors
|
|
104
102
|
}
|
|
105
103
|
} else {
|
|
106
|
-
|
|
104
|
+
clearCachedStats();
|
|
107
105
|
}
|
|
108
106
|
};
|
|
109
107
|
|
|
@@ -119,9 +117,6 @@ const banner = async () => {
|
|
|
119
117
|
const innerWidth = boxWidth - 2;
|
|
120
118
|
const version = require('../package.json').version;
|
|
121
119
|
|
|
122
|
-
// Use cached stats (no refetch on every banner display)
|
|
123
|
-
const statsInfo = cachedStats;
|
|
124
|
-
|
|
125
120
|
// Draw logo - compact for mobile, full for desktop
|
|
126
121
|
|
|
127
122
|
console.log(chalk.cyan('╔' + '═'.repeat(innerWidth) + '╗'));
|
|
@@ -193,11 +188,6 @@ const banner = async () => {
|
|
|
193
188
|
console.log();
|
|
194
189
|
};
|
|
195
190
|
|
|
196
|
-
/**
|
|
197
|
-
* Get cached stats for dashboard
|
|
198
|
-
*/
|
|
199
|
-
const getCachedStats = () => cachedStats;
|
|
200
|
-
|
|
201
191
|
/**
|
|
202
192
|
* Main connection menu
|
|
203
193
|
*/
|
|
@@ -357,7 +347,7 @@ const run = async () => {
|
|
|
357
347
|
const connCount = connections.count();
|
|
358
348
|
connections.disconnectAll();
|
|
359
349
|
currentService = null;
|
|
360
|
-
|
|
350
|
+
clearCachedStats();
|
|
361
351
|
console.log(chalk.yellow(`Disconnected ${connCount} connection${connCount > 1 ? 's' : ''}`));
|
|
362
352
|
break;
|
|
363
353
|
case 'exit':
|
|
@@ -376,4 +366,4 @@ const run = async () => {
|
|
|
376
366
|
}
|
|
377
367
|
};
|
|
378
368
|
|
|
379
|
-
module.exports = { run, banner, mainMenu, dashboardMenu
|
|
369
|
+
module.exports = { run, banner, mainMenu, dashboardMenu };
|
package/src/menus/dashboard.js
CHANGED
|
@@ -10,7 +10,7 @@ const { execSync, spawn } = require('child_process');
|
|
|
10
10
|
|
|
11
11
|
const { connections } = require('../services');
|
|
12
12
|
const { getLogoWidth, centerText, prepareStdin } = require('../ui');
|
|
13
|
-
const { getCachedStats } = require('../
|
|
13
|
+
const { getCachedStats } = require('../services/stats-cache');
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Dashboard menu after login
|
|
@@ -45,13 +45,12 @@ const dashboardMenu = async (service) => {
|
|
|
45
45
|
const allConns = connections.getAll();
|
|
46
46
|
if (allConns.length > 0) {
|
|
47
47
|
const propfirms = allConns.slice(0, 3).map(c => c.propfirm || c.type || 'Connected');
|
|
48
|
-
const propfirmText = propfirms.map(p => chalk.green('
|
|
48
|
+
const propfirmText = propfirms.map(p => chalk.green('> ') + chalk.white(p)).join(' ');
|
|
49
49
|
console.log(makeLine(propfirmText, 'center'));
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Show stats bar (Connections, Accounts, Balance, P&L)
|
|
53
|
-
|
|
54
|
-
try { statsInfo = getCachedStats(); } catch (e) {}
|
|
53
|
+
const statsInfo = getCachedStats();
|
|
55
54
|
|
|
56
55
|
if (statsInfo) {
|
|
57
56
|
console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stats Cache - Shared stats storage to avoid circular dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
let cachedStats = null;
|
|
6
|
+
|
|
7
|
+
const setCachedStats = (stats) => {
|
|
8
|
+
cachedStats = stats;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getCachedStats = () => {
|
|
12
|
+
return cachedStats;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const clearCachedStats = () => {
|
|
16
|
+
cachedStats = null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
setCachedStats,
|
|
21
|
+
getCachedStats,
|
|
22
|
+
clearCachedStats
|
|
23
|
+
};
|