ccxt 4.1.73 → 4.1.75

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.
Files changed (53) hide show
  1. package/README.md +6 -8
  2. package/dist/ccxt.browser.js +1108 -1455
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -4
  5. package/dist/cjs/src/base/Exchange.js +31 -4
  6. package/dist/cjs/src/base/ws/Client.js +11 -14
  7. package/dist/cjs/src/bigone.js +38 -9
  8. package/dist/cjs/src/bingx.js +57 -18
  9. package/dist/cjs/src/bitmart.js +33 -11
  10. package/dist/cjs/src/bybit.js +30 -7
  11. package/dist/cjs/src/cex.js +61 -3
  12. package/dist/cjs/src/exmo.js +34 -31
  13. package/dist/cjs/src/gate.js +1 -0
  14. package/dist/cjs/src/gemini.js +21 -19
  15. package/dist/cjs/src/kraken.js +156 -11
  16. package/dist/cjs/src/okx.js +45 -2
  17. package/dist/cjs/src/poloniex.js +27 -25
  18. package/dist/cjs/src/pro/binance.js +60 -8
  19. package/dist/cjs/src/pro/cex.js +317 -10
  20. package/dist/cjs/src/pro/coinbasepro.js +1 -1
  21. package/js/ccxt.d.ts +2 -5
  22. package/js/ccxt.js +2 -4
  23. package/js/src/abstract/kraken.d.ts +2 -0
  24. package/js/src/base/Exchange.d.ts +2 -0
  25. package/js/src/base/Exchange.js +31 -4
  26. package/js/src/base/ws/Client.js +11 -14
  27. package/js/src/bigone.d.ts +1 -0
  28. package/js/src/bigone.js +38 -9
  29. package/js/src/bingx.d.ts +3 -0
  30. package/js/src/bingx.js +58 -19
  31. package/js/src/bitmart.d.ts +1 -0
  32. package/js/src/bitmart.js +33 -11
  33. package/js/src/bybit.d.ts +1 -0
  34. package/js/src/bybit.js +30 -7
  35. package/js/src/cex.d.ts +1 -0
  36. package/js/src/cex.js +61 -3
  37. package/js/src/exmo.d.ts +1 -1
  38. package/js/src/exmo.js +34 -31
  39. package/js/src/gate.js +1 -0
  40. package/js/src/gemini.js +21 -19
  41. package/js/src/kraken.d.ts +2 -0
  42. package/js/src/kraken.js +156 -11
  43. package/js/src/okx.d.ts +2 -0
  44. package/js/src/okx.js +45 -2
  45. package/js/src/poloniex.js +27 -25
  46. package/js/src/pro/binance.d.ts +1 -0
  47. package/js/src/pro/binance.js +61 -9
  48. package/js/src/pro/cex.d.ts +11 -2
  49. package/js/src/pro/cex.js +318 -11
  50. package/js/src/pro/coinbasepro.js +1 -1
  51. package/package.json +1 -1
  52. package/js/src/abstract/tidex.d.ts +0 -28
  53. package/js/src/abstract/tidex.js +0 -11
