hedgequantx 2.9.242 → 2.9.244
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
|
@@ -309,14 +309,13 @@ async function startDaemonBackground() {
|
|
|
309
309
|
// Install daemon to isolated directory first
|
|
310
310
|
const installed = installDaemon();
|
|
311
311
|
if (!installed) {
|
|
312
|
-
log.
|
|
313
|
-
return
|
|
312
|
+
log.warn('Failed to install daemon to isolated dir, using direct mode');
|
|
313
|
+
return startDaemonDirect();
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
// Check if isolated daemon entry exists
|
|
317
317
|
if (!fs.existsSync(DAEMON_ENTRY)) {
|
|
318
|
-
log.
|
|
319
|
-
// Fallback to direct execution
|
|
318
|
+
log.warn('Daemon entry not found, using direct mode', { path: DAEMON_ENTRY });
|
|
320
319
|
return startDaemonDirect();
|
|
321
320
|
}
|
|
322
321
|
|
|
@@ -338,7 +337,7 @@ async function startDaemonBackground() {
|
|
|
338
337
|
let attempts = 0;
|
|
339
338
|
const maxAttempts = 30;
|
|
340
339
|
|
|
341
|
-
const check = setInterval(() => {
|
|
340
|
+
const check = setInterval(async () => {
|
|
342
341
|
attempts++;
|
|
343
342
|
|
|
344
343
|
if (isDaemonRunning()) {
|
|
@@ -347,8 +346,10 @@ async function startDaemonBackground() {
|
|
|
347
346
|
resolve(true);
|
|
348
347
|
} else if (attempts >= maxAttempts) {
|
|
349
348
|
clearInterval(check);
|
|
350
|
-
log.
|
|
351
|
-
|
|
349
|
+
log.warn('Isolated daemon failed to start, trying direct mode');
|
|
350
|
+
// Fallback to direct mode
|
|
351
|
+
const directResult = await startDaemonDirect();
|
|
352
|
+
resolve(directResult);
|
|
352
353
|
}
|
|
353
354
|
}, 100);
|
|
354
355
|
});
|
|
@@ -222,19 +222,20 @@ const handleNewOrderResponse = (service, data) => {
|
|
|
222
222
|
debug('New order response:', JSON.stringify(res));
|
|
223
223
|
|
|
224
224
|
// Emit as orderNotification for the placeOrder listener
|
|
225
|
-
if
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
225
|
+
// Even if no basketId, emit for rejection handling
|
|
226
|
+
const isRejected = res.rpCode?.[0] !== '0';
|
|
227
|
+
const order = {
|
|
228
|
+
basketId: res.basketId || res.orderId || res.userMsg?.[0] || 'unknown',
|
|
229
|
+
accountId: res.accountId,
|
|
230
|
+
symbol: res.symbol,
|
|
231
|
+
exchange: res.exchange || 'CME',
|
|
232
|
+
status: isRejected ? 5 : 2, // 2=Working, 5=Rejected
|
|
233
|
+
notifyType: isRejected ? 0 : 1, // 1=Accepted
|
|
234
|
+
rpCode: res.rpCode,
|
|
235
|
+
rqHandlerRpCode: res.rqHandlerRpCode, // Also include request handler response code
|
|
236
|
+
userMsg: res.userMsg,
|
|
237
|
+
};
|
|
238
|
+
service.emit('orderNotification', order);
|
|
238
239
|
|
|
239
240
|
// Also emit specific event
|
|
240
241
|
service.emit('newOrderResponse', res);
|
|
@@ -145,18 +145,27 @@ const placeOrder = async (service, orderData) => {
|
|
|
145
145
|
orderTag,
|
|
146
146
|
});
|
|
147
147
|
} else if (status === 5 || status === 6) {
|
|
148
|
-
// Extract rejection reason from rpCode[1]
|
|
148
|
+
// Extract rejection reason from rpCode[1] or rqHandlerRpCode[1]
|
|
149
149
|
const rpCode = order.rpCode;
|
|
150
|
+
const rqCode = order.rqHandlerRpCode;
|
|
150
151
|
let errorMsg = `Order rejected: status ${status}`;
|
|
152
|
+
|
|
153
|
+
// Try rpCode first, then rqHandlerRpCode
|
|
151
154
|
if (rpCode && Array.isArray(rpCode) && rpCode.length > 1 && rpCode[1]) {
|
|
152
|
-
errorMsg = `
|
|
155
|
+
errorMsg = `Rejected: ${rpCode[1]}`;
|
|
156
|
+
} else if (rqCode && Array.isArray(rqCode) && rqCode.length > 1 && rqCode[1]) {
|
|
157
|
+
errorMsg = `Rejected: ${rqCode[1]}`;
|
|
158
|
+
} else if (rpCode && Array.isArray(rpCode) && rpCode[0] && rpCode[0] !== '0') {
|
|
159
|
+
errorMsg = `Rejected: code ${rpCode[0]}`;
|
|
153
160
|
}
|
|
161
|
+
|
|
154
162
|
resolve({
|
|
155
163
|
success: false,
|
|
156
164
|
error: errorMsg,
|
|
157
165
|
orderId: order.basketId,
|
|
158
166
|
orderTag,
|
|
159
167
|
rpCode,
|
|
168
|
+
rqHandlerRpCode: rqCode,
|
|
160
169
|
});
|
|
161
170
|
}
|
|
162
171
|
}
|