hedgequantx 2.6.129 → 2.6.130
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/pages/algo/one-account.js +41 -15
package/package.json
CHANGED
|
@@ -181,17 +181,18 @@ const selectSymbol = async (service, account, allowMultiple = false) => {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
// Multi-symbol selection mode
|
|
184
|
+
// Each contract will have a 'qty' property for number of contracts
|
|
184
185
|
const selectedContracts = [];
|
|
185
186
|
|
|
186
187
|
while (selectedContracts.length < MAX_MULTI_SYMBOLS) {
|
|
187
188
|
console.log();
|
|
188
189
|
|
|
189
|
-
// Show already selected symbols
|
|
190
|
+
// Show already selected symbols with quantities
|
|
190
191
|
if (selectedContracts.length > 0) {
|
|
191
192
|
console.log(chalk.cyan(` SELECTED (${selectedContracts.length}/${MAX_MULTI_SYMBOLS}):`));
|
|
192
193
|
selectedContracts.forEach((c, i) => {
|
|
193
194
|
const name = c.name || c.symbol;
|
|
194
|
-
console.log(chalk.green(` ${i + 1}. ${name}`));
|
|
195
|
+
console.log(chalk.green(` ${i + 1}. ${name} x${c.qty}`));
|
|
195
196
|
});
|
|
196
197
|
console.log();
|
|
197
198
|
}
|
|
@@ -225,6 +226,13 @@ const selectSymbol = async (service, account, allowMultiple = false) => {
|
|
|
225
226
|
|
|
226
227
|
if (choice === 'done') break;
|
|
227
228
|
|
|
229
|
+
// Ask for number of contracts for this symbol
|
|
230
|
+
const symbolName = choice.name || choice.symbol;
|
|
231
|
+
const qty = await prompts.numberInput(`CONTRACTS FOR ${symbolName}:`, 1, 1, 10);
|
|
232
|
+
if (qty === null) continue; // User cancelled, don't add symbol
|
|
233
|
+
|
|
234
|
+
// Add qty to contract object
|
|
235
|
+
choice.qty = qty;
|
|
228
236
|
selectedContracts.push(choice);
|
|
229
237
|
|
|
230
238
|
if (selectedContracts.length >= MAX_MULTI_SYMBOLS) {
|
|
@@ -243,21 +251,29 @@ const selectSymbol = async (service, account, allowMultiple = false) => {
|
|
|
243
251
|
*/
|
|
244
252
|
const configureAlgo = async (account, contractOrContracts) => {
|
|
245
253
|
const contractList = Array.isArray(contractOrContracts) ? contractOrContracts : [contractOrContracts];
|
|
254
|
+
const isMultiSymbol = contractList.length > 1;
|
|
246
255
|
|
|
247
256
|
console.log();
|
|
248
257
|
console.log(chalk.cyan(' CONFIGURE ALGO PARAMETERS'));
|
|
249
258
|
|
|
250
|
-
// Show selected symbols
|
|
251
|
-
if (
|
|
259
|
+
// Show selected symbols with quantities (multi-symbol mode)
|
|
260
|
+
if (isMultiSymbol) {
|
|
252
261
|
console.log(chalk.white(` Trading ${contractList.length} symbols:`));
|
|
253
262
|
contractList.forEach((c, i) => {
|
|
254
|
-
|
|
263
|
+
const name = c.name || c.symbol;
|
|
264
|
+
const qty = c.qty || 1;
|
|
265
|
+
console.log(chalk.yellow(` ${i + 1}. ${name} x${qty}`));
|
|
255
266
|
});
|
|
256
267
|
}
|
|
257
268
|
console.log();
|
|
258
269
|
|
|
259
|
-
|
|
260
|
-
|
|
270
|
+
// Only ask for contracts in single-symbol mode
|
|
271
|
+
// In multi-symbol mode, qty is already set per symbol
|
|
272
|
+
let contracts = 1;
|
|
273
|
+
if (!isMultiSymbol) {
|
|
274
|
+
contracts = await prompts.numberInput('NUMBER OF CONTRACTS:', 1, 1, 10);
|
|
275
|
+
if (contracts === null) return null;
|
|
276
|
+
}
|
|
261
277
|
|
|
262
278
|
const dailyTarget = await prompts.numberInput('DAILY TARGET ($):', 1000, 1, 10000);
|
|
263
279
|
if (dailyTarget === null) return null;
|
|
@@ -1393,27 +1409,33 @@ const launchAlgo = async (service, account, contract, config) => {
|
|
|
1393
1409
|
* @param {Object} config - Algo configuration
|
|
1394
1410
|
*/
|
|
1395
1411
|
const launchMultiSymbolRithmic = async (service, account, contracts, config) => {
|
|
1396
|
-
const {
|
|
1412
|
+
const { dailyTarget, maxRisk, showName, enableAI } = config;
|
|
1397
1413
|
|
|
1398
1414
|
const accountName = showName
|
|
1399
1415
|
? (account.accountName || account.rithmicAccountId || account.accountId)
|
|
1400
1416
|
: 'HQX *****';
|
|
1401
1417
|
const rithmicAccountId = account.rithmicAccountId || account.accountId;
|
|
1402
1418
|
|
|
1403
|
-
// Build symbols string for UI
|
|
1404
|
-
const
|
|
1405
|
-
|
|
1419
|
+
// Build symbols string for UI (with quantities)
|
|
1420
|
+
const symbolsDisplay = contracts.map(c => {
|
|
1421
|
+
const name = c.name || c.symbol;
|
|
1422
|
+
const qty = c.qty || 1;
|
|
1423
|
+
return `${name}x${qty}`;
|
|
1424
|
+
}).join(', ');
|
|
1406
1425
|
|
|
1407
1426
|
const ui = new AlgoUI({
|
|
1408
1427
|
subtitle: `MULTI-SYMBOL (${contracts.length})`,
|
|
1409
1428
|
mode: 'one-account'
|
|
1410
1429
|
});
|
|
1411
1430
|
|
|
1431
|
+
// Calculate total qty across all symbols
|
|
1432
|
+
const totalQty = contracts.reduce((sum, c) => sum + (c.qty || 1), 0);
|
|
1433
|
+
|
|
1412
1434
|
// Shared stats (same structure as launchAlgo)
|
|
1413
1435
|
const stats = {
|
|
1414
1436
|
accountName,
|
|
1415
1437
|
symbol: symbolsDisplay,
|
|
1416
|
-
qty,
|
|
1438
|
+
qty: totalQty,
|
|
1417
1439
|
target: dailyTarget,
|
|
1418
1440
|
risk: maxRisk,
|
|
1419
1441
|
propfirm: account.propfirm || 'Unknown',
|
|
@@ -1463,7 +1485,7 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1463
1485
|
let stopReason = null;
|
|
1464
1486
|
let tickCount = 0;
|
|
1465
1487
|
|
|
1466
|
-
// Store contract info for later use
|
|
1488
|
+
// Store contract info for later use (including qty per symbol)
|
|
1467
1489
|
const contractInfoMap = {};
|
|
1468
1490
|
contracts.forEach(c => {
|
|
1469
1491
|
const name = c.name || c.symbol;
|
|
@@ -1472,6 +1494,7 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1472
1494
|
tickValue: c.tickValue ?? null,
|
|
1473
1495
|
contractId: c.id || c.symbol || c.name,
|
|
1474
1496
|
exchange: c.exchange || 'CME',
|
|
1497
|
+
qty: c.qty || 1, // Per-symbol quantity
|
|
1475
1498
|
};
|
|
1476
1499
|
});
|
|
1477
1500
|
|
|
@@ -1594,19 +1617,22 @@ const launchMultiSymbolRithmic = async (service, account, contracts, config) =>
|
|
|
1594
1617
|
const orderSide = direction === 'long' ? 0 : 1;
|
|
1595
1618
|
const sideStr = direction === 'long' ? 'LONG' : 'SHORT';
|
|
1596
1619
|
|
|
1620
|
+
// Use per-symbol quantity
|
|
1621
|
+
const symbolQty = contractInfoMap[symbolName].qty;
|
|
1622
|
+
|
|
1597
1623
|
// Calculate risk amount
|
|
1598
1624
|
const kelly = Math.min(0.25, confidence || 0.15);
|
|
1599
1625
|
const riskAmount = Math.round(maxRisk * kelly);
|
|
1600
1626
|
const riskPct = Math.round((riskAmount / maxRisk) * 100);
|
|
1601
1627
|
|
|
1602
1628
|
pendingOrders[symbolName] = true;
|
|
1603
|
-
ui.addLog('entry', `[${symbolName}] ${sideStr} ${
|
|
1629
|
+
ui.addLog('entry', `[${symbolName}] ${sideStr} ${symbolQty}x | risk: $${riskAmount} (${riskPct}%)`);
|
|
1604
1630
|
|
|
1605
1631
|
const orderData = {
|
|
1606
1632
|
accountId: rithmicAccountId,
|
|
1607
1633
|
symbol: symbolName,
|
|
1608
1634
|
exchange: contractInfoMap[symbolName].exchange,
|
|
1609
|
-
size:
|
|
1635
|
+
size: symbolQty,
|
|
1610
1636
|
side: orderSide,
|
|
1611
1637
|
};
|
|
1612
1638
|
|