hedgequantx 2.6.161 → 2.6.162

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.
Files changed (42) hide show
  1. package/package.json +1 -1
  2. package/src/menus/ai-agent-connect.js +181 -0
  3. package/src/menus/ai-agent-models.js +219 -0
  4. package/src/menus/ai-agent-oauth.js +292 -0
  5. package/src/menus/ai-agent-ui.js +141 -0
  6. package/src/menus/ai-agent.js +88 -1489
  7. package/src/pages/algo/copy-engine.js +449 -0
  8. package/src/pages/algo/copy-trading.js +11 -543
  9. package/src/pages/algo/smart-logs-data.js +218 -0
  10. package/src/pages/algo/smart-logs.js +9 -214
  11. package/src/pages/algo/ui-constants.js +144 -0
  12. package/src/pages/algo/ui-summary.js +184 -0
  13. package/src/pages/algo/ui.js +42 -526
  14. package/src/pages/stats-calculations.js +191 -0
  15. package/src/pages/stats-ui.js +381 -0
  16. package/src/pages/stats.js +14 -507
  17. package/src/services/ai/client-analysis.js +194 -0
  18. package/src/services/ai/client-models.js +333 -0
  19. package/src/services/ai/client.js +6 -489
  20. package/src/services/ai/index.js +2 -257
  21. package/src/services/ai/proxy-install.js +249 -0
  22. package/src/services/ai/proxy-manager.js +29 -411
  23. package/src/services/ai/proxy-remote.js +161 -0
  24. package/src/services/ai/supervisor-optimize.js +215 -0
  25. package/src/services/ai/supervisor-sync.js +178 -0
  26. package/src/services/ai/supervisor.js +50 -515
  27. package/src/services/ai/validation.js +250 -0
  28. package/src/services/hqx-server-events.js +110 -0
  29. package/src/services/hqx-server-handlers.js +217 -0
  30. package/src/services/hqx-server-latency.js +136 -0
  31. package/src/services/hqx-server.js +51 -403
  32. package/src/services/position-constants.js +28 -0
  33. package/src/services/position-manager.js +105 -554
  34. package/src/services/position-momentum.js +206 -0
  35. package/src/services/projectx/accounts.js +142 -0
  36. package/src/services/projectx/index.js +40 -289
  37. package/src/services/projectx/trading.js +180 -0
  38. package/src/services/rithmic/handlers.js +2 -208
  39. package/src/services/rithmic/index.js +32 -542
  40. package/src/services/rithmic/latency-tracker.js +182 -0
  41. package/src/services/rithmic/specs.js +146 -0
  42. package/src/services/rithmic/trade-history.js +254 -0