@@ -752,32 +752,34 @@ class poloniex extends poloniex$1 {
752
752
  let withdrawAvailable = this.safeValue(result[code], 'withdraw');
753
753
  withdrawAvailable = (withdrawEnabled) ? withdrawEnabled : withdrawAvailable;
754
754
  const networks = this.safeValue(result[code], 'networks', {});
755
- networks[networkCode] = {
756
- 'info': currency,
757
- 'id': networkId,
758
- 'network': networkCode,
759
- 'currencyId': id,
760
- 'numericId': numericId,
761
- 'deposit': depositEnabled,
762
- 'withdraw': withdrawEnabled,
763
- 'active': active,
764
- 'fee': this.parseNumber(feeString),
765
- 'precision': undefined,
766
- 'limits': {
767
- 'amount': {
768
- 'min': undefined,
769
- 'max': undefined,
770
- },
771
- 'withdraw': {
772
- 'min': undefined,
773
- 'max': undefined,
774
- },
775
- 'deposit': {
776
- 'min': undefined,
777
- 'max': undefined,
755
+ if (networkCode !== undefined) {
756
+ networks[networkCode] = {
757
+ 'info': currency,
758
+ 'id': networkId,
759
+ 'network': networkCode,
760
+ 'currencyId': id,
761
+ 'numericId': numericId,
762
+ 'deposit': depositEnabled,
763
+ 'withdraw': withdrawEnabled,
764
+ 'active': active,
765
+ 'fee': this.parseNumber(feeString),
766
+ 'precision': undefined,
767
+ 'limits': {
768
+ 'amount': {
769
+ 'min': undefined,
770
+ 'max': undefined,
771
+ },
772
+ 'withdraw': {
773
+ 'min': undefined,
774
+ 'max': undefined,
775
+ },
776
+ 'deposit': {
777
+ 'min': undefined,
778
+ 'max': undefined,
779
+ },
778
780
  },
779
- },
780
- };
781
+ };
782
+ }
781
783
  result[code]['networks'] = networks;
782
784
  const info = this.safeValue(result[code], 'info', []);
783
785
  const rawInfo = {};
@@ -23,6 +23,7 @@ class binance extends binance$1 {
23
23
  'watchOrderBook': true,
24
24
  'watchOrderBookForSymbols': true,
25
25
  'watchOrders': true,
26
+ 'watchOrdersForSymbols': true,
26
27
  'watchPositions': true,
27
28
  'watchTicker': true,
28
29
  'watchTickers': true,
@@ -2062,6 +2063,7 @@ class binance extends binance$1 {
2062
2063
  /**
2063
2064
  * @method
2064
2065
  * @name binance#watchOrders
2066
+ * @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
2065
2067
  * @description watches information on multiple orders made by the user
2066
2068
  * @param {string} symbol unified market symbol of the market orders were made in
2067
2069
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -2075,7 +2077,7 @@ class binance extends binance$1 {
2075
2077
  if (symbol !== undefined) {
2076
2078
  market = this.market(symbol);
2077
2079
  symbol = market['symbol'];
2078
- messageHash += ':' + symbol;
2080
+ messageHash += '::' + symbol;
2079
2081
  }
2080
2082
  let type = undefined;
2081
2083
  [type, params] = this.handleMarketTypeAndParams('watchOrders', market, params);
@@ -2098,11 +2100,63 @@ class binance extends binance$1 {
2098
2100
  this.setBalanceCache(client, type);
2099
2101
  this.setPositionsCache(client, type);
2100
2102
  const message = undefined;
2101
- const orders = await this.watch(url, messageHash, message, type);
2103
+ const newOrder = await this.watch(url, messageHash, message, type);
2102
2104
  if (this.newUpdates) {
2103
- limit = orders.getLimit(symbol, limit);
2105
+ return newOrder;
2104
2106
  }
2105
- return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
2107
+ return this.filterBySymbolSinceLimit(this.orders, symbol, since, limit, true);
2108
+ }
2109
+ async watchOrdersForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
2110
+ /**
2111
+ * @method
2112
+ * @name binance#watchOrdersForSymbols
2113
+ * @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
2114
+ * @description watches information on multiple orders made by the user
2115
+ * @param {string[]} symbols unified symbol of the market to fetch orders for
2116
+ * @param {int} [since] the earliest time in ms to fetch orders for
2117
+ * @param {int} [limit] the maximum number of trade structures to retrieve
2118
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2119
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2120
+ */
2121
+ let marginMode = undefined;
2122
+ [marginMode, params] = this.handleMarginModeAndParams('authenticate', params);
2123
+ const isIsolatedMargin = (marginMode === 'isolated');
2124
+ if (isIsolatedMargin) {
2125
+ throw new errors.NotSupported(this.id + ' watchOrdersForSymbols does not support isolated margin markets, use watchOrders instead');
2126
+ }
2127
+ await this.loadMarkets();
2128
+ let type = undefined;
2129
+ const market = this.getMarketFromSymbols(symbols);
2130
+ [type, params] = this.handleMarketTypeAndParams('watchOrdersForSymbols', market, params);
2131
+ symbols = this.marketSymbols(symbols, type, true, true, true);
2132
+ let messageHash = 'orders';
2133
+ if (symbols !== undefined) {
2134
+ messageHash = messageHash + '::' + symbols.join(',');
2135
+ }
2136
+ let subType = undefined;
2137
+ [subType, params] = this.handleSubTypeAndParams('watchOrdersForSymbols', market, params);
2138
+ if (this.isLinear(type, subType)) {
2139
+ type = 'future';
2140
+ }
2141
+ else if (this.isInverse(type, subType)) {
2142
+ type = 'delivery';
2143
+ }
2144
+ params = this.extend(params, { 'type': type });
2145
+ await this.authenticate(params);
2146
+ let urlType = type;
2147
+ if (type === 'margin') {
2148
+ urlType = 'spot'; // spot-margin shares the same stream as regular spot
2149
+ }
2150
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
2151
+ const client = this.client(url);
2152
+ this.setBalanceCache(client, type);
2153
+ this.setPositionsCache(client, type);
2154
+ const message = undefined;
2155
+ const newOrders = await this.watch(url, messageHash, message, type);
2156
+ if (this.newUpdates) {
2157
+ return newOrders;
2158
+ }
2159
+ return this.filterBySymbolsSinceLimit(this.orders, symbols, since, limit, true);
2106
2160
  }
2107
2161
  parseWsOrder(order, market = undefined) {
2108
2162
  //
@@ -2733,7 +2787,6 @@ class binance extends binance$1 {
2733
2787
  }
2734
2788
  }
2735
2789
  handleOrder(client, message) {
2736
- const messageHash = 'orders';
2737
2790
  const parsed = this.parseWsOrder(message);
2738
2791
  const symbol = this.safeString(parsed, 'symbol');
2739
2792
  const orderId = this.safeString(parsed, 'id');
@@ -2762,9 +2815,8 @@ class binance extends binance$1 {
2762
2815
  }
2763
2816
  }
2764
2817
  cachedOrders.append(parsed);
2765
- client.resolve(this.orders, messageHash);
2766
- const messageHashSymbol = messageHash + ':' + symbol;
2767
- client.resolve(this.orders, messageHashSymbol);
2818
+ this.resolvePromiseIfMessagehashMatches(client, 'orders::', symbol, parsed);
2819
+ client.resolve(parsed, 'orders');
2768
2820
  }
2769
2821
  }
2770
2822
  handleAcountUpdate(client, message) {
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var cex$1 = require('../cex.js');
4
+ var sha256 = require('../static_dependencies/noble-hashes/sha256.js');
4
5
  var errors = require('../base/errors.js');
5
6
  var Precise = require('../base/Precise.js');
6
7
  var Cache = require('../base/ws/Cache.js');
7
- var sha256 = require('../static_dependencies/noble-hashes/sha256.js');
8
8
 
9
9
  // ---------------------------------------------------------------------------
10
10
  // ---------------------------------------------------------------------------
@@ -22,6 +22,14 @@ class cex extends cex$1 {
22
22
  'watchOrderBook': true,
23
23
  'watchOHLCV': true,
24
24
  'watchPosition': undefined,
25
+ 'createOrderWs': true,
26
+ 'editOrderWs': true,
27
+ 'cancelOrderWs': true,
28
+ 'cancelOrdersWs': true,
29
+ 'fetchOrderWs': true,
30
+ 'fetchOpenOrdersWs': true,
31
+ 'fetchTickerWs': true,
32
+ 'fetchBalanceWs': true,
25
33
  },
26
34
  'urls': {
27
35
  'api': {
@@ -38,7 +46,7 @@ class cex extends cex$1 {
38
46
  requestId() {
39
47
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
40
48
  this.options['requestId'] = requestId;
41
- return requestId;
49
+ return requestId.toString();
42
50
  }
43
51
  async watchBalance(params = {}) {
44
52
  /**
@@ -50,7 +58,7 @@ class cex extends cex$1 {
50
58
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
51
59
  */
52
60
  await this.authenticate(params);
53
- const messageHash = 'balance';
61
+ const messageHash = this.requestId();
54
62
  const url = this.urls['api']['ws'];
55
63
  const subscribe = {
56
64
  'e': 'get-balance',
@@ -97,7 +105,8 @@ class cex extends cex$1 {
97
105
  result[code] = account;
98
106
  }
99
107
  this.balance = this.safeBalance(result);
100
- client.resolve(this.balance, 'balance');
108
+ const messageHash = this.safeString(message, 'oid');
109
+ client.resolve(this.balance, messageHash);
101
110
  }
102
111
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
103
112
  /**
@@ -287,6 +296,27 @@ class cex extends cex$1 {
287
296
  }
288
297
  return this.filterByArray(this.tickers, 'symbol', symbols);
289
298
  }
299
+ async fetchTickerWs(symbol, params = {}) {
300
+ /**
301
+ * @method
302
+ * @name cex#fetchTickerWs
303
+ * @see https://docs.cex.io/#ws-api-ticker-deprecated
304
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
305
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
306
+ * @param {object} [params] extra parameters specific to the cex api endpoint
307
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
308
+ */
309
+ await this.loadMarkets();
310
+ const market = this.market(symbol);
311
+ const url = this.urls['api']['ws'];
312
+ const messageHash = this.requestId();
313
+ const request = this.extend({
314
+ 'e': 'ticker',
315
+ 'oid': messageHash,
316
+ 'data': [market['base'], market['quote']],
317
+ }, params);
318
+ return await this.watch(url, messageHash, request, messageHash);
319
+ }
290
320
  handleTicker(client, message) {
291
321
  //
292
322
  // {
@@ -303,10 +333,12 @@ class cex extends cex$1 {
303
333
  const data = this.safeValue(message, 'data', {});
304
334
  const ticker = this.parseWsTicker(data);
305
335
  const symbol = ticker['symbol'];
306
- const messageHash = 'ticker:' + symbol;
307
336
  this.tickers[symbol] = ticker;
337
+ let messageHash = 'ticker:' + symbol;
308
338
  client.resolve(ticker, messageHash);
309
339
  client.resolve(ticker, 'tickers');
340
+ messageHash = this.safeString(message, 'oid');
341
+ client.resolve(ticker, messageHash);
310
342
  }
311
343
  parseWsTicker(ticker, market = undefined) {
312
344
  //
@@ -371,6 +403,25 @@ class cex extends cex$1 {
371
403
  'info': ticker,
372
404
  }, market);
373
405
  }
406
+ async fetchBalanceWs(params = {}) {
407
+ /**
408
+ * @method
409
+ * @name cex#fetchBalanceWs
410
+ * @see https://docs.cex.io/#ws-api-get-balance
411
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
412
+ * @param {object} [params] extra parameters specific to the cex api endpoint
413
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/en/latest/manual.html?#balance-structure}
414
+ */
415
+ await this.loadMarkets();
416
+ await this.authenticate();
417
+ const url = this.urls['api']['ws'];
418
+ const messageHash = this.requestId();
419
+ const request = this.extend({
420
+ 'e': 'get-balance',
421
+ 'oid': messageHash,
422
+ }, params);
423
+ return await this.watch(url, messageHash, request, messageHash);
424
+ }
374
425
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
375
426
  /**
376
427
  * @method
@@ -659,7 +710,8 @@ class cex extends cex$1 {
659
710
  const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
660
711
  this.orders = new Cache.ArrayCacheBySymbolById(limit);
661
712
  }
662
- const ordersBySymbol = this.safeValue(this.orders['hashmap'], symbol, {});
713
+ const storedOrders = this.orders;
714
+ const ordersBySymbol = this.safeValue(storedOrders.hashmap, symbol, {});
663
715
  let order = this.safeValue(ordersBySymbol, orderId);
664
716
  if (order === undefined) {
665
717
  order = this.parseWsOrderUpdate(data, market);
@@ -684,7 +736,6 @@ class cex extends cex$1 {
684
736
  order['timestamp'] = timestamp;
685
737
  order['datetime'] = this.iso8601(timestamp);
686
738
  order = this.safeOrder(order);
687
- const storedOrders = this.orders;
688
739
  storedOrders.append(order);
689
740
  const messageHash = 'orders:' + symbol;
690
741
  client.resolve(storedOrders, messageHash);
@@ -745,7 +796,10 @@ class cex extends cex$1 {
745
796
  }
746
797
  const base = this.safeCurrencyCode(baseId);
747
798
  const quote = this.safeCurrencyCode(quoteId);
748
- const symbol = base + '/' + quote;
799
+ let symbol = undefined;
800
+ if (base !== undefined && quote !== undefined) {
801
+ symbol = base + '/' + quote;
802
+ }
749
803
  market = this.safeMarket(symbol, market);
750
804
  const time = this.safeInteger(order, 'time', this.milliseconds());
751
805
  let timestamp = time;
@@ -1110,6 +1164,236 @@ class cex extends cex$1 {
1110
1164
  client.resolve(stored, messageHash);
1111
1165
  }
1112
1166
  }
1167
+ async fetchOrderWs(id, symbol = undefined, params = {}) {
1168
+ /**
1169
+ * @method
1170
+ * @name cex#fetchOrderWs
1171
+ * @description fetches information on an order made by the user
1172
+ * @see https://docs.cex.io/#ws-api-get-order
1173
+ * @param {string} symbol not used by cex fetchOrder
1174
+ * @param {object} [params] extra parameters specific to the cex api endpoint
1175
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1176
+ */
1177
+ await this.loadMarkets();
1178
+ await this.authenticate();
1179
+ let market = undefined;
1180
+ if (symbol !== undefined) {
1181
+ market = this.market(symbol);
1182
+ }
1183
+ const data = this.extend({
1184
+ 'order_id': id.toString(),
1185
+ }, params);
1186
+ const url = this.urls['api']['ws'];
1187
+ const messageHash = this.requestId();
1188
+ const request = {
1189
+ 'e': 'get-order',
1190
+ 'oid': messageHash,
1191
+ 'data': data,
1192
+ };
1193
+ const response = await this.watch(url, messageHash, request, messageHash);
1194
+ return this.parseOrder(response, market);
1195
+ }
1196
+ async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1197
+ /**
1198
+ * @method
1199
+ * @name cex#fetchOpenOrdersWs
1200
+ * @see https://docs.cex.io/#ws-api-open-orders
1201
+ * @description fetch all unfilled currently open orders
1202
+ * @param {string} symbol unified market symbol
1203
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1204
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1205
+ * @param {object} [params] extra parameters specific to the cex api endpoint
1206
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1207
+ */
1208
+ if (symbol === undefined) {
1209
+ throw new errors.ArgumentsRequired(this.id + 'fetchOpenOrdersWs requires a symbol.');
1210
+ }
1211
+ await this.loadMarkets();
1212
+ await this.authenticate();
1213
+ const market = this.market(symbol);
1214
+ const url = this.urls['api']['ws'];
1215
+ const messageHash = this.requestId();
1216
+ const data = this.extend({
1217
+ 'pair': [market['baseId'], market['quoteId']],
1218
+ }, params);
1219
+ const request = {
1220
+ 'e': 'open-orders',
1221
+ 'oid': messageHash,
1222
+ 'data': data,
1223
+ };
1224
+ const response = await this.watch(url, messageHash, request, messageHash);
1225
+ return this.parseOrders(response, market, since, limit, params);
1226
+ }
1227
+ async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
1228
+ /**
1229
+ * @method
1230
+ * @name cex#createOrderWs
1231
+ * @see https://docs.cex.io/#ws-api-order-placement
1232
+ * @description create a trade order
1233
+ * @param {string} symbol unified symbol of the market to create an order in
1234
+ * @param {string} type 'market' or 'limit'
1235
+ * @param {string} side 'buy' or 'sell'
1236
+ * @param {float} amount how much of currency you want to trade in units of base currency
1237
+ * @param {float} price the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1238
+ * @param {object} [params] extra parameters specific to the kraken api endpoint
1239
+ * @param {boolean} [params.maker_only] Optional, maker only places an order only if offers best sell (<= max) or buy(>= max) price for this pair, if not order placement will be rejected with an error - "Order is not maker"
1240
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
1241
+ */
1242
+ if (price === undefined) {
1243
+ throw new errors.BadRequest(this.id + ' createOrderWs requires a price argument');
1244
+ }
1245
+ await this.loadMarkets();
1246
+ await this.authenticate();
1247
+ const market = this.market(symbol);
1248
+ const url = this.urls['api']['ws'];
1249
+ const messageHash = this.requestId();
1250
+ const data = this.extend({
1251
+ 'pair': [market['baseId'], market['quoteId']],
1252
+ 'amount': amount,
1253
+ 'price': price,
1254
+ 'type': side,
1255
+ }, params);
1256
+ const request = {
1257
+ 'e': 'place-order',
1258
+ 'oid': messageHash,
1259
+ 'data': data,
1260
+ };
1261
+ const rawOrder = await this.watch(url, messageHash, request, messageHash);
1262
+ return this.parseOrder(rawOrder, market);
1263
+ }
1264
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1265
+ /**
1266
+ * @method
1267
+ * @name cex#editOrderWs
1268
+ * @description edit a trade order
1269
+ * @see https://docs.cex.io/#ws-api-cancel-replace
1270
+ * @param {string} id order id
1271
+ * @param {string} symbol unified symbol of the market to create an order in
1272
+ * @param {string} type 'market' or 'limit'
1273
+ * @param {string} side 'buy' or 'sell'
1274
+ * @param {float} amount how much of the currency you want to trade in units of the base currency
1275
+ * @param {float|undefined} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1276
+ * @param {object} [params] extra parameters specific to the cex api endpoint
1277
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
1278
+ */
1279
+ if (amount === undefined) {
1280
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a amount argument');
1281
+ }
1282
+ if (price === undefined) {
1283
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a price argument');
1284
+ }
1285
+ await this.loadMarkets();
1286
+ await this.authenticate();
1287
+ const market = this.market(symbol);
1288
+ const data = this.extend({
1289
+ 'pair': [market['baseId'], market['quoteId']],
1290
+ 'type': side,
1291
+ 'amount': amount,
1292
+ 'price': price,
1293
+ 'order_id': id,
1294
+ }, params);
1295
+ const messageHash = this.requestId();
1296
+ const url = this.urls['api']['ws'];
1297
+ const request = {
1298
+ 'e': 'cancel-replace-order',
1299
+ 'oid': messageHash,
1300
+ 'data': data,
1301
+ };
1302
+ const response = await this.watch(url, messageHash, request, messageHash, messageHash);
1303
+ return this.parseOrder(response, market);
1304
+ }
1305
+ async cancelOrderWs(id, symbol = undefined, params = {}) {
1306
+ /**
1307
+ * @method
1308
+ * @name cex#cancelOrderWs
1309
+ * @see https://docs.cex.io/#ws-api-order-cancel
1310
+ * @description cancels an open order
1311
+ * @param {string} id order id
1312
+ * @param {string} symbol not used by cex cancelOrder ()
1313
+ * @param {object} [params] extra parameters specific to the cex api endpoint
1314
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1315
+ */
1316
+ await this.loadMarkets();
1317
+ await this.authenticate();
1318
+ let market = undefined;
1319
+ if (symbol !== undefined) {
1320
+ market = this.market(symbol);
1321
+ }
1322
+ const data = this.extend({
1323
+ 'order_id': id,
1324
+ }, params);
1325
+ const messageHash = this.requestId();
1326
+ const url = this.urls['api']['ws'];
1327
+ const request = {
1328
+ 'e': 'cancel-order',
1329
+ 'oid': messageHash,
1330
+ 'data': data,
1331
+ };
1332
+ const response = await this.watch(url, messageHash, request, messageHash, messageHash);
1333
+ return this.parseOrder(response, market);
1334
+ }
1335
+ async cancelOrdersWs(ids, symbol = undefined, params = {}) {
1336
+ /**
1337
+ * @method
1338
+ * @name cex#cancelOrdersWs
1339
+ * @description cancel multiple orders
1340
+ * @see https://docs.cex.io/#ws-api-mass-cancel-place
1341
+ * @param {string[]} ids order ids
1342
+ * @param {string} symbol not used by cex cancelOrders()
1343
+ * @param {object} [params] extra parameters specific to the cex api endpoint
1344
+ * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1345
+ */
1346
+ if (symbol !== undefined) {
1347
+ throw new errors.BadRequest(this.id + ' cancelOrderWs does not allow filtering by symbol');
1348
+ }
1349
+ await this.loadMarkets();
1350
+ await this.authenticate();
1351
+ const messageHash = this.requestId();
1352
+ const data = this.extend({
1353
+ 'cancel-orders': ids,
1354
+ }, params);
1355
+ const url = this.urls['api']['ws'];
1356
+ const request = {
1357
+ 'e': 'mass-cancel-place-orders',
1358
+ 'oid': messageHash,
1359
+ 'data': data,
1360
+ };
1361
+ const response = await this.watch(url, messageHash, request, messageHash, messageHash);
1362
+ //
1363
+ // {
1364
+ // "cancel-orders": [{
1365
+ // "order_id": 69202557979,
1366
+ // "fremains": "0.15000000"
1367
+ // }],
1368
+ // "place-orders": [],
1369
+ // "placed-cancelled": []
1370
+ // }
1371
+ //
1372
+ const canceledOrders = this.safeValue(response, 'cancel-orders');
1373
+ return this.parseOrders(canceledOrders, undefined, undefined, undefined, params);
1374
+ }
1375
+ resolveData(client, message) {
1376
+ //
1377
+ // "e": "open-orders",
1378
+ // "data": [
1379
+ // {
1380
+ // "id": "2477098",
1381
+ // "time": "1435927928618",
1382
+ // "type": "buy",
1383
+ // "price": "241.9477",
1384
+ // "amount": "0.02000000",
1385
+ // "pending": "0.02000000"
1386
+ // },
1387
+ // ...
1388
+ // ],
1389
+ // "oid": "1435927928274_9_open-orders",
1390
+ // "ok": "ok"
1391
+ // }
1392
+ //
1393
+ const data = this.safeValue(message, 'data');
1394
+ const messageHash = this.safeString(message, 'oid');
1395
+ client.resolve(data, messageHash);
1396
+ }
1113
1397
  handleConnected(client, message) {
1114
1398
  //
1115
1399
  // {
@@ -1127,7 +1411,25 @@ class cex extends cex$1 {
1127
1411
  // "ok": "error"
1128
1412
  // }
1129
1413
  //
1130
- throw new errors.ExchangeError(this.id + ' ' + this.json(message));
1414
+ try {
1415
+ const data = this.safeValue(message, 'data', {});
1416
+ const error = this.safeString(data, 'error');
1417
+ const event = this.safeString(message, 'e', '');
1418
+ const feedback = this.id + ' ' + event + ' ' + error;
1419
+ this.throwExactlyMatchedException(this.exceptions['exact'], error, feedback);
1420
+ this.throwBroadlyMatchedException(this.exceptions['broad'], error, feedback);
1421
+ throw new errors.ExchangeError(feedback);
1422
+ }
1423
+ catch (error) {
1424
+ const messageHash = this.safeString(message, 'oid');
1425
+ const future = this.safeValue(client['futures'], messageHash);
1426
+ if (future !== undefined) {
1427
+ client.reject(error, messageHash);
1428
+ }
1429
+ else {
1430
+ throw error;
1431
+ }
1432
+ }
1131
1433
  }
1132
1434
  handleMessage(client, message) {
1133
1435
  const ok = this.safeString(message, 'ok');
@@ -1147,11 +1449,16 @@ class cex extends cex$1 {
1147
1449
  'get-balance': this.handleBalance,
1148
1450
  'order-book-subscribe': this.handleOrderBookSnapshot,
1149
1451
  'md_update': this.handleOrderBookUpdate,
1150
- 'open-orders': this.handleOrdersSnapshot,
1452
+ 'open-orders': this.resolveData,
1151
1453
  'order': this.handleOrderUpdate,
1152
1454
  'history-update': this.handleTrade,
1153
1455
  'history': this.handleTradesSnapshot,
1154
1456
  'tx': this.handleTransaction,
1457
+ 'place-order': this.resolveData,
1458
+ 'cancel-replace-order': this.resolveData,
1459
+ 'cancel-order': this.resolveData,
1460
+ 'mass-cancel-place-orders': this.resolveData,
1461
+ 'get-order': this.resolveData,
1155
1462
  };
1156
1463
  const handler = this.safeValue(handlers, event);
1157
1464
  if (handler !== undefined) {
@@ -248,8 +248,8 @@ class coinbasepro extends coinbasepro$1 {
248
248
  * @param {object} [params] extra parameters specific to the exchange API endpoint
249
249
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
250
250
  */
251
- symbols = this.marketSymbols(symbols, undefined, false);
252
251
  await this.loadMarkets();
252
+ symbols = this.marketSymbols(symbols, undefined, false);
253
253
  const name = 'user';
254
254
  const messageHash = 'multipleOrders::';
255
255
  const authentication = this.authenticate();
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.72";
7
+ declare const version = "4.1.74";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -94,7 +94,6 @@ import phemex from './src/phemex.js';
94
94
  import poloniex from './src/poloniex.js';
95
95
  import poloniexfutures from './src/poloniexfutures.js';
96
96
  import probit from './src/probit.js';
97
- import tidex from './src/tidex.js';
98
97
  import timex from './src/timex.js';
99
98
  import tokocrypto from './src/tokocrypto.js';
100
99
  import upbit from './src/upbit.js';
@@ -253,7 +252,6 @@ declare const exchanges: {
253
252
  poloniex: typeof poloniex;
254
253
  poloniexfutures: typeof poloniexfutures;
255
254
  probit: typeof probit;
256
- tidex: typeof tidex;
257
255
  timex: typeof timex;
258
256
  tokocrypto: typeof tokocrypto;
259
257
  upbit: typeof upbit;
@@ -480,7 +478,6 @@ declare const ccxt: {
480
478
  poloniex: typeof poloniex;
481
479
  poloniexfutures: typeof poloniexfutures;
482
480
  probit: typeof probit;
483
- tidex: typeof tidex;
484
481
  timex: typeof timex;
485
482
  tokocrypto: typeof tokocrypto;
486
483
  upbit: typeof upbit;
@@ -492,5 +489,5 @@ declare const ccxt: {
492
489
  zaif: typeof zaif;
493
490
  zonda: typeof zonda;
494
491
  } & typeof functions & typeof errors;
495
- export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinlist, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, p2b, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
492
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinlist, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
496
493
  export default ccxt;