hedgequantx 2.9.250 → 2.9.251

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.9.250",
3
+ "version": "2.9.251",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -221,19 +221,31 @@ const handleNewOrderResponse = (service, data) => {
221
221
  try {
222
222
  const res = proto.decode('ResponseNewOrder', data);
223
223
 
224
+ // Log full response for debugging
225
+ console.log('[Rithmic] ResponseNewOrder:', JSON.stringify(res));
226
+
224
227
  const isAccepted = res.rpCode?.[0] === '0';
225
228
 
226
229
  // Build rejection reason from rpCode array
227
- // rpCode is typically ['code', 'message'] or just ['code']
228
230
  let rejectReason = null;
229
- if (!isAccepted) {
230
- // Try to get the error message from rpCode[1] or rqHandlerRpCode[1]
231
- const rpMsg = res.rpCode?.slice(1).join(' ') || '';
232
- const rqMsg = res.rqHandlerRpCode?.slice(1).join(' ') || '';
233
- rejectReason = rpMsg || rqMsg || null;
231
+ if (!isAccepted && res.rpCode) {
232
+ // rpCode can be ['0'] for success or ['code', 'message', ...] for errors
233
+ // Join all parts after the code for the full message
234
+ const allCodes = Array.isArray(res.rpCode) ? res.rpCode : [res.rpCode];
235
+ const rqCodes = Array.isArray(res.rqHandlerRpCode) ? res.rqHandlerRpCode : [];
236
+
237
+ // Get message from rpCode (skip first element which is the code)
238
+ const rpMsg = allCodes.slice(1).join(' ').trim();
239
+ const rqMsg = rqCodes.slice(1).join(' ').trim();
234
240
 
235
- // If no message, interpret the code
236
- if (!rejectReason && res.rpCode?.[0]) {
241
+ // Use the message if available
242
+ if (rpMsg) {
243
+ rejectReason = rpMsg;
244
+ } else if (rqMsg) {
245
+ rejectReason = rqMsg;
246
+ } else {
247
+ // Map numeric codes to messages
248
+ const code = allCodes[0];
237
249
  const codeMap = {
238
250
  '1': 'Invalid request',
239
251
  '2': 'Invalid account',
@@ -245,17 +257,17 @@ const handleNewOrderResponse = (service, data) => {
245
257
  '8': 'Position limit exceeded',
246
258
  '9': 'Rate limit exceeded',
247
259
  };
248
- rejectReason = codeMap[res.rpCode[0]] || `Gateway rejected (code: ${res.rpCode[0]})`;
260
+ rejectReason = codeMap[code] || `Gateway rejected (code: ${code})`;
249
261
  }
250
262
 
251
- console.log('[Rithmic] Gateway rejection:', rejectReason, '| rpCode:', res.rpCode, '| rqHandlerRpCode:', res.rqHandlerRpCode);
263
+ console.log('[Rithmic] Order REJECTED:', rejectReason);
252
264
  }
253
265
 
254
266
  const order = {
255
267
  basketId: res.basketId || null,
256
268
  symbol: res.symbol,
257
269
  exchange: res.exchange || 'CME',
258
- notifyType: isAccepted ? 1 : 6, // 1=STATUS (accepted), 6=REJECT
270
+ notifyType: isAccepted ? 1 : 6,
259
271
  status: isAccepted ? 2 : 6,
260
272
  text: rejectReason,
261
273
  rpCode: res.rpCode,