hedgequantx 2.5.43 → 2.6.0
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/bin/cli.js +11 -0
- package/package.json +1 -1
- package/src/app.js +11 -0
- package/src/config/settings.js +29 -0
- package/src/pages/algo/copy-trading.js +692 -253
- package/src/pages/algo/one-account.js +241 -47
- package/src/services/position-manager.js +927 -0
- package/src/services/rithmic/connection.js +201 -1
- package/src/services/rithmic/handlers.js +341 -5
- package/src/services/rithmic/index.js +75 -3
- package/src/services/rithmic/orders.js +193 -1
- package/src/services/rithmic/protobuf.js +171 -2
package/bin/cli.js
CHANGED
|
@@ -51,6 +51,17 @@ program
|
|
|
51
51
|
console.log(`HedgeQuantX CLI v${pkg.version}`);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
program
|
|
55
|
+
.command('test-latency')
|
|
56
|
+
.description('Test order latency (requires active Rithmic connection)')
|
|
57
|
+
.option('-s, --symbol <symbol>', 'Symbol to test (e.g., NQ, ES, MNQ)', 'NQ')
|
|
58
|
+
.option('-c, --count <count>', 'Number of test iterations', '10')
|
|
59
|
+
.option('-p, --propfirm <propfirm>', 'Propfirm to use', 'apex')
|
|
60
|
+
.action(async (options) => {
|
|
61
|
+
const { runLatencyTest } = require('../src/commands/test-latency');
|
|
62
|
+
await runLatencyTest(options);
|
|
63
|
+
});
|
|
64
|
+
|
|
54
65
|
// Handle -u flag before parsing commands
|
|
55
66
|
if (process.argv.includes('-u') || process.argv.includes('--update')) {
|
|
56
67
|
const { execSync } = require('child_process');
|
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -256,6 +256,17 @@ const run = async () => {
|
|
|
256
256
|
log.info('Starting HQX CLI');
|
|
257
257
|
await bannerClosed();
|
|
258
258
|
|
|
259
|
+
// PRE-LOAD: Initialize Rithmic protobuf definitions at startup
|
|
260
|
+
// This removes ~100ms latency from first order
|
|
261
|
+
const { proto } = require('./services/rithmic/protobuf');
|
|
262
|
+
const protoSpinner = ora({ text: 'INITIALIZING TRADING ENGINE...', color: 'cyan' }).start();
|
|
263
|
+
try {
|
|
264
|
+
await proto.load();
|
|
265
|
+
protoSpinner.succeed('TRADING ENGINE READY');
|
|
266
|
+
} catch (e) {
|
|
267
|
+
protoSpinner.warn('Trading engine partial init');
|
|
268
|
+
}
|
|
269
|
+
|
|
259
270
|
// Restore session
|
|
260
271
|
const spinner = ora({ text: 'RESTORING SESSION...', color: 'yellow' }).start();
|
|
261
272
|
const restored = await connections.restoreFromStorage();
|
package/src/config/settings.js
CHANGED
|
@@ -136,6 +136,34 @@ const CACHE = {
|
|
|
136
136
|
STATS_TTL: 60000, // 1 minute
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
// ==================== FAST SCALPING (Ultra-Low Latency) ====================
|
|
140
|
+
const FAST_SCALPING = {
|
|
141
|
+
// Hold constraints (prop firm rules - NON-NEGOTIABLE)
|
|
142
|
+
MIN_HOLD_MS: 10000, // 10 seconds minimum hold
|
|
143
|
+
MAX_HOLD_MS: 60000, // 60 seconds failsafe (force exit if stuck)
|
|
144
|
+
|
|
145
|
+
// Exit targets (in ticks) - defaults, override per symbol
|
|
146
|
+
TARGET_TICKS: 16, // Take profit target
|
|
147
|
+
STOP_TICKS: 20, // Stop loss
|
|
148
|
+
|
|
149
|
+
// Trailing stop (activates after MIN_HOLD + profit threshold)
|
|
150
|
+
TRAILING_ACTIVATION_TICKS: 8, // Start trailing after +8 ticks profit
|
|
151
|
+
TRAILING_DISTANCE_TICKS: 4, // Trail 4 ticks behind high/low
|
|
152
|
+
|
|
153
|
+
// Position monitoring
|
|
154
|
+
MONITOR_INTERVAL_MS: 100, // Check position every 100ms after hold
|
|
155
|
+
|
|
156
|
+
// Momentum thresholds (cumulative delta over 5 seconds)
|
|
157
|
+
MOMENTUM_STRONG_THRESHOLD: 50, // Delta > 50 = strong momentum, HOLD
|
|
158
|
+
MOMENTUM_WEAK_THRESHOLD: 20, // Delta < 20 = weak momentum, consider EXIT
|
|
159
|
+
MOMENTUM_WINDOW_MS: 5000, // 5 second window for momentum calc
|
|
160
|
+
|
|
161
|
+
// Latency monitoring
|
|
162
|
+
LOG_LATENCY: true,
|
|
163
|
+
LATENCY_TARGET_MS: 50, // Target entry latency
|
|
164
|
+
LATENCY_WARN_MS: 100, // Warn if entry takes > 100ms
|
|
165
|
+
};
|
|
166
|
+
|
|
139
167
|
// ==================== DEBUG ====================
|
|
140
168
|
const DEBUG = {
|
|
141
169
|
get enabled() {
|
|
@@ -152,4 +180,5 @@ module.exports = {
|
|
|
152
180
|
HQX_SERVER,
|
|
153
181
|
CACHE,
|
|
154
182
|
DEBUG,
|
|
183
|
+
FAST_SCALPING,
|
|
155
184
|
};
|