hedgequantx 2.9.44 → 2.9.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/dist/lib/m/hqx-2b.jsc
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const readline = require('readline');
|
|
8
8
|
const { AlgoUI, renderSessionSummary } = require('./ui');
|
|
9
|
-
const {
|
|
9
|
+
const { loadStrategy } = require('../../lib/m');
|
|
10
10
|
const { MarketDataFeed } = require('../../lib/data');
|
|
11
11
|
const { SupervisionEngine } = require('../../services/ai-supervision');
|
|
12
12
|
|
|
@@ -17,12 +17,19 @@ const { SupervisionEngine } = require('../../services/ai-supervision');
|
|
|
17
17
|
* @param {Object} params.account - Account object
|
|
18
18
|
* @param {Object} params.contract - Contract object
|
|
19
19
|
* @param {Object} params.config - Algo config (contracts, target, risk, showName)
|
|
20
|
+
* @param {Object} params.strategy - Strategy info object with id, name
|
|
20
21
|
* @param {Object} params.options - Optional: supervisionConfig for multi-agent AI
|
|
21
22
|
*/
|
|
22
|
-
const executeAlgo = async ({ service, account, contract, config, options = {} }) => {
|
|
23
|
+
const executeAlgo = async ({ service, account, contract, config, strategy: strategyInfo, options = {} }) => {
|
|
23
24
|
const { contracts, dailyTarget, maxRisk, showName } = config;
|
|
24
25
|
const { supervisionConfig, subtitle } = options;
|
|
25
26
|
|
|
27
|
+
// Load the selected strategy module dynamically
|
|
28
|
+
const strategyId = strategyInfo?.id || 'ultra-scalping';
|
|
29
|
+
const strategyName = strategyInfo?.name || 'HQX Scalping';
|
|
30
|
+
const strategyModule = loadStrategy(strategyId);
|
|
31
|
+
const StrategyClass = strategyModule.M1; // loadStrategy normalizes to M1
|
|
32
|
+
|
|
26
33
|
// Initialize AI Supervision Engine if configured
|
|
27
34
|
const supervisionEnabled = supervisionConfig?.supervisionEnabled && supervisionConfig?.agents?.length > 0;
|
|
28
35
|
const supervisionEngine = supervisionEnabled ? new SupervisionEngine(supervisionConfig) : null;
|
|
@@ -35,7 +42,7 @@ const executeAlgo = async ({ service, account, contract, config, options = {} })
|
|
|
35
42
|
const tickSize = contract.tickSize || 0.25;
|
|
36
43
|
|
|
37
44
|
const ui = new AlgoUI({
|
|
38
|
-
subtitle: subtitle || (supervisionEnabled ?
|
|
45
|
+
subtitle: subtitle || (supervisionEnabled ? `${strategyName} + AI` : strategyName),
|
|
39
46
|
mode: 'one-account'
|
|
40
47
|
});
|
|
41
48
|
|
|
@@ -67,14 +74,14 @@ const executeAlgo = async ({ service, account, contract, config, options = {} })
|
|
|
67
74
|
const aiContext = { recentTicks: [], recentSignals: [], recentTrades: [], maxTicks: 100 };
|
|
68
75
|
|
|
69
76
|
// Initialize Strategy
|
|
70
|
-
const strategy = new
|
|
77
|
+
const strategy = new StrategyClass({ tickSize });
|
|
71
78
|
strategy.initialize(contractId, tickSize);
|
|
72
79
|
|
|
73
80
|
// Initialize Market Data Feed
|
|
74
81
|
const marketFeed = new MarketDataFeed({ propfirm: account.propfirm });
|
|
75
82
|
|
|
76
83
|
// Log startup
|
|
77
|
-
ui.addLog('info', `Strategy: ${supervisionEnabled ? '
|
|
84
|
+
ui.addLog('info', `Strategy: ${strategyName}${supervisionEnabled ? ' + AI' : ''}`);
|
|
78
85
|
ui.addLog('info', `Account: ${accountName}`);
|
|
79
86
|
ui.addLog('info', `Symbol: ${symbolName} | Qty: ${contracts}`);
|
|
80
87
|
ui.addLog('info', `Target: $${dailyTarget} | Risk: $${maxRisk}`);
|
|
@@ -7,14 +7,20 @@ const readline = require('readline');
|
|
|
7
7
|
const { connections } = require('../../services');
|
|
8
8
|
const { AlgoUI, renderSessionSummary } = require('./ui');
|
|
9
9
|
const { SupervisionEngine } = require('../../services/ai-supervision');
|
|
10
|
-
const {
|
|
10
|
+
const { loadStrategy } = require('../../lib/m');
|
|
11
11
|
const { MarketDataFeed } = require('../../lib/data');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Launch Copy Trading execution
|
|
15
15
|
*/
|
|
16
16
|
const launchCopyTrading = async (config) => {
|
|
17
|
-
const { lead, followers, contract, dailyTarget, maxRisk, showNames, supervisionConfig } = config;
|
|
17
|
+
const { lead, followers, contract, dailyTarget, maxRisk, showNames, supervisionConfig, strategy: strategyInfo } = config;
|
|
18
|
+
|
|
19
|
+
// Load the selected strategy module dynamically
|
|
20
|
+
const strategyId = strategyInfo?.id || 'ultra-scalping';
|
|
21
|
+
const strategyName = strategyInfo?.name || 'HQX Scalping';
|
|
22
|
+
const strategyModule = loadStrategy(strategyId);
|
|
23
|
+
const StrategyClass = strategyModule.M1;
|
|
18
24
|
|
|
19
25
|
// Initialize AI Supervision if configured
|
|
20
26
|
const supervisionEnabled = supervisionConfig?.supervisionEnabled && supervisionConfig?.agents?.length > 0;
|
|
@@ -35,7 +41,7 @@ const launchCopyTrading = async (config) => {
|
|
|
35
41
|
);
|
|
36
42
|
|
|
37
43
|
const ui = new AlgoUI({
|
|
38
|
-
subtitle: supervisionEnabled ?
|
|
44
|
+
subtitle: supervisionEnabled ? `${strategyName} Copy + AI` : `${strategyName} Copy`,
|
|
39
45
|
mode: 'copy-trading'
|
|
40
46
|
});
|
|
41
47
|
|
|
@@ -68,7 +74,7 @@ const launchCopyTrading = async (config) => {
|
|
|
68
74
|
let tickCount = 0;
|
|
69
75
|
|
|
70
76
|
// Initialize Strategy
|
|
71
|
-
const strategy = new
|
|
77
|
+
const strategy = new StrategyClass({ tickSize });
|
|
72
78
|
strategy.initialize(contractId, tickSize);
|
|
73
79
|
|
|
74
80
|
// Initialize Market Data Feed
|
|
@@ -13,6 +13,7 @@ const { checkMarketHours } = require('../../services/rithmic/market');
|
|
|
13
13
|
const { getActiveAgentCount, getSupervisionConfig, getActiveAgents } = require('../ai-agents');
|
|
14
14
|
const { launchCopyTrading } = require('./copy-executor');
|
|
15
15
|
const { runPreflightCheck, formatPreflightResults, getPreflightSummary } = require('../../services/ai-supervision');
|
|
16
|
+
const { getAvailableStrategies } = require('../../lib/m');
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Copy Trading Menu
|
|
@@ -125,6 +126,10 @@ const copyTradingMenu = async () => {
|
|
|
125
126
|
const contract = await selectSymbol(leadService);
|
|
126
127
|
if (!contract) return;
|
|
127
128
|
|
|
129
|
+
// Step 3b: Select Strategy
|
|
130
|
+
const strategy = await selectStrategy();
|
|
131
|
+
if (!strategy) return;
|
|
132
|
+
|
|
128
133
|
// Step 4: Configure Parameters
|
|
129
134
|
console.log();
|
|
130
135
|
console.log(chalk.cyan.bold(' STEP 4: CONFIGURE PARAMETERS'));
|
|
@@ -185,6 +190,7 @@ const copyTradingMenu = async () => {
|
|
|
185
190
|
// Summary
|
|
186
191
|
console.log();
|
|
187
192
|
console.log(chalk.white.bold(' SUMMARY:'));
|
|
193
|
+
console.log(chalk.cyan(` Strategy: ${strategy.name}`));
|
|
188
194
|
console.log(chalk.cyan(` Symbol: ${contract.name}`));
|
|
189
195
|
console.log(chalk.cyan(` Lead: ${leadAccount.propfirm} x${leadContracts}`));
|
|
190
196
|
console.log(chalk.yellow(` Followers (${followers.length}):`));
|
|
@@ -202,6 +208,7 @@ const copyTradingMenu = async () => {
|
|
|
202
208
|
lead: { account: leadAccount, contracts: leadContracts },
|
|
203
209
|
followers: followers.map(f => ({ account: f, contracts: followerContracts })),
|
|
204
210
|
contract,
|
|
211
|
+
strategy,
|
|
205
212
|
dailyTarget,
|
|
206
213
|
maxRisk,
|
|
207
214
|
showNames,
|
|
@@ -209,6 +216,34 @@ const copyTradingMenu = async () => {
|
|
|
209
216
|
});
|
|
210
217
|
};
|
|
211
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Select trading strategy
|
|
221
|
+
*/
|
|
222
|
+
const selectStrategy = async () => {
|
|
223
|
+
console.log();
|
|
224
|
+
console.log(chalk.cyan(' Select Strategy'));
|
|
225
|
+
console.log();
|
|
226
|
+
|
|
227
|
+
const strategies = getAvailableStrategies();
|
|
228
|
+
|
|
229
|
+
const options = strategies.map(s => ({
|
|
230
|
+
label: `${s.name} (${s.backtest.winRate} WR, R:R ${s.params.riskReward})`,
|
|
231
|
+
value: s
|
|
232
|
+
}));
|
|
233
|
+
options.push({ label: chalk.gray('< Back'), value: 'back' });
|
|
234
|
+
|
|
235
|
+
// Show strategy details
|
|
236
|
+
for (const s of strategies) {
|
|
237
|
+
console.log(chalk.white(` ${s.name}`));
|
|
238
|
+
console.log(chalk.gray(` Backtest: ${s.backtest.pnl} | ${s.backtest.winRate} WR | ${s.backtest.trades} trades`));
|
|
239
|
+
console.log(chalk.gray(` Stop: ${s.params.stopTicks} ticks | Target: ${s.params.targetTicks} ticks | R:R ${s.params.riskReward}`));
|
|
240
|
+
console.log();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const selected = await prompts.selectOption(chalk.yellow('Select Strategy:'), options);
|
|
244
|
+
return selected === 'back' || selected === null ? null : selected;
|
|
245
|
+
};
|
|
246
|
+
|
|
212
247
|
/**
|
|
213
248
|
* Symbol selection - sorted with popular indices first
|
|
214
249
|
*/
|