ccxt 4.3.56 → 4.3.57
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/README.md +3 -3
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/ws/Client.js +34 -4
- package/dist/cjs/src/bingx.js +48 -8
- package/dist/cjs/src/bitget.js +56 -47
- package/dist/cjs/src/coinone.js +13 -19
- package/dist/cjs/src/gate.js +108 -1
- package/dist/cjs/src/htx.js +88 -25
- package/dist/cjs/src/huobijp.js +65 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/ws/Client.d.ts +2 -0
- package/js/src/base/ws/Client.js +34 -4
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +48 -8
- package/js/src/bitget.d.ts +1 -1
- package/js/src/bitget.js +56 -47
- package/js/src/coinone.js +13 -19
- package/js/src/gate.d.ts +3 -1
- package/js/src/gate.js +108 -1
- package/js/src/htx.d.ts +3 -2
- package/js/src/htx.js +88 -25
- package/js/src/huobijp.d.ts +3 -2
- package/js/src/huobijp.js +65 -2
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -190,7 +190,7 @@ var woofipro$1 = require('./src/pro/woofipro.js');
|
|
|
190
190
|
|
|
191
191
|
//-----------------------------------------------------------------------------
|
|
192
192
|
// this is updated by vss.js when building
|
|
193
|
-
const version = '4.3.
|
|
193
|
+
const version = '4.3.57';
|
|
194
194
|
Exchange["default"].ccxtVersion = version;
|
|
195
195
|
const exchanges = {
|
|
196
196
|
'ace': ace,
|
|
@@ -12,6 +12,7 @@ var index = require('../../static_dependencies/scure-base/index.js');
|
|
|
12
12
|
|
|
13
13
|
class Client {
|
|
14
14
|
constructor(url, onMessageCallback, onErrorCallback, onCloseCallback, onConnectedCallback, config = {}) {
|
|
15
|
+
this.useMessageQueue = true;
|
|
15
16
|
this.verbose = false;
|
|
16
17
|
const defaults = {
|
|
17
18
|
url,
|
|
@@ -25,6 +26,8 @@ class Client {
|
|
|
25
26
|
futures: {},
|
|
26
27
|
subscriptions: {},
|
|
27
28
|
rejections: {},
|
|
29
|
+
messageQueue: {},
|
|
30
|
+
useMessageQueue: true,
|
|
28
31
|
connected: undefined,
|
|
29
32
|
error: undefined,
|
|
30
33
|
connectionStarted: undefined,
|
|
@@ -55,6 +58,15 @@ class Client {
|
|
|
55
58
|
if (messageHash in this.rejections) {
|
|
56
59
|
future.reject(this.rejections[messageHash]);
|
|
57
60
|
delete this.rejections[messageHash];
|
|
61
|
+
delete this.messageQueue[messageHash];
|
|
62
|
+
return future;
|
|
63
|
+
}
|
|
64
|
+
if (this.useMessageQueue) {
|
|
65
|
+
const queue = this.messageQueue[messageHash];
|
|
66
|
+
if (queue && queue.length) {
|
|
67
|
+
future.resolve(queue.shift());
|
|
68
|
+
delete this.futures[messageHash];
|
|
69
|
+
}
|
|
58
70
|
}
|
|
59
71
|
return future;
|
|
60
72
|
}
|
|
@@ -62,10 +74,27 @@ class Client {
|
|
|
62
74
|
if (this.verbose && (messageHash === undefined)) {
|
|
63
75
|
this.log(new Date(), 'resolve received undefined messageHash');
|
|
64
76
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
if (this.useMessageQueue === true) {
|
|
78
|
+
if (!(messageHash in this.messageQueue)) {
|
|
79
|
+
this.messageQueue[messageHash] = [];
|
|
80
|
+
}
|
|
81
|
+
const queue = this.messageQueue[messageHash];
|
|
82
|
+
queue.push(result);
|
|
83
|
+
while (queue.length > 10) { // limit size to 10 messages in the queue
|
|
84
|
+
queue.shift();
|
|
85
|
+
}
|
|
86
|
+
if ((messageHash !== undefined) && (messageHash in this.futures)) {
|
|
87
|
+
const promise = this.futures[messageHash];
|
|
88
|
+
promise.resolve(queue.shift());
|
|
89
|
+
delete this.futures[messageHash];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (messageHash in this.futures) {
|
|
94
|
+
const promise = this.futures[messageHash];
|
|
95
|
+
promise.resolve(result);
|
|
96
|
+
delete this.futures[messageHash];
|
|
97
|
+
}
|
|
69
98
|
}
|
|
70
99
|
return result;
|
|
71
100
|
}
|
|
@@ -106,6 +135,7 @@ class Client {
|
|
|
106
135
|
reset(error) {
|
|
107
136
|
this.clearConnectionTimeout();
|
|
108
137
|
this.clearPingInterval();
|
|
138
|
+
this.messageQueue = {};
|
|
109
139
|
this.reject(error);
|
|
110
140
|
}
|
|
111
141
|
onConnectionTimeout() {
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -669,6 +669,29 @@ class bingx extends bingx$1 {
|
|
|
669
669
|
const markets = this.safeList(response, 'data', []);
|
|
670
670
|
return this.parseMarkets(markets);
|
|
671
671
|
}
|
|
672
|
+
async fetchInverseSwapMarkets(params) {
|
|
673
|
+
const response = await this.cswapV1PublicGetMarketContracts(params);
|
|
674
|
+
//
|
|
675
|
+
// {
|
|
676
|
+
// "code": 0,
|
|
677
|
+
// "msg": "",
|
|
678
|
+
// "timestamp": 1720074487610,
|
|
679
|
+
// "data": [
|
|
680
|
+
// {
|
|
681
|
+
// "symbol": "BNB-USD",
|
|
682
|
+
// "pricePrecision": 2,
|
|
683
|
+
// "minTickSize": "10",
|
|
684
|
+
// "minTradeValue": "10",
|
|
685
|
+
// "minQty": "1.00000000",
|
|
686
|
+
// "status": 1,
|
|
687
|
+
// "timeOnline": 1713175200000
|
|
688
|
+
// },
|
|
689
|
+
// ]
|
|
690
|
+
// }
|
|
691
|
+
//
|
|
692
|
+
const markets = this.safeList(response, 'data', []);
|
|
693
|
+
return this.parseMarkets(markets);
|
|
694
|
+
}
|
|
672
695
|
parseMarket(market) {
|
|
673
696
|
const id = this.safeString(market, 'symbol');
|
|
674
697
|
const symbolParts = id.split('-');
|
|
@@ -676,7 +699,16 @@ class bingx extends bingx$1 {
|
|
|
676
699
|
const quoteId = symbolParts[1];
|
|
677
700
|
const base = this.safeCurrencyCode(baseId);
|
|
678
701
|
const quote = this.safeCurrencyCode(quoteId);
|
|
679
|
-
|
|
702
|
+
let currency = this.safeString(market, 'currency');
|
|
703
|
+
let checkIsInverse = false;
|
|
704
|
+
let checkIsLinear = true;
|
|
705
|
+
const minTickSize = this.safeNumber(market, 'minTickSize');
|
|
706
|
+
if (minTickSize !== undefined) {
|
|
707
|
+
// inverse swap market
|
|
708
|
+
currency = baseId;
|
|
709
|
+
checkIsInverse = true;
|
|
710
|
+
checkIsLinear = false;
|
|
711
|
+
}
|
|
680
712
|
const settle = this.safeCurrencyCode(currency);
|
|
681
713
|
let pricePrecision = this.safeNumber(market, 'tickSize');
|
|
682
714
|
if (pricePrecision === undefined) {
|
|
@@ -696,8 +728,12 @@ class bingx extends bingx$1 {
|
|
|
696
728
|
const fees = this.safeDict(this.fees, type, {});
|
|
697
729
|
const contractSize = (swap) ? this.parseNumber('1') : undefined;
|
|
698
730
|
const isActive = this.safeString(market, 'status') === '1';
|
|
699
|
-
const isInverse = (spot) ? undefined :
|
|
700
|
-
const isLinear = (spot) ? undefined :
|
|
731
|
+
const isInverse = (spot) ? undefined : checkIsInverse;
|
|
732
|
+
const isLinear = (spot) ? undefined : checkIsLinear;
|
|
733
|
+
let timeOnline = this.safeInteger(market, 'timeOnline');
|
|
734
|
+
if (timeOnline === 0) {
|
|
735
|
+
timeOnline = undefined;
|
|
736
|
+
}
|
|
701
737
|
return this.safeMarketStructure({
|
|
702
738
|
'id': id,
|
|
703
739
|
'symbol': symbol,
|
|
@@ -739,15 +775,15 @@ class bingx extends bingx$1 {
|
|
|
739
775
|
'max': this.safeNumber(market, 'maxQty'),
|
|
740
776
|
},
|
|
741
777
|
'price': {
|
|
742
|
-
'min':
|
|
778
|
+
'min': minTickSize,
|
|
743
779
|
'max': undefined,
|
|
744
780
|
},
|
|
745
781
|
'cost': {
|
|
746
|
-
'min': this.
|
|
782
|
+
'min': this.safeNumberN(market, ['minNotional', 'tradeMinUSDT', 'minTradeValue']),
|
|
747
783
|
'max': this.safeNumber(market, 'maxNotional'),
|
|
748
784
|
},
|
|
749
785
|
},
|
|
750
|
-
'created':
|
|
786
|
+
'created': timeOnline,
|
|
751
787
|
'info': market,
|
|
752
788
|
});
|
|
753
789
|
}
|
|
@@ -758,17 +794,21 @@ class bingx extends bingx$1 {
|
|
|
758
794
|
* @description retrieves data on all markets for bingx
|
|
759
795
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20Symbols
|
|
760
796
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Contract%20Information
|
|
797
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Contract%20Information
|
|
761
798
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
762
799
|
* @returns {object[]} an array of objects representing market data
|
|
763
800
|
*/
|
|
764
801
|
const requests = [this.fetchSwapMarkets(params)];
|
|
765
802
|
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
766
803
|
if (!isSandbox) {
|
|
804
|
+
requests.push(this.fetchInverseSwapMarkets(params));
|
|
767
805
|
requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
|
|
768
806
|
}
|
|
769
807
|
const promises = await Promise.all(requests);
|
|
770
|
-
const
|
|
771
|
-
const
|
|
808
|
+
const linearSwapMarkets = this.safeList(promises, 0, []);
|
|
809
|
+
const inverseSwapMarkets = this.safeList(promises, 1, []);
|
|
810
|
+
const spotMarkets = this.safeList(promises, 2, []);
|
|
811
|
+
const swapMarkets = this.arrayConcat(linearSwapMarkets, inverseSwapMarkets);
|
|
772
812
|
return this.arrayConcat(spotMarkets, swapMarkets);
|
|
773
813
|
}
|
|
774
814
|
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -5012,6 +5012,22 @@ class bitget extends bitget$1 {
|
|
|
5012
5012
|
else {
|
|
5013
5013
|
response = await this.privateMarginPostMarginV1IsolatedOrderBatchCancelOrder(this.extend(request, params));
|
|
5014
5014
|
}
|
|
5015
|
+
//
|
|
5016
|
+
// {
|
|
5017
|
+
// "code": "00000",
|
|
5018
|
+
// "msg": "success",
|
|
5019
|
+
// "requestTime": 1700717155622,
|
|
5020
|
+
// "data": {
|
|
5021
|
+
// "resultList": [
|
|
5022
|
+
// {
|
|
5023
|
+
// "orderId": "1111453253721796609",
|
|
5024
|
+
// "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
|
|
5025
|
+
// },
|
|
5026
|
+
// ],
|
|
5027
|
+
// "failure": []
|
|
5028
|
+
// }
|
|
5029
|
+
// }
|
|
5030
|
+
//
|
|
5015
5031
|
}
|
|
5016
5032
|
else {
|
|
5017
5033
|
if (stop) {
|
|
@@ -5023,6 +5039,27 @@ class bitget extends bitget$1 {
|
|
|
5023
5039
|
else {
|
|
5024
5040
|
response = await this.privateSpotPostV2SpotTradeCancelSymbolOrder(this.extend(request, params));
|
|
5025
5041
|
}
|
|
5042
|
+
//
|
|
5043
|
+
// {
|
|
5044
|
+
// "code": "00000",
|
|
5045
|
+
// "msg": "success",
|
|
5046
|
+
// "requestTime": 1700716953996,
|
|
5047
|
+
// "data": {
|
|
5048
|
+
// "symbol": "BTCUSDT"
|
|
5049
|
+
// }
|
|
5050
|
+
// }
|
|
5051
|
+
//
|
|
5052
|
+
const timestamp = this.safeInteger(response, 'requestTime');
|
|
5053
|
+
const responseData = this.safeDict(response, 'data');
|
|
5054
|
+
const marketId = this.safeString(responseData, 'symbol');
|
|
5055
|
+
return [
|
|
5056
|
+
this.safeOrder({
|
|
5057
|
+
'info': response,
|
|
5058
|
+
'symbol': this.safeSymbol(marketId, undefined, undefined, 'spot'),
|
|
5059
|
+
'timestamp': timestamp,
|
|
5060
|
+
'datetime': this.iso8601(timestamp),
|
|
5061
|
+
}),
|
|
5062
|
+
];
|
|
5026
5063
|
}
|
|
5027
5064
|
}
|
|
5028
5065
|
else {
|
|
@@ -5035,54 +5072,26 @@ class bitget extends bitget$1 {
|
|
|
5035
5072
|
else {
|
|
5036
5073
|
response = await this.privateMixPostV2MixOrderBatchCancelOrders(this.extend(request, params));
|
|
5037
5074
|
}
|
|
5075
|
+
// {
|
|
5076
|
+
// "code": "00000",
|
|
5077
|
+
// "msg": "success",
|
|
5078
|
+
// "requestTime": "1680008815965",
|
|
5079
|
+
// "data": {
|
|
5080
|
+
// "successList": [
|
|
5081
|
+
// {
|
|
5082
|
+
// "orderId": "1024598257429823488",
|
|
5083
|
+
// "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
|
|
5084
|
+
// },
|
|
5085
|
+
// ],
|
|
5086
|
+
// "failureList": []
|
|
5087
|
+
// }
|
|
5088
|
+
// }
|
|
5038
5089
|
}
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
// "msg": "success",
|
|
5045
|
-
// "requestTime": 1700716953996,
|
|
5046
|
-
// "data": {
|
|
5047
|
-
// "symbol": "BTCUSDT"
|
|
5048
|
-
// }
|
|
5049
|
-
// }
|
|
5050
|
-
//
|
|
5051
|
-
// swap
|
|
5052
|
-
//
|
|
5053
|
-
// {
|
|
5054
|
-
// "code": "00000",
|
|
5055
|
-
// "msg": "success",
|
|
5056
|
-
// "requestTime": "1680008815965",
|
|
5057
|
-
// "data": {
|
|
5058
|
-
// "successList": [
|
|
5059
|
-
// {
|
|
5060
|
-
// "orderId": "1024598257429823488",
|
|
5061
|
-
// "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
|
|
5062
|
-
// },
|
|
5063
|
-
// ],
|
|
5064
|
-
// "failureList": []
|
|
5065
|
-
// }
|
|
5066
|
-
// }
|
|
5067
|
-
//
|
|
5068
|
-
// spot margin
|
|
5069
|
-
//
|
|
5070
|
-
// {
|
|
5071
|
-
// "code": "00000",
|
|
5072
|
-
// "msg": "success",
|
|
5073
|
-
// "requestTime": 1700717155622,
|
|
5074
|
-
// "data": {
|
|
5075
|
-
// "resultList": [
|
|
5076
|
-
// {
|
|
5077
|
-
// "orderId": "1111453253721796609",
|
|
5078
|
-
// "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
|
|
5079
|
-
// },
|
|
5080
|
-
// ],
|
|
5081
|
-
// "failure": []
|
|
5082
|
-
// }
|
|
5083
|
-
// }
|
|
5084
|
-
//
|
|
5085
|
-
return response;
|
|
5090
|
+
const data = this.safeDict(response, 'data');
|
|
5091
|
+
const resultList = this.safeList2(data, 'resultList', 'successList');
|
|
5092
|
+
const failureList = this.safeList2(data, 'failure', 'failureList');
|
|
5093
|
+
const responseList = this.arrayConcat(resultList, failureList);
|
|
5094
|
+
return this.parseOrders(responseList);
|
|
5086
5095
|
}
|
|
5087
5096
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
5088
5097
|
/**
|
package/dist/cjs/src/coinone.js
CHANGED
|
@@ -18,8 +18,7 @@ class coinone extends coinone$1 {
|
|
|
18
18
|
'id': 'coinone',
|
|
19
19
|
'name': 'CoinOne',
|
|
20
20
|
'countries': ['KR'],
|
|
21
|
-
|
|
22
|
-
'rateLimit': 667,
|
|
21
|
+
'rateLimit': 50,
|
|
23
22
|
'version': 'v2',
|
|
24
23
|
'pro': false,
|
|
25
24
|
'has': {
|
|
@@ -191,10 +190,10 @@ class coinone extends coinone$1 {
|
|
|
191
190
|
},
|
|
192
191
|
'precisionMode': number.TICK_SIZE,
|
|
193
192
|
'exceptions': {
|
|
194
|
-
'405': errors.OnMaintenance,
|
|
195
193
|
'104': errors.OrderNotFound,
|
|
194
|
+
'107': errors.BadRequest,
|
|
196
195
|
'108': errors.BadSymbol,
|
|
197
|
-
'
|
|
196
|
+
'405': errors.OnMaintenance,
|
|
198
197
|
},
|
|
199
198
|
'commonCurrencies': {
|
|
200
199
|
'SOC': 'Soda Coin',
|
|
@@ -1164,22 +1163,17 @@ class coinone extends coinone$1 {
|
|
|
1164
1163
|
}
|
|
1165
1164
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1166
1165
|
if (response === undefined) {
|
|
1167
|
-
return undefined;
|
|
1168
|
-
}
|
|
1169
|
-
if ('result' in response) {
|
|
1170
|
-
const result = response['result'];
|
|
1171
|
-
if (result !== 'success') {
|
|
1172
|
-
//
|
|
1173
|
-
// { "errorCode": "405", "status": "maintenance", "result": "error"}
|
|
1174
|
-
//
|
|
1175
|
-
const errorCode = this.safeString(response, 'errorCode');
|
|
1176
|
-
const feedback = this.id + ' ' + body;
|
|
1177
|
-
this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
|
|
1178
|
-
throw new errors.ExchangeError(feedback);
|
|
1179
|
-
}
|
|
1166
|
+
return undefined; // fallback to default error handler
|
|
1180
1167
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1168
|
+
//
|
|
1169
|
+
// {"result":"error","error_code":"107","error_msg":"Parameter value is wrong"}
|
|
1170
|
+
// {"result":"error","error_code":"108","error_msg":"Unknown CryptoCurrency"}
|
|
1171
|
+
//
|
|
1172
|
+
const errorCode = this.safeString(response, 'error_code');
|
|
1173
|
+
if (errorCode !== '0') {
|
|
1174
|
+
const feedback = this.id + ' ' + body;
|
|
1175
|
+
this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
|
|
1176
|
+
throw new errors.ExchangeError(feedback); // unknown message
|
|
1183
1177
|
}
|
|
1184
1178
|
return undefined;
|
|
1185
1179
|
}
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -81,6 +81,8 @@ class gate extends gate$1 {
|
|
|
81
81
|
'borrowIsolatedMargin': true,
|
|
82
82
|
'cancelAllOrders': true,
|
|
83
83
|
'cancelOrder': true,
|
|
84
|
+
'cancelOrders': true,
|
|
85
|
+
'cancelOrdersForSymbols': true,
|
|
84
86
|
'createMarketBuyOrderWithCost': true,
|
|
85
87
|
'createMarketOrder': true,
|
|
86
88
|
'createMarketOrderWithCost': false,
|
|
@@ -4467,6 +4469,8 @@ class gate extends gate$1 {
|
|
|
4467
4469
|
// "message": "Not enough balance"
|
|
4468
4470
|
// }
|
|
4469
4471
|
//
|
|
4472
|
+
// {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
|
|
4473
|
+
//
|
|
4470
4474
|
const succeeded = this.safeBool(order, 'succeeded', true);
|
|
4471
4475
|
if (!succeeded) {
|
|
4472
4476
|
// cancelOrders response
|
|
@@ -4474,6 +4478,7 @@ class gate extends gate$1 {
|
|
|
4474
4478
|
'clientOrderId': this.safeString(order, 'text'),
|
|
4475
4479
|
'info': order,
|
|
4476
4480
|
'status': 'rejected',
|
|
4481
|
+
'id': this.safeString(order, 'id'),
|
|
4477
4482
|
});
|
|
4478
4483
|
}
|
|
4479
4484
|
const put = this.safeValue2(order, 'put', 'initial', {});
|
|
@@ -5073,6 +5078,92 @@ class gate extends gate$1 {
|
|
|
5073
5078
|
//
|
|
5074
5079
|
return this.parseOrder(response, market);
|
|
5075
5080
|
}
|
|
5081
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
5082
|
+
/**
|
|
5083
|
+
* @method
|
|
5084
|
+
* @name gate#cancelOrders
|
|
5085
|
+
* @description cancel multiple orders
|
|
5086
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
|
|
5087
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list-2
|
|
5088
|
+
* @param {string[]} ids order ids
|
|
5089
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
5090
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5091
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5092
|
+
*/
|
|
5093
|
+
await this.loadMarkets();
|
|
5094
|
+
let market = undefined;
|
|
5095
|
+
if (symbol !== undefined) {
|
|
5096
|
+
market = this.market(symbol);
|
|
5097
|
+
}
|
|
5098
|
+
let type = undefined;
|
|
5099
|
+
const defaultSettle = (market === undefined) ? 'usdt' : market['settle'];
|
|
5100
|
+
const settle = this.safeStringLower(params, 'settle', defaultSettle);
|
|
5101
|
+
[type, params] = this.handleMarketTypeAndParams('cancelOrders', market, params);
|
|
5102
|
+
const isSpot = (type === 'spot');
|
|
5103
|
+
if (isSpot && (symbol === undefined)) {
|
|
5104
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrders requires a symbol argument for spot markets');
|
|
5105
|
+
}
|
|
5106
|
+
if (isSpot) {
|
|
5107
|
+
const ordersRequests = [];
|
|
5108
|
+
for (let i = 0; i < ids.length; i++) {
|
|
5109
|
+
const id = ids[i];
|
|
5110
|
+
const orderItem = {
|
|
5111
|
+
'id': id,
|
|
5112
|
+
'symbol': symbol,
|
|
5113
|
+
};
|
|
5114
|
+
ordersRequests.push(orderItem);
|
|
5115
|
+
}
|
|
5116
|
+
return await this.cancelOrdersForSymbols(ordersRequests, params);
|
|
5117
|
+
}
|
|
5118
|
+
const request = {
|
|
5119
|
+
'settle': settle,
|
|
5120
|
+
};
|
|
5121
|
+
const finalList = [request]; // hacky but needs to be done here
|
|
5122
|
+
for (let i = 0; i < ids.length; i++) {
|
|
5123
|
+
finalList.push(ids[i]);
|
|
5124
|
+
}
|
|
5125
|
+
const response = await this.privateFuturesPostSettleBatchCancelOrders(finalList);
|
|
5126
|
+
return this.parseOrders(response);
|
|
5127
|
+
}
|
|
5128
|
+
async cancelOrdersForSymbols(orders, params = {}) {
|
|
5129
|
+
/**
|
|
5130
|
+
* @method
|
|
5131
|
+
* @name gate#cancelOrdersForSymbols
|
|
5132
|
+
* @description cancel multiple orders for multiple symbols
|
|
5133
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
|
|
5134
|
+
* @param {string[]} ids order ids
|
|
5135
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
5136
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5137
|
+
* @param {string[]} [params.clientOrderIds] client order ids
|
|
5138
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5139
|
+
*/
|
|
5140
|
+
await this.loadMarkets();
|
|
5141
|
+
const ordersRequests = [];
|
|
5142
|
+
for (let i = 0; i < orders.length; i++) {
|
|
5143
|
+
const order = orders[i];
|
|
5144
|
+
const symbol = this.safeString(order, 'symbol');
|
|
5145
|
+
const market = this.market(symbol);
|
|
5146
|
+
if (!market['spot']) {
|
|
5147
|
+
throw new errors.NotSupported(this.id + ' cancelOrdersForSymbols() supports only spot markets');
|
|
5148
|
+
}
|
|
5149
|
+
const id = this.safeString(order, 'id');
|
|
5150
|
+
const orderItem = {
|
|
5151
|
+
'id': id,
|
|
5152
|
+
'currency_pair': market['id'],
|
|
5153
|
+
};
|
|
5154
|
+
ordersRequests.push(orderItem);
|
|
5155
|
+
}
|
|
5156
|
+
const response = await this.privateSpotPostCancelBatchOrders(ordersRequests);
|
|
5157
|
+
//
|
|
5158
|
+
// [
|
|
5159
|
+
// {
|
|
5160
|
+
// "currency_pair": "BTC_USDT",
|
|
5161
|
+
// "id": "123456"
|
|
5162
|
+
// }
|
|
5163
|
+
// ]
|
|
5164
|
+
//
|
|
5165
|
+
return this.parseOrders(response);
|
|
5166
|
+
}
|
|
5076
5167
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
5077
5168
|
/**
|
|
5078
5169
|
* @method
|
|
@@ -6077,7 +6168,22 @@ class gate extends gate$1 {
|
|
|
6077
6168
|
const authentication = api[0]; // public, private
|
|
6078
6169
|
const type = api[1]; // spot, margin, future, delivery
|
|
6079
6170
|
let query = this.omit(params, this.extractParams(path));
|
|
6080
|
-
|
|
6171
|
+
const containsSettle = path.indexOf('settle') > -1;
|
|
6172
|
+
if (containsSettle && path.endsWith('batch_cancel_orders')) { // weird check to prevent $settle in php and converting {settle} to array(settle)
|
|
6173
|
+
// special case where we need to extract the settle from the path
|
|
6174
|
+
// but the body is an array of strings
|
|
6175
|
+
const settle = this.safeDict(params, 0);
|
|
6176
|
+
path = this.implodeParams(path, settle);
|
|
6177
|
+
// remove the first element from params
|
|
6178
|
+
const newParams = [];
|
|
6179
|
+
const anyParams = params;
|
|
6180
|
+
for (let i = 1; i < anyParams.length; i++) {
|
|
6181
|
+
newParams.push(params[i]);
|
|
6182
|
+
}
|
|
6183
|
+
params = newParams;
|
|
6184
|
+
query = newParams;
|
|
6185
|
+
}
|
|
6186
|
+
else if (Array.isArray(params)) {
|
|
6081
6187
|
// endpoints like createOrders use an array instead of an object
|
|
6082
6188
|
// so we infer the settle from one of the elements
|
|
6083
6189
|
// they have to be all the same so relying on the first one is fine
|
|
@@ -7550,6 +7656,7 @@ class gate extends gate$1 {
|
|
|
7550
7656
|
// {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: Trigger.rule"}
|
|
7551
7657
|
// {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: trigger.expiration invalid range"}
|
|
7552
7658
|
// {"label": "INVALID_ARGUMENT", "detail": "invalid size"}
|
|
7659
|
+
// {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
|
|
7553
7660
|
//
|
|
7554
7661
|
const label = this.safeString(response, 'label');
|
|
7555
7662
|
if (label !== undefined) {
|
package/dist/cjs/src/htx.js
CHANGED
|
@@ -6026,7 +6026,66 @@ class htx extends htx$1 {
|
|
|
6026
6026
|
// "ts": 1604367997451
|
|
6027
6027
|
// }
|
|
6028
6028
|
//
|
|
6029
|
-
|
|
6029
|
+
const data = this.safeDict(response, 'data');
|
|
6030
|
+
return this.parseCancelOrders(data);
|
|
6031
|
+
}
|
|
6032
|
+
parseCancelOrders(orders) {
|
|
6033
|
+
//
|
|
6034
|
+
// {
|
|
6035
|
+
// "success": [
|
|
6036
|
+
// "5983466"
|
|
6037
|
+
// ],
|
|
6038
|
+
// "failed": [
|
|
6039
|
+
// {
|
|
6040
|
+
// "err-msg": "Incorrect order state",
|
|
6041
|
+
// "order-state": 7,
|
|
6042
|
+
// "order-id": "",
|
|
6043
|
+
// "err-code": "order-orderstate-error",
|
|
6044
|
+
// "client-order-id": "first"
|
|
6045
|
+
// },
|
|
6046
|
+
// ...
|
|
6047
|
+
// ]
|
|
6048
|
+
// }
|
|
6049
|
+
//
|
|
6050
|
+
// {
|
|
6051
|
+
// "errors": [
|
|
6052
|
+
// {
|
|
6053
|
+
// "order_id": "769206471845261312",
|
|
6054
|
+
// "err_code": 1061,
|
|
6055
|
+
// "err_msg": "This order doesnt exist."
|
|
6056
|
+
// }
|
|
6057
|
+
// ],
|
|
6058
|
+
// "successes": "1258075374411399168,1258075393254871040"
|
|
6059
|
+
// }
|
|
6060
|
+
//
|
|
6061
|
+
const successes = this.safeString(orders, 'successes');
|
|
6062
|
+
let success = undefined;
|
|
6063
|
+
if (successes !== undefined) {
|
|
6064
|
+
success = successes.split(',');
|
|
6065
|
+
}
|
|
6066
|
+
else {
|
|
6067
|
+
success = this.safeList(orders, 'success', []);
|
|
6068
|
+
}
|
|
6069
|
+
const failed = this.safeList2(orders, 'errors', 'failed', []);
|
|
6070
|
+
const result = [];
|
|
6071
|
+
for (let i = 0; i < success.length; i++) {
|
|
6072
|
+
const order = success[i];
|
|
6073
|
+
result.push(this.safeOrder({
|
|
6074
|
+
'info': order,
|
|
6075
|
+
'id': order,
|
|
6076
|
+
'status': 'canceled',
|
|
6077
|
+
}));
|
|
6078
|
+
}
|
|
6079
|
+
for (let i = 0; i < failed.length; i++) {
|
|
6080
|
+
const order = failed[i];
|
|
6081
|
+
result.push(this.safeOrder({
|
|
6082
|
+
'info': order,
|
|
6083
|
+
'id': this.safeString2(order, 'order-id', 'order_id'),
|
|
6084
|
+
'status': 'failed',
|
|
6085
|
+
'clientOrderId': this.safeString(order, 'client-order-id'),
|
|
6086
|
+
}));
|
|
6087
|
+
}
|
|
6088
|
+
return result;
|
|
6030
6089
|
}
|
|
6031
6090
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
6032
6091
|
/**
|
|
@@ -6067,6 +6126,22 @@ class htx extends htx$1 {
|
|
|
6067
6126
|
request['symbol'] = market['id'];
|
|
6068
6127
|
}
|
|
6069
6128
|
response = await this.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(this.extend(request, params));
|
|
6129
|
+
//
|
|
6130
|
+
// {
|
|
6131
|
+
// "code": 200,
|
|
6132
|
+
// "data": {
|
|
6133
|
+
// "success-count": 2,
|
|
6134
|
+
// "failed-count": 0,
|
|
6135
|
+
// "next-id": 5454600
|
|
6136
|
+
// }
|
|
6137
|
+
// }
|
|
6138
|
+
//
|
|
6139
|
+
const data = this.safeDict(response, 'data');
|
|
6140
|
+
return [
|
|
6141
|
+
this.safeOrder({
|
|
6142
|
+
'info': data,
|
|
6143
|
+
}),
|
|
6144
|
+
];
|
|
6070
6145
|
}
|
|
6071
6146
|
else {
|
|
6072
6147
|
if (symbol === undefined) {
|
|
@@ -6146,31 +6221,19 @@ class htx extends htx$1 {
|
|
|
6146
6221
|
else {
|
|
6147
6222
|
throw new errors.NotSupported(this.id + ' cancelAllOrders() does not support ' + marketType + ' markets');
|
|
6148
6223
|
}
|
|
6224
|
+
//
|
|
6225
|
+
// {
|
|
6226
|
+
// "status": "ok",
|
|
6227
|
+
// "data": {
|
|
6228
|
+
// "errors": [],
|
|
6229
|
+
// "successes": "1104754904426696704"
|
|
6230
|
+
// },
|
|
6231
|
+
// "ts": "1683435723755"
|
|
6232
|
+
// }
|
|
6233
|
+
//
|
|
6234
|
+
const data = this.safeDict(response, 'data');
|
|
6235
|
+
return this.parseCancelOrders(data);
|
|
6149
6236
|
}
|
|
6150
|
-
//
|
|
6151
|
-
// spot
|
|
6152
|
-
//
|
|
6153
|
-
// {
|
|
6154
|
-
// "code": 200,
|
|
6155
|
-
// "data": {
|
|
6156
|
-
// "success-count": 2,
|
|
6157
|
-
// "failed-count": 0,
|
|
6158
|
-
// "next-id": 5454600
|
|
6159
|
-
// }
|
|
6160
|
-
// }
|
|
6161
|
-
//
|
|
6162
|
-
// future and swap
|
|
6163
|
-
//
|
|
6164
|
-
// {
|
|
6165
|
-
// "status": "ok",
|
|
6166
|
-
// "data": {
|
|
6167
|
-
// "errors": [],
|
|
6168
|
-
// "successes": "1104754904426696704"
|
|
6169
|
-
// },
|
|
6170
|
-
// "ts": "1683435723755"
|
|
6171
|
-
// }
|
|
6172
|
-
//
|
|
6173
|
-
return response;
|
|
6174
6237
|
}
|
|
6175
6238
|
async cancelAllOrdersAfter(timeout, params = {}) {
|
|
6176
6239
|
/**
|