ccxt 4.3.56 → 4.3.58

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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +5 -1
  5. package/dist/cjs/src/base/ws/Client.js +34 -4
  6. package/dist/cjs/src/bigone.js +21 -1
  7. package/dist/cjs/src/bingx.js +127 -27
  8. package/dist/cjs/src/bitget.js +56 -47
  9. package/dist/cjs/src/coinmate.js +28 -35
  10. package/dist/cjs/src/coinone.js +13 -19
  11. package/dist/cjs/src/gate.js +117 -4
  12. package/dist/cjs/src/htx.js +91 -26
  13. package/dist/cjs/src/huobijp.js +65 -2
  14. package/dist/cjs/src/kucoin.js +3 -0
  15. package/dist/cjs/src/latoken.js +5 -1
  16. package/dist/cjs/src/okx.js +3 -0
  17. package/dist/cjs/src/pro/okx.js +3 -3
  18. package/dist/cjs/src/woo.js +1 -1
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/kucoin.d.ts +1 -0
  22. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  23. package/js/src/alpaca.d.ts +1 -1
  24. package/js/src/alpaca.js +5 -1
  25. package/js/src/base/ws/Client.d.ts +2 -0
  26. package/js/src/base/ws/Client.js +34 -4
  27. package/js/src/bigone.d.ts +1 -1
  28. package/js/src/bigone.js +21 -1
  29. package/js/src/bingx.d.ts +1 -0
  30. package/js/src/bingx.js +127 -27
  31. package/js/src/bitget.d.ts +1 -1
  32. package/js/src/bitget.js +56 -47
  33. package/js/src/coinmate.js +28 -35
  34. package/js/src/coinone.js +13 -19
  35. package/js/src/gate.d.ts +3 -1
  36. package/js/src/gate.js +117 -4
  37. package/js/src/htx.d.ts +3 -2
  38. package/js/src/htx.js +91 -26
  39. package/js/src/huobijp.d.ts +3 -2
  40. package/js/src/huobijp.js +65 -2
  41. package/js/src/kucoin.js +3 -0
  42. package/js/src/latoken.d.ts +1 -1
  43. package/js/src/latoken.js +5 -1
  44. package/js/src/okx.js +3 -0
  45. package/js/src/pro/okx.js +3 -3
  46. package/js/src/woo.js +2 -2
  47. package/package.json +1 -1
@@ -11,6 +11,7 @@ import { isNode, isJsonEncodedObject, deepExtend, milliseconds, } from '../../ba
11
11
  import { utf8 } from '../../static_dependencies/scure-base/index.js';
