@imbingox/acex 0.4.0-beta.11 → 0.4.0-beta.12
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
|
@@ -93,6 +93,11 @@ interface BinancePapiOpenOrder {
|
|
|
93
93
|
time?: number;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
interface BinancePapiCancelAllResponse {
|
|
97
|
+
code?: number | string;
|
|
98
|
+
msg?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
96
101
|
interface BinanceListenKeyResponse {
|
|
97
102
|
listenKey?: string;
|
|
98
103
|
}
|
|
@@ -859,21 +864,53 @@ export class BinancePrivateAdapter implements PrivateUserDataAdapter {
|
|
|
859
864
|
request: CancelAllOrdersRequest,
|
|
860
865
|
accountOptions?: Record<string, unknown>,
|
|
861
866
|
): Promise<RawOrderUpdate[]> {
|
|
862
|
-
const
|
|
863
|
-
const
|
|
867
|
+
const symbol = encodeUmSymbol(request.symbol);
|
|
868
|
+
const openOrders = await this.signedRequest<BinancePapiOpenOrder[]>(
|
|
869
|
+
"GET",
|
|
870
|
+
"/papi/v1/um/openOrders",
|
|
871
|
+
credentials,
|
|
872
|
+
accountOptions,
|
|
873
|
+
{
|
|
874
|
+
symbol,
|
|
875
|
+
},
|
|
876
|
+
SAFE_READ_RETRY_POLICY,
|
|
877
|
+
);
|
|
878
|
+
|
|
879
|
+
// Venue responds {code,msg}; returned updates are synthesized from the
|
|
880
|
+
// pre-fetch. Orders that fill between fetch and cancel are corrected by
|
|
881
|
+
// the WS terminal event / reconcile.
|
|
882
|
+
const response = await this.signedRequest<BinancePapiCancelAllResponse>(
|
|
864
883
|
"DELETE",
|
|
865
884
|
"/papi/v1/um/allOpenOrders",
|
|
866
885
|
credentials,
|
|
867
886
|
accountOptions,
|
|
868
887
|
{
|
|
869
|
-
symbol
|
|
888
|
+
symbol,
|
|
870
889
|
},
|
|
871
890
|
NO_RETRY_POLICY,
|
|
872
891
|
);
|
|
873
892
|
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
893
|
+
if (response.code !== undefined && `${response.code}` !== "200") {
|
|
894
|
+
throw new Error(
|
|
895
|
+
`Binance PAPI cancelAllOrders failed: code=${response.code}, msg=${
|
|
896
|
+
response.msg ?? ""
|
|
897
|
+
}`,
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
const receivedAt = Date.now();
|
|
902
|
+
return openOrders.flatMap((order) => {
|
|
903
|
+
const mapped = mapOpenOrder(order, receivedAt);
|
|
904
|
+
return mapped
|
|
905
|
+
? [
|
|
906
|
+
{
|
|
907
|
+
...mapped,
|
|
908
|
+
status: "canceled",
|
|
909
|
+
exchangeTs: undefined,
|
|
910
|
+
receivedAt,
|
|
911
|
+
},
|
|
912
|
+
]
|
|
913
|
+
: [];
|
|
877
914
|
});
|
|
878
915
|
}
|
|
879
916
|
|