Explorar el Código

Handle Pacifica cancel validation errors

helium3@sina.com hace 2 meses
padre
commit
ce064a8101

+ 1 - 1
packages/connectors/pacifica/src/adapter.ts

@@ -277,7 +277,7 @@ export class PacificaAdapter {
       }
     });
 
-    if (json.cancelled && !json.cancelled.includes(orderId)) {
+    if (json.cancelled && !json.cancelled.map(entry => String(entry)).includes(orderId)) {
       throw new PacificaApiError("Order cancel not acknowledged", {
         status: 200,
         payload: json

+ 4 - 1
packages/strategies/src/gridMaker.ts

@@ -1314,11 +1314,14 @@ function normalizeError(error: unknown): { message?: string; name?: string; stat
   return { message: String(error) };
 }
 
-function isIgnorableCancelError(error?: { status?: number; code?: string }): boolean {
+function isIgnorableCancelError(error?: { status?: number; code?: string; name?: string; message?: string }): boolean {
   if (!error) return false;
   if (error.status === 404) return true;
   if (error.status === 422 && (error.code === '5' || error.code === 'order_not_active')) {
     return true;
   }
+  if (error.status === 400 && (error.name === 'PacificaValidationError' || error.message?.toLowerCase().includes('invalid message'))) {
+    return true;
+  }
   return false;
 }