12
12
  export default class Client {
13
13
  constructor(url, onMessageCallback, onErrorCallback, onCloseCallback, onConnectedCallback, config = {}) {
14
+ this.useMessageQueue = true;
14
15
  this.verbose = false;
15
16
  const defaults = {
16
17
  url,
@@ -24,6 +25,8 @@ export default class Client {
24
25
  futures: {},
25
26
  subscriptions: {},
26
27
  rejections: {},
28
+ messageQueue: {},
29
+ useMessageQueue: true,
27
30
  connected: undefined,
28
31
  error: undefined,
29
32
  connectionStarted: undefined,
@@ -54,6 +57,15 @@ export default class Client {
54
57
  if (messageHash in this.rejections) {
55
58
  future.reject(this.rejections[messageHash]);
56
59
  delete this.rejections[messageHash];
60
+ delete this.messageQueue[messageHash];
61
+ return future;
62
+ }
63
+ if (this.useMessageQueue) {
64
+ const queue = this.messageQueue[messageHash];
65
+ if (queue && queue.length) {
66
+ future.resolve(queue.shift());
67
+ delete this.futures[messageHash];
68
+ }
57
69
  }
58
70
  return future;
59
71
  }
@@ -61,10 +73,27 @@ export default class Client {
61
73
  if (this.verbose && (messageHash === undefined)) {
62
74
  this.log(new Date(), 'resolve received undefined messageHash');
63
75
  }
64
- if ((messageHash !== undefined) && (messageHash in this.futures)) {
65
- const promise = this.futures[messageHash];
66
- promise.resolve(result);
67
- delete this.futures[messageHash];
76
+ if (this.useMessageQueue === true) {
77
+ if (!(messageHash in this.messageQueue)) {
78
+ this.messageQueue[messageHash] = [];
79
+ }
80
+ const queue = this.messageQueue[messageHash];
81
+ queue.push(result);
82
+ while (queue.length > 10) { // limit size to 10 messages in the queue
83
+ queue.shift();
84
+ }
85
+ if ((messageHash !== undefined) && (messageHash in this.futures)) {
86
+ const promise = this.futures[messageHash];
87
+ promise.resolve(queue.shift());
88
+ delete this.futures[messageHash];
89
+ }
90
+ }
91
+ else {
92
+ if (messageHash in this.futures) {
93
+ const promise = this.futures[messageHash];
94
+ promise.resolve(result);
95
+ delete this.futures[messageHash];
96
+ }
68
97
  }
69
98
  return result;
70
99
  }
@@ -105,6 +134,7 @@ export default class Client {
105
134
  reset(error) {
106
135
  this.clearConnectionTimeout();
107
136
  this.clearPingInterval();
137
+ this.messageQueue = {};
108
138
  this.reject(error);
109
139
  }
110
140
  onConnectionTimeout() {
@@ -26,7 +26,7 @@ export default class bigone extends Exchange {
26
26
  createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
27
27
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
28
28
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
29
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
29
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<any[]>;
30
30
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
31
31
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
32
32
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
package/js/src/bigone.js CHANGED
@@ -1624,7 +1624,27 @@ export default class bigone extends Exchange {
1624
1624
  // }
1625
1625
  // }
1626
1626
  //
1627
- return response;
1627
+ const data = this.safeDict(response, 'data', {});
1628
+ const cancelled = this.safeList(data, 'cancelled', []);
1629
+ const failed = this.safeList(data, 'failed', []);
1630
+ const result = [];
1631
+ for (let i = 0; i < cancelled.length; i++) {
1632
+ const orderId = cancelled[i];
1633
+ result.push(this.safeOrder({
1634
+ 'info': orderId,
1635
+ 'id': orderId,
1636
+ 'status': 'canceled',
1637
+ }));
1638
+ }
1639
+ for (let i = 0; i < failed.length; i++) {
1640
+ const orderId = failed[i];
1641
+ result.push(this.safeOrder({
1642
+ 'info': orderId,
1643
+ 'id': orderId,
1644
+ 'status': 'failed',
1645
+ }));
1646
+ }
1647
+ return result;
1628
1648
  }
1629
1649
  async fetchOrder(id, symbol = undefined, params = {}) {
1630
1650
  /**
package/js/src/bingx.d.ts CHANGED
@@ -10,6 +10,7 @@ export default class bingx extends Exchange {
10
10
  fetchCurrencies(params?: {}): Promise<Currencies>;
11
11
  fetchSpotMarkets(params: any): Promise<import("./base/types.js").MarketInterface[]>;
12
12
  fetchSwapMarkets(params: any): Promise<import("./base/types.js").MarketInterface[]>;
13
+ fetchInverseSwapMarkets(params: any): Promise<import("./base/types.js").MarketInterface[]>;
13
14
  parseMarket(market: Dict): Market;
14
15
  fetchMarkets(params?: {}): Promise<Market[]>;
15
16
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
package/js/src/bingx.js CHANGED
@@ -672,6 +672,29 @@ export default class bingx extends Exchange {
672
672
  const markets = this.safeList(response, 'data', []);
673
673
  return this.parseMarkets(markets);
674
674
  }
675
+ async fetchInverseSwapMarkets(params) {
676
+ const response = await this.cswapV1PublicGetMarketContracts(params);
677
+ //
678
+ // {
679
+ // "code": 0,
680
+ // "msg": "",
681
+ // "timestamp": 1720074487610,
682
+ // "data": [
683
+ // {
684
+ // "symbol": "BNB-USD",
685
+ // "pricePrecision": 2,
686
+ // "minTickSize": "10",
687
+ // "minTradeValue": "10",
688
+ // "minQty": "1.00000000",
689
+ // "status": 1,
690
+ // "timeOnline": 1713175200000
691
+ // },
692
+ // ]
693
+ // }
694
+ //
695
+ const markets = this.safeList(response, 'data', []);
696
+ return this.parseMarkets(markets);
697
+ }
675
698
  parseMarket(market) {
676
699
  const id = this.safeString(market, 'symbol');
677
700
  const symbolParts = id.split('-');
@@ -679,7 +702,16 @@ export default class bingx extends Exchange {
679
702
  const quoteId = symbolParts[1];
680
703
  const base = this.safeCurrencyCode(baseId);
681
704
  const quote = this.safeCurrencyCode(quoteId);
682
- const currency = this.safeString(market, 'currency');
705
+ let currency = this.safeString(market, 'currency');
706
+ let checkIsInverse = false;
707
+ let checkIsLinear = true;
708
+ const minTickSize = this.safeNumber(market, 'minTickSize');
709
+ if (minTickSize !== undefined) {
710
+ // inverse swap market
711
+ currency = baseId;
712
+ checkIsInverse = true;
713
+ checkIsLinear = false;
714
+ }
683
715
  const settle = this.safeCurrencyCode(currency);
684
716
  let pricePrecision = this.safeNumber(market, 'tickSize');
685
717
  if (pricePrecision === undefined) {
@@ -699,8 +731,12 @@ export default class bingx extends Exchange {
699
731
  const fees = this.safeDict(this.fees, type, {});
700
732
  const contractSize = (swap) ? this.parseNumber('1') : undefined;
701
733
  const isActive = this.safeString(market, 'status') === '1';
702
- const isInverse = (spot) ? undefined : false;
703
- const isLinear = (spot) ? undefined : swap;
734
+ const isInverse = (spot) ? undefined : checkIsInverse;
735
+ const isLinear = (spot) ? undefined : checkIsLinear;
736
+ let timeOnline = this.safeInteger(market, 'timeOnline');
737
+ if (timeOnline === 0) {
738
+ timeOnline = undefined;
739
+ }
704
740
  return this.safeMarketStructure({
705
741
  'id': id,
706
742
  'symbol': symbol,
@@ -742,15 +778,15 @@ export default class bingx extends Exchange {
742
778
  'max': this.safeNumber(market, 'maxQty'),
743
779
  },
744
780
  'price': {
745
- 'min': undefined,
781
+ 'min': minTickSize,
746
782
  'max': undefined,
747
783
  },
748
784
  'cost': {
749
- 'min': this.safeNumber2(market, 'minNotional', 'tradeMinUSDT'),
785
+ 'min': this.safeNumberN(market, ['minNotional', 'tradeMinUSDT', 'minTradeValue']),
750
786
  'max': this.safeNumber(market, 'maxNotional'),
751
787
  },
752
788
  },
753
- 'created': undefined,
789
+ 'created': timeOnline,
754
790
  'info': market,
755
791
  });
756
792
  }
@@ -761,17 +797,21 @@ export default class bingx extends Exchange {
761
797
  * @description retrieves data on all markets for bingx
762
798
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20Symbols
763
799
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Contract%20Information
800
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Contract%20Information
764
801
  * @param {object} [params] extra parameters specific to the exchange API endpoint
765
802
  * @returns {object[]} an array of objects representing market data
766
803
  */
767
804
  const requests = [this.fetchSwapMarkets(params)];
768
805
  const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
769
806
  if (!isSandbox) {
807
+ requests.push(this.fetchInverseSwapMarkets(params));
770
808
  requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
771
809
  }
772
810
  const promises = await Promise.all(requests);
773
- const spotMarkets = this.safeList(promises, 0, []);
774
- const swapMarkets = this.safeList(promises, 1, []);
811
+ const linearSwapMarkets = this.safeList(promises, 0, []);
812
+ const inverseSwapMarkets = this.safeList(promises, 1, []);
813
+ const spotMarkets = this.safeList(promises, 2, []);
814
+ const swapMarkets = this.arrayConcat(linearSwapMarkets, inverseSwapMarkets);
775
815
  return this.arrayConcat(spotMarkets, swapMarkets);
776
816
  }
777
817
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
@@ -783,13 +823,14 @@ export default class bingx extends Exchange {
783
823
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
784
824
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
785
825
  * @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#K-Line%20Data%20-%20Mark%20Price
826
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20K-line%20Data
786
827
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
787
828
  * @param {string} timeframe the length of time each candle represents
788
829
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
789
830
  * @param {int} [limit] the maximum amount of candles to fetch
790
831
  * @param {object} [params] extra parameters specific to the exchange API endpoint
791
832
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
792
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
833
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
793
834
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
794
835
  */
795
836
  await this.loadMarkets();
@@ -819,13 +860,18 @@ export default class bingx extends Exchange {
819
860
  response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
820
861
  }
821
862
  else {
822
- const price = this.safeString(params, 'price');
823
- params = this.omit(params, 'price');
824
- if (price === 'mark') {
825
- response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
863
+ if (market['inverse']) {
864
+ response = await this.cswapV1PublicGetMarketKlines(this.extend(request, params));
826
865
  }
827
866
  else {
828
- response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
867
+ const price = this.safeString(params, 'price');
868
+ params = this.omit(params, 'price');
869
+ if (price === 'mark') {
870
+ response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
871
+ }
872
+ else {
873
+ response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
874
+ }
829
875
  }
830
876
  }
831
877
  //
@@ -1137,6 +1183,7 @@ export default class bingx extends Exchange {
1137
1183
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1138
1184
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20depth%20information
1139
1185
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Market%20Depth
1186
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%20Depth%20Data
1140
1187
  * @param {string} symbol unified symbol of the market to fetch the order book for
1141
1188
  * @param {int} [limit] the maximum amount of order book entries to return
1142
1189
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1157,7 +1204,12 @@ export default class bingx extends Exchange {
1157
1204
  response = await this.spotV1PublicGetMarketDepth(this.extend(request, params));
1158
1205
  }
1159
1206
  else {
1160
- response = await this.swapV2PublicGetQuoteDepth(this.extend(request, params));
1207
+ if (market['inverse']) {
1208
+ response = await this.cswapV1PublicGetMarketDepth(this.extend(request, params));
1209
+ }
1210
+ else {
1211
+ response = await this.swapV2PublicGetQuoteDepth(this.extend(request, params));
1212
+ }
1161
1213
  }
1162
1214
  //
1163
1215
  // spot
@@ -1226,6 +1278,7 @@ export default class bingx extends Exchange {
1226
1278
  * @name bingx#fetchFundingRate
1227
1279
  * @description fetch the current funding rate
1228
1280
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
1281
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Price%20&%20Current%20Funding%20Rate
1229
1282
  * @param {string} symbol unified market symbol
1230
1283
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1231
1284
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -1235,7 +1288,13 @@ export default class bingx extends Exchange {
1235
1288
  const request = {
1236
1289
  'symbol': market['id'],
1237
1290
  };
1238
- const response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(request, params));
1291
+ let response = undefined;
1292
+ if (market['inverse']) {
1293
+ response = await this.cswapV1PublicGetMarketPremiumIndex(this.extend(request, params));
1294
+ }
1295
+ else {
1296
+ response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(request, params));
1297
+ }
1239
1298
  //
1240
1299
  // {
1241
1300
  // "code":0,
@@ -1387,9 +1446,10 @@ export default class bingx extends Exchange {
1387
1446
  /**
1388
1447
  * @method
1389
1448
  * @name bingx#fetchOpenInterest
1390
- * @description Retrieves the open interest of a currency
1449
+ * @description retrieves the open interest of a trading pair
1391
1450
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Swap%20Open%20Positions
1392
- * @param {string} symbol Unified CCXT market symbol
1451
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20Swap%20Open%20Positions
1452
+ * @param {string} symbol unified CCXT market symbol
1393
1453
  * @param {object} [params] exchange specific parameters
1394
1454
  * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
1395
1455
  */
@@ -1398,7 +1458,15 @@ export default class bingx extends Exchange {
1398
1458
  const request = {
1399
1459
  'symbol': market['id'],
1400
1460
  };
1401
- const response = await this.swapV2PublicGetQuoteOpenInterest(this.extend(request, params));
1461
+ let response = undefined;
1462
+ if (market['inverse']) {
1463
+ response = await this.cswapV1PublicGetMarketOpenInterest(this.extend(request, params));
1464
+ }
1465
+ else {
1466
+ response = await this.swapV2PublicGetQuoteOpenInterest(this.extend(request, params));
1467
+ }
1468
+ //
1469
+ // linear swap
1402
1470
  //
1403
1471
  // {
1404
1472
  // "code": 0,
@@ -1410,18 +1478,50 @@ export default class bingx extends Exchange {
1410
1478
  // }
1411
1479
  // }
1412
1480
  //
1413
- const data = this.safeDict(response, 'data', {});
1414
- return this.parseOpenInterest(data, market);
1481
+ // inverse swap
1482
+ //
1483
+ // {
1484
+ // "code": 0,
1485
+ // "msg": "",
1486
+ // "timestamp": 1720328247986,
1487
+ // "data": [
1488
+ // {
1489
+ // "symbol": "BTC-USD",
1490
+ // "openInterest": "749.1160",
1491
+ // "timestamp": 1720310400000
1492
+ // }
1493
+ // ]
1494
+ // }
1495
+ //
1496
+ let result = {};
1497
+ if (market['inverse']) {
1498
+ const data = this.safeList(response, 'data', []);
1499
+ result = this.safeDict(data, 0, {});
1500
+ }
1501
+ else {
1502
+ result = this.safeDict(response, 'data', {});
1503
+ }
1504
+ return this.parseOpenInterest(result, market);
1415
1505
  }
1416
1506
  parseOpenInterest(interest, market = undefined) {
1417
1507
  //
1418
- // {
1419
- // "openInterest": "3289641547.10",
1420
- // "symbol": "BTC-USDT",
1421
- // "time": 1672026617364
1422
- // }
1508
+ // linear swap
1509
+ //
1510
+ // {
1511
+ // "openInterest": "3289641547.10",
1512
+ // "symbol": "BTC-USDT",
1513
+ // "time": 1672026617364
1514
+ // }
1515
+ //
1516
+ // inverse swap
1517
+ //
1518
+ // {
1519
+ // "symbol": "BTC-USD",
1520
+ // "openInterest": "749.1160",
1521
+ // "timestamp": 1720310400000
1522
+ // }
1423
1523
  //
1424
- const timestamp = this.safeInteger(interest, 'time');
1524
+ const timestamp = this.safeInteger2(interest, 'time', 'timestamp');
1425
1525
  const id = this.safeString(interest, 'symbol');
1426
1526
  const symbol = this.safeSymbol(id, market, '-', 'swap');
1427
1527
  const openInterest = this.safeNumber(interest, 'openInterest');
@@ -64,7 +64,7 @@ export default class bitget extends Exchange {
64
64
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
65
65
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
66
66
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
67
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
67
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
68
68
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
69
69
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
70
70
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/bitget.js CHANGED
@@ -5015,6 +5015,22 @@ export default class bitget extends Exchange {
5015
5015
  else {
5016
5016
  response = await this.privateMarginPostMarginV1IsolatedOrderBatchCancelOrder(this.extend(request, params));
5017
5017
  }
5018
+ //
5019
+ // {
5020
+ // "code": "00000",
5021
+ // "msg": "success",
5022
+ // "requestTime": 1700717155622,
5023
+ // "data": {
5024
+ // "resultList": [
5025
+ // {
5026
+ // "orderId": "1111453253721796609",
5027
+ // "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
5028
+ // },
5029
+ // ],
5030
+ // "failure": []
5031
+ // }
5032
+ // }
5033
+ //
5018
5034
  }
5019
5035
  else {
5020
5036
  if (stop) {
@@ -5026,6 +5042,27 @@ export default class bitget extends Exchange {
5026
5042
  else {
5027
5043
  response = await this.privateSpotPostV2SpotTradeCancelSymbolOrder(this.extend(request, params));
5028
5044
  }
5045
+ //
5046
+ // {
5047
+ // "code": "00000",
5048
+ // "msg": "success",
5049
+ // "requestTime": 1700716953996,
5050
+ // "data": {
5051
+ // "symbol": "BTCUSDT"
5052
+ // }
5053
+ // }
5054
+ //
5055
+ const timestamp = this.safeInteger(response, 'requestTime');
5056
+ const responseData = this.safeDict(response, 'data');
5057
+ const marketId = this.safeString(responseData, 'symbol');
5058
+ return [
5059
+ this.safeOrder({
5060
+ 'info': response,
5061
+ 'symbol': this.safeSymbol(marketId, undefined, undefined, 'spot'),
5062
+ 'timestamp': timestamp,
5063
+ 'datetime': this.iso8601(timestamp),
5064
+ }),
5065
+ ];
5029
5066
  }
5030
5067
  }
5031
5068
  else {
@@ -5038,54 +5075,26 @@ export default class bitget extends Exchange {
5038
5075
  else {
5039
5076
  response = await this.privateMixPostV2MixOrderBatchCancelOrders(this.extend(request, params));
5040
5077
  }
5078
+ // {
5079
+ // "code": "00000",
5080
+ // "msg": "success",
5081
+ // "requestTime": "1680008815965",
5082
+ // "data": {
5083
+ // "successList": [
5084
+ // {
5085
+ // "orderId": "1024598257429823488",
5086
+ // "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
5087
+ // },
5088
+ // ],
5089
+ // "failureList": []
5090
+ // }
5091
+ // }
5041
5092
  }
5042
- //
5043
- // spot
5044
- //
5045
- // {
5046
- // "code": "00000",
5047
- // "msg": "success",
5048
- // "requestTime": 1700716953996,
5049
- // "data": {
5050
- // "symbol": "BTCUSDT"
5051
- // }
5052
- // }
5053
- //
5054
- // swap
5055
- //
5056
- // {
5057
- // "code": "00000",
5058
- // "msg": "success",
5059
- // "requestTime": "1680008815965",
5060
- // "data": {
5061
- // "successList": [
5062
- // {
5063
- // "orderId": "1024598257429823488",
5064
- // "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
5065
- // },
5066
- // ],
5067
- // "failureList": []
5068
- // }
5069
- // }
5070
- //
5071
- // spot margin
5072
- //
5073
- // {
5074
- // "code": "00000",
5075
- // "msg": "success",
5076
- // "requestTime": 1700717155622,
5077
- // "data": {
5078
- // "resultList": [
5079
- // {
5080
- // "orderId": "1111453253721796609",
5081
- // "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
5082
- // },
5083
- // ],
5084
- // "failure": []
5085
- // }
5086
- // }
5087
- //
5088
- return response;
5093
+ const data = this.safeDict(response, 'data');
5094
+ const resultList = this.safeList2(data, 'resultList', 'successList');
5095
+ const failureList = this.safeList2(data, 'failure', 'failureList');
5096
+ const responseList = this.arrayConcat(resultList, failureList);
5097
+ return this.parseOrders(responseList);
5089
5098
  }
5090
5099
  async fetchOrder(id, symbol = undefined, params = {}) {
5091
5100
  /**
@@ -21,7 +21,7 @@ export default class coinmate extends Exchange {
21
21
  'id': 'coinmate',
22
22
  'name': 'CoinMate',
23
23
  'countries': ['GB', 'CZ', 'EU'],
24
- 'rateLimit': 1000,
24
+ 'rateLimit': 600,
25
25
  'has': {
26
26
  'CORS': true,
27
27
  'spot': true,
@@ -170,28 +170,28 @@ export default class coinmate extends Exchange {
170
170
  'trading': {
171
171
  'tierBased': true,
172
172
  'percentage': true,
173
- 'maker': this.parseNumber('0.0012'),
174
- 'taker': this.parseNumber('0.0025'),
173
+ 'taker': this.parseNumber('0.006'),
174
+ 'maker': this.parseNumber('0.004'),
175
175
  'tiers': {
176
176
  'taker': [
177
- [this.parseNumber('0'), this.parseNumber('0.0035')],
178
- [this.parseNumber('10000'), this.parseNumber('0.0023')],
179
- [this.parseNumber('100000'), this.parseNumber('0.0021')],
180
- [this.parseNumber('250000'), this.parseNumber('0.0020')],
181
- [this.parseNumber('500000'), this.parseNumber('0.0015')],
182
- [this.parseNumber('1000000'), this.parseNumber('0.0013')],
183
- [this.parseNumber('3000000'), this.parseNumber('0.0010')],
184
- [this.parseNumber('15000000'), this.parseNumber('0.0005')],
177
+ [this.parseNumber('0'), this.parseNumber('0.006')],
178
+ [this.parseNumber('10000'), this.parseNumber('0.003')],
179
+ [this.parseNumber('100000'), this.parseNumber('0.0023')],
180
+ [this.parseNumber('250000'), this.parseNumber('0.0021')],
181
+ [this.parseNumber('500000'), this.parseNumber('0.0018')],
182
+ [this.parseNumber('1000000'), this.parseNumber('0.0015')],
183
+ [this.parseNumber('3000000'), this.parseNumber('0.0012')],
184
+ [this.parseNumber('15000000'), this.parseNumber('0.001')],
185
185
  ],
186
186
  'maker': [
187
- [this.parseNumber('0'), this.parseNumber('0.003')],
188
- [this.parseNumber('10000'), this.parseNumber('0.0011')],
189
- [this.parseNumber('100000'), this.parseNumber('0.0010')],
190
- [this.parseNumber('250000'), this.parseNumber('0.0008')],
187
+ [this.parseNumber('0'), this.parseNumber('0.004')],
188
+ [this.parseNumber('10000'), this.parseNumber('0.002')],
189
+ [this.parseNumber('100000'), this.parseNumber('0.0012')],
190
+ [this.parseNumber('250000'), this.parseNumber('0.0009')],
191
191
  [this.parseNumber('500000'), this.parseNumber('0.0005')],
192
192
  [this.parseNumber('1000000'), this.parseNumber('0.0003')],
193
193
  [this.parseNumber('3000000'), this.parseNumber('0.0002')],
194
- [this.parseNumber('15000000'), this.parseNumber('0')],
194
+ [this.parseNumber('15000000'), this.parseNumber('-0.0004')],
195
195
  ],
196
196
  },
197
197
  },
@@ -1096,26 +1096,19 @@ export default class coinmate extends Exchange {
1096
1096
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1097
1097
  }
1098
1098
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1099
- if (response !== undefined) {
1100
- if ('error' in response) {
1101
- // {"error":true,"errorMessage":"Minimum Order Size 0.01 ETH","data":null}
1102
- if (response['error']) {
1103
- const message = this.safeString(response, 'errorMessage');
1104
- const feedback = this.id + ' ' + message;
1105
- this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1106
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1107
- throw new ExchangeError(this.id + ' ' + this.json(response));
1108
- }
1109
- }
1099
+ if (response === undefined) {
1100
+ return undefined; // fallback to default error handler
1110
1101
  }
1111
- if (code > 400) {
1112
- if (body) {
1113
- const feedback = this.id + ' ' + body;
1114
- this.throwExactlyMatchedException(this.exceptions['exact'], body, feedback);
1115
- this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
1116
- throw new ExchangeError(feedback); // unknown message
1117
- }
1118
- throw new ExchangeError(this.id + ' ' + body);
1102
+ //
1103
+ // {"error":true,"errorMessage":"Api internal error","data":null}
1104
+ // {"error":true,"errorMessage":"Access denied.","data":null}
1105
+ //
1106
+ const errorMessage = this.safeString(response, 'errorMessage');
1107
+ if (errorMessage !== undefined) {
1108
+ const feedback = this.id + ' ' + body;
1109
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorMessage, feedback);
1110
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
1111
+ throw new ExchangeError(feedback); // unknown message
1119
1112
  }
1120
1113
  return undefined;
1121
1114
  }