hedgequantx 2.9.33 → 2.9.35
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
CHANGED
|
@@ -39,7 +39,10 @@ const copyTradingMenu = async () => {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
// Filter active accounts: status === 0 (ProjectX) OR status === 'active' (Rithmic) OR no status
|
|
43
|
+
const activeAccounts = allAccounts.filter(acc =>
|
|
44
|
+
acc.status === 0 || acc.status === 'active' || acc.status === undefined || acc.status === null
|
|
45
|
+
);
|
|
43
46
|
|
|
44
47
|
if (activeAccounts.length < 2) {
|
|
45
48
|
spinner.fail(`Need at least 2 active accounts (found: ${activeAccounts.length})`);
|
|
@@ -46,7 +46,10 @@ const customStrategyMenu = async (service) => {
|
|
|
46
46
|
|
|
47
47
|
if (!allAccounts?.length) { spinner.fail('No accounts found'); await prompts.waitForEnter(); return; }
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
// Filter active accounts: status === 0 (ProjectX) OR status === 'active' (Rithmic) OR no status
|
|
50
|
+
const activeAccounts = allAccounts.filter(acc =>
|
|
51
|
+
acc.status === 0 || acc.status === 'active' || acc.status === undefined || acc.status === null
|
|
52
|
+
);
|
|
50
53
|
if (!activeAccounts.length) { spinner.fail('No active accounts'); await prompts.waitForEnter(); return; }
|
|
51
54
|
|
|
52
55
|
spinner.succeed(`Found ${activeAccounts.length} active account(s)`);
|
|
@@ -40,7 +40,10 @@ const oneAccountMenu = async (service) => {
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// Filter active accounts: status === 0 (ProjectX) OR status === 'active' (Rithmic) OR no status
|
|
44
|
+
const activeAccounts = allAccounts.filter(acc =>
|
|
45
|
+
acc.status === 0 || acc.status === 'active' || acc.status === undefined || acc.status === null
|
|
46
|
+
);
|
|
44
47
|
|
|
45
48
|
if (!activeAccounts.length) {
|
|
46
49
|
spinner.fail('No active accounts');
|
|
@@ -292,33 +292,64 @@ const getOrderHistory = async (service, date) => {
|
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
/**
|
|
295
|
-
* Get full trade history
|
|
295
|
+
* Get full trade history (fills) from ORDER_PLANT
|
|
296
296
|
* @param {RithmicService} service - The Rithmic service instance
|
|
297
|
-
* @param {number} days - Number of days to fetch (default
|
|
297
|
+
* @param {number} days - Number of days to fetch (default 7, max 14)
|
|
298
298
|
* @returns {Promise<{success: boolean, trades: Array}>}
|
|
299
299
|
*/
|
|
300
|
-
const getTradeHistoryFull = async (service, days =
|
|
300
|
+
const getTradeHistoryFull = async (service, days = 7) => {
|
|
301
301
|
if (!service.orderConn || !service.loginInfo) {
|
|
302
302
|
return { success: false, trades: [] };
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
// Get available dates
|
|
306
|
-
|
|
305
|
+
// Get available dates with timeout
|
|
306
|
+
let dates;
|
|
307
|
+
try {
|
|
308
|
+
const datesPromise = getOrderHistoryDates(service);
|
|
309
|
+
const timeoutPromise = new Promise((_, reject) =>
|
|
310
|
+
setTimeout(() => reject(new Error('Timeout')), 5000)
|
|
311
|
+
);
|
|
312
|
+
const result = await Promise.race([datesPromise, timeoutPromise]);
|
|
313
|
+
dates = result.dates;
|
|
314
|
+
} catch (e) {
|
|
315
|
+
return { success: true, trades: [] };
|
|
316
|
+
}
|
|
317
|
+
|
|
307
318
|
if (!dates || dates.length === 0) {
|
|
308
319
|
return { success: true, trades: [] };
|
|
309
320
|
}
|
|
310
321
|
|
|
311
|
-
//
|
|
312
|
-
const
|
|
322
|
+
// Filter to recent dates only (last N days from today)
|
|
323
|
+
const today = new Date();
|
|
324
|
+
const cutoffDate = new Date(today.getTime() - (Math.min(days, 14) * 24 * 60 * 60 * 1000));
|
|
325
|
+
const cutoffStr = cutoffDate.toISOString().slice(0, 10).replace(/-/g, '');
|
|
326
|
+
|
|
327
|
+
// Sort dates descending and filter to recent only
|
|
328
|
+
const recentDates = dates
|
|
329
|
+
.filter(d => d >= cutoffStr)
|
|
330
|
+
.sort((a, b) => b.localeCompare(a))
|
|
331
|
+
.slice(0, 7); // Max 7 dates to avoid long waits
|
|
332
|
+
|
|
333
|
+
if (recentDates.length === 0) {
|
|
334
|
+
return { success: true, trades: [] };
|
|
335
|
+
}
|
|
313
336
|
|
|
314
337
|
const allTrades = [];
|
|
315
338
|
|
|
316
|
-
// Fetch history for each date
|
|
317
|
-
for (const date of
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
339
|
+
// Fetch history for each date with short timeout
|
|
340
|
+
for (const date of recentDates) {
|
|
341
|
+
try {
|
|
342
|
+
const histPromise = getOrderHistory(service, date);
|
|
343
|
+
const timeoutPromise = new Promise((resolve) =>
|
|
344
|
+
setTimeout(() => resolve({ orders: [] }), 3000)
|
|
345
|
+
);
|
|
346
|
+
const { orders } = await Promise.race([histPromise, timeoutPromise]);
|
|
347
|
+
// Filter only fills (notifyType 5)
|
|
348
|
+
const fills = (orders || []).filter(o => o.notifyType === 5 || o.fillPrice);
|
|
349
|
+
allTrades.push(...fills);
|
|
350
|
+
} catch (e) {
|
|
351
|
+
// Skip failed dates
|
|
352
|
+
}
|
|
322
353
|
}
|
|
323
354
|
|
|
324
355
|
return { success: true, trades: allTrades };
|