@@ -0,0 +1,141 @@
1
+ /**
2
+ * AI Agent UI Helpers
3
+ * Shared UI functions for AI agent menu
4
+ */
5
+
6
+ const chalk = require('chalk');
7
+ const { getLogoWidth } = require('../ui');
8
+
9
+ /**
10
+ * Create a line with padding for box display
11
+ * @param {number} W - Box inner width
12
+ * @param {string} content - Content to display
13
+ * @param {string} align - Alignment: 'left' or 'center'
14
+ * @returns {string} Formatted line
15
+ */
16
+ const makeLine = (W, content, align = 'left') => {
17
+ const plainLen = content.replace(/\x1b\[[0-9;]*m/g, '').length;
18
+ const padding = W - plainLen;
19
+ if (align === 'center') {
20
+ const leftPad = Math.floor(padding / 2);
21
+ return chalk.cyan('║') + ' '.repeat(leftPad) + content + ' '.repeat(padding - leftPad) + chalk.cyan('║');
22
+ }
23
+ return chalk.cyan('║') + ' ' + content + ' '.repeat(Math.max(0, padding - 1)) + chalk.cyan('║');
24
+ };
25
+
26
+ /**
27
+ * Create a 2-column row for box display
28
+ * @param {number} W - Box inner width
29
+ * @param {string} left - Left column content
30
+ * @param {string} right - Right column content
31
+ * @returns {string} Formatted line
32
+ */
33
+ const make2ColRow = (W, left, right) => {
34
+ const col1Width = Math.floor(W / 2);
35
+ const leftPlain = left.replace(/\x1b\[[0-9;]*m/g, '').length;
36
+ const rightPlain = right.replace(/\x1b\[[0-9;]*m/g, '').length;
37
+ const leftPadded = ' ' + left + ' '.repeat(Math.max(0, col1Width - leftPlain - 1));
38
+ const rightPadded = right + ' '.repeat(Math.max(0, W - col1Width - rightPlain));
39
+ return chalk.cyan('║') + leftPadded + rightPadded + chalk.cyan('║');
40
+ };
41
+
42
+ /**
43
+ * Create a menu row with 2 columns centered
44
+ * @param {number} W - Box inner width
45
+ * @param {string} col1 - First column content
46
+ * @param {string} col2 - Second column content
47
+ * @returns {string} Formatted line
48
+ */
49
+ const menuRow2 = (W, col1, col2 = '') => {
50
+ const colWidth = Math.floor(W / 2);
51
+ const c1Plain = col1.replace(/\x1b\[[0-9;]*m/g, '');
52
+ const c2Plain = col2.replace(/\x1b\[[0-9;]*m/g, '');
53
+
54
+ const pad1Left = Math.floor((colWidth - c1Plain.length) / 2);
55
+ const pad1Right = colWidth - c1Plain.length - pad1Left;
56
+
57
+ const col2Width = W - colWidth;
58
+ const pad2Left = Math.floor((col2Width - c2Plain.length) / 2);
59
+ const pad2Right = col2Width - c2Plain.length - pad2Left;
60
+
61
+ const line =
62
+ ' '.repeat(pad1Left) + col1 + ' '.repeat(pad1Right) +
63
+ ' '.repeat(pad2Left) + col2 + ' '.repeat(pad2Right);
64
+
65
+ return chalk.cyan('║') + line + chalk.cyan('║');
66
+ };
67
+
68
+ /**
69
+ * Create a menu item with key and label
70
+ * @param {string} key - Key to press
71
+ * @param {string} label - Label to display
72
+ * @param {Function} color - Chalk color function
73
+ * @returns {string} Formatted menu item
74
+ */
75
+ const menuItem = (key, label, color) => {
76
+ const text = `[${key}] ${label.padEnd(14)}`;
77
+ return color(text);
78
+ };
79
+
80
+ /**
81
+ * Get provider color based on provider ID
82
+ * @param {string} providerId - Provider identifier
83
+ * @returns {Function} Chalk color function
84
+ */
85
+ const getProviderColor = (providerId) => {
86
+ if (providerId === 'anthropic') return chalk.magenta;
87
+ if (providerId === 'openai') return chalk.green;
88
+ if (providerId === 'openrouter') return chalk.yellow;
89
+ return chalk.cyan;
90
+ };
91
+
92
+ /**
93
+ * Get box dimensions
94
+ * @returns {Object} { boxWidth, W }
95
+ */
96
+ const getBoxDimensions = () => {
97
+ const boxWidth = getLogoWidth();
98
+ const W = boxWidth - 2;
99
+ return { boxWidth, W };
100
+ };
101
+
102
+ /**
103
+ * Open URL in default browser
104
+ * @param {string} url - URL to open
105
+ * @returns {Promise<boolean>} true if browser opened, false if failed
106
+ */
107
+ const openBrowser = (url) => {
108
+ return new Promise((resolve) => {
109
+ const { exec } = require('child_process');
110
+ const platform = process.platform;
111
+
112
+ let cmd;
113
+ if (platform === 'darwin') cmd = `open "${url}"`;
114
+ else if (platform === 'win32') cmd = `start "" "${url}"`;
115
+ else cmd = `xdg-open "${url}"`;
116
+
117
+ exec(cmd, (err) => {
118
+ resolve(!err);
119
+ });
120
+ });
121
+ };
122
+
123
+ /**
124
+ * Check if running on remote/VPS (SSH)
125
+ * @returns {boolean} true if remote
126
+ */
127
+ const isRemoteEnvironment = () => {
128
+ return process.env.SSH_CONNECTION || process.env.SSH_CLIENT ||
129
+ (process.env.DISPLAY === undefined && process.platform === 'linux');
130
+ };
131
+
132
+ module.exports = {
133
+ makeLine,
134
+ make2ColRow,
135
+ menuRow2,
136
+ menuItem,
137
+ getProviderColor,
138
+ getBoxDimensions,
139
+ openBrowser,
140
+ isRemoteEnvironment
141
+ };