ccxt 4.3.55 → 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.
Files changed (50) hide show
  1. package/README.md +3 -5
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +26 -2
  5. package/dist/cjs/src/base/ws/Client.js +34 -4
  6. package/dist/cjs/src/binance.js +7 -7
  7. package/dist/cjs/src/bingx.js +83 -9
  8. package/dist/cjs/src/bitflyer.js +7 -1
  9. package/dist/cjs/src/bitget.js +56 -47
  10. package/dist/cjs/src/bitopro.js +20 -3
  11. package/dist/cjs/src/btcmarkets.js +26 -27
  12. package/dist/cjs/src/bybit.js +9 -5
  13. package/dist/cjs/src/coinone.js +13 -19
  14. package/dist/cjs/src/delta.js +5 -1
  15. package/dist/cjs/src/gate.js +109 -1
  16. package/dist/cjs/src/htx.js +88 -25
  17. package/dist/cjs/src/huobijp.js +65 -2
  18. package/dist/cjs/src/hyperliquid.js +1 -1
  19. package/dist/cjs/src/lbank.js +27 -6
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/bingx.d.ts +16 -0
  23. package/js/src/base/Exchange.d.ts +1 -0
  24. package/js/src/base/Exchange.js +26 -2
  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/binance.js +7 -7
  28. package/js/src/bingx.d.ts +1 -0
  29. package/js/src/bingx.js +83 -9
  30. package/js/src/bitflyer.d.ts +1 -1
  31. package/js/src/bitflyer.js +7 -1
  32. package/js/src/bitget.d.ts +1 -1
  33. package/js/src/bitget.js +56 -47
  34. package/js/src/bitopro.d.ts +3 -2
  35. package/js/src/bitopro.js +20 -3
  36. package/js/src/btcmarkets.js +27 -28
  37. package/js/src/bybit.js +9 -5
  38. package/js/src/coinone.js +13 -19
  39. package/js/src/delta.d.ts +1 -1
  40. package/js/src/delta.js +5 -1
  41. package/js/src/gate.d.ts +3 -1
  42. package/js/src/gate.js +109 -1
  43. package/js/src/htx.d.ts +3 -2
  44. package/js/src/htx.js +88 -25
  45. package/js/src/huobijp.d.ts +3 -2
  46. package/js/src/huobijp.js +65 -2
  47. package/js/src/hyperliquid.js +1 -1
  48. package/js/src/lbank.d.ts +2 -2
  49. package/js/src/lbank.js +27 -6
  50. package/package.json +7 -3
@@ -3058,16 +3058,20 @@ class bybit extends bybit$1 {
3058
3058
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
3059
3059
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
3060
3060
  let type = undefined;
3061
- [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
3061
+ [type, params] = this.getBybitType('fetchBalance', undefined, params);
3062
3062
  const isSpot = (type === 'spot');
3063
- const isSwap = (type === 'swap');
3063
+ const isLinear = (type === 'linear');
3064
+ const isInverse = (type === 'inverse');
3064
3065
  if (isUnifiedAccount) {
3065
- if (isSpot || isSwap) {
3066
+ if (isInverse) {
3067
+ type = 'contract';
3068
+ }
3069
+ else {
3066
3070
  type = 'unified';
3067
3071
  }
3068
3072
  }
3069
3073
  else {
3070
- if (isSwap) {
3074
+ if (isLinear || isInverse) {
3071
3075
  type = 'contract';
3072
3076
  }
3073
3077
  }
@@ -3387,7 +3391,7 @@ class bybit extends bybit$1 {
3387
3391
  feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
3388
3392
  }
3389
3393
  fee = {
3390
- 'cost': feeCostString,
3394
+ 'cost': this.parseNumber(feeCostString),
3391
3395
  'currency': feeCurrencyCode,
3392
3396
  };
3393
3397
  }
@@ -18,8 +18,7 @@ class coinone extends coinone$1 {
18
18
  'id': 'coinone',
19
19
  'name': 'CoinOne',
20
20
  'countries': ['KR'],
21
- // 'enableRateLimit': false,
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
- '107': errors.BadRequest, // {"errorCode":"107","errorMsg":"Parameter error","result":"error"}
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
- else {
1182
- throw new errors.ExchangeError(this.id + ' ' + body);
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
  }
@@ -2012,7 +2012,11 @@ class delta extends delta$1 {
2012
2012
  // "success":true
2013
2013
  // }
2014
2014
  //
2015
- return response;
2015
+ return [
2016
+ this.safeOrder({
2017
+ 'info': response,
2018
+ }),
2019
+ ];
2016
2020
  }
2017
2021
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2018
2022
  /**
@@ -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,
@@ -622,6 +624,7 @@ class gate extends gate$1 {
622
624
  'createOrder': {
623
625
  'expiration': 86400, // for conditional orders
624
626
  },
627
+ 'createMarketBuyOrderRequiresPrice': true,
625
628
  'networks': {
626
629
  'AVAXC': 'AVAX_C',
627
630
  'BEP20': 'BSC',
@@ -4466,6 +4469,8 @@ class gate extends gate$1 {
4466
4469
  // "message": "Not enough balance"
4467
4470
  // }
4468
4471
  //
4472
+ // {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
4473
+ //
4469
4474
  const succeeded = this.safeBool(order, 'succeeded', true);
4470
4475
  if (!succeeded) {
4471
4476
  // cancelOrders response
@@ -4473,6 +4478,7 @@ class gate extends gate$1 {
4473
4478
  'clientOrderId': this.safeString(order, 'text'),
4474
4479
  'info': order,
4475
4480
  'status': 'rejected',
4481
+ 'id': this.safeString(order, 'id'),
4476
4482
  });
4477
4483
  }
4478
4484
  const put = this.safeValue2(order, 'put', 'initial', {});
@@ -5072,6 +5078,92 @@ class gate extends gate$1 {
5072
5078
  //
5073
5079
  return this.parseOrder(response, market);
5074
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
+ }
5075
5167
  async cancelAllOrders(symbol = undefined, params = {}) {
5076
5168
  /**
5077
5169
  * @method
@@ -6076,7 +6168,22 @@ class gate extends gate$1 {
6076
6168
  const authentication = api[0]; // public, private
6077
6169
  const type = api[1]; // spot, margin, future, delivery
6078
6170
  let query = this.omit(params, this.extractParams(path));
6079
- if (Array.isArray(params)) {
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)) {
6080
6187
  // endpoints like createOrders use an array instead of an object
6081
6188
  // so we infer the settle from one of the elements
6082
6189
  // they have to be all the same so relying on the first one is fine
@@ -7549,6 +7656,7 @@ class gate extends gate$1 {
7549
7656
  // {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: Trigger.rule"}
7550
7657
  // {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: trigger.expiration invalid range"}
7551
7658
  // {"label": "INVALID_ARGUMENT", "detail": "invalid size"}
7659
+ // {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
7552
7660
  //
7553
7661
  const label = this.safeString(response, 'label');
7554
7662
  if (label !== undefined) {
@@ -6026,7 +6026,66 @@ class htx extends htx$1 {
6026
6026
  // "ts": 1604367997451
6027
6027
  // }
6028
6028
  //
6029
- return response;
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
  /**
@@ -1545,7 +1545,65 @@ class huobijp extends huobijp$1 {
1545
1545
  // }
1546
1546
  // }
1547
1547
  //
1548
- return response;
1548
+ return this.parseCancelOrders(response);
1549
+ }
1550
+ parseCancelOrders(orders) {
1551
+ //
1552
+ // {
1553
+ // "success": [
1554
+ // "5983466"
1555
+ // ],
1556
+ // "failed": [
1557
+ // {
1558
+ // "err-msg": "Incorrect order state",
1559
+ // "order-state": 7,
1560
+ // "order-id": "",
1561
+ // "err-code": "order-orderstate-error",
1562
+ // "client-order-id": "first"
1563
+ // },
1564
+ // ...
1565
+ // ]
1566
+ // }
1567
+ //
1568
+ // {
1569
+ // "errors": [
1570
+ // {
1571
+ // "order_id": "769206471845261312",
1572
+ // "err_code": 1061,
1573
+ // "err_msg": "This order doesnt exist."
1574
+ // }
1575
+ // ],
1576
+ // "successes": "1258075374411399168,1258075393254871040"
1577
+ // }
1578
+ //
1579
+ const successes = this.safeString(orders, 'successes');
1580
+ let success = undefined;
1581
+ if (successes !== undefined) {
1582
+ success = successes.split(',');
1583
+ }
1584
+ else {
1585
+ success = this.safeList(orders, 'success', []);
1586
+ }
1587
+ const failed = this.safeList2(orders, 'errors', 'failed', []);
1588
+ const result = [];
1589
+ for (let i = 0; i < success.length; i++) {
1590
+ const order = success[i];
1591
+ result.push(this.safeOrder({
1592
+ 'info': order,
1593
+ 'id': order,
1594
+ 'status': 'canceled',
1595
+ }));
1596
+ }
1597
+ for (let i = 0; i < failed.length; i++) {
1598
+ const order = failed[i];
1599
+ result.push(this.safeOrder({
1600
+ 'info': order,
1601
+ 'id': this.safeString2(order, 'order-id', 'order_id'),
1602
+ 'status': 'failed',
1603
+ 'clientOrderId': this.safeString(order, 'client-order-id'),
1604
+ }));
1605
+ }
1606
+ return result;
1549
1607
  }
1550
1608
  async cancelAllOrders(symbol = undefined, params = {}) {
1551
1609
  /**
@@ -1580,7 +1638,12 @@ class huobijp extends huobijp$1 {
1580
1638
  // }
1581
1639
  // }
1582
1640
  //
1583
- return response;
1641
+ const data = this.safeDict(response, 'data', {});
1642
+ return [
1643
+ this.safeOrder({
1644
+ 'info': data,
1645
+ }),
1646
+ ];
1584
1647
  }
1585
1648
  currencyToPrecision(code, fee, networkCode = undefined) {
1586
1649
  return this.decimalToPrecision(fee, 0, this.currencies[code]['precision'], this.precisionMode);
@@ -593,7 +593,7 @@ class hyperliquid extends hyperliquid$1 {
593
593
  'limits': {
594
594
  'leverage': {
595
595
  'min': undefined,
596
- 'max': undefined,
596
+ 'max': this.safeInteger(market, 'maxLeverage'),
597
597
  },
598
598
  'amount': {
599
599
  'min': undefined,
@@ -1486,6 +1486,27 @@ class lbank extends lbank$1 {
1486
1486
  // "status":-1
1487
1487
  // }
1488
1488
  //
1489
+ // cancelOrder
1490
+ //
1491
+ // {
1492
+ // "executedQty":0.0,
1493
+ // "price":0.05,
1494
+ // "origQty":100.0,
1495
+ // "tradeType":"buy",
1496
+ // "status":0
1497
+ // }
1498
+ //
1499
+ // cancelAllOrders
1500
+ //
1501
+ // {
1502
+ // "executedQty":0.00000000000000000000,
1503
+ // "orderId":"293ef71b-3e67-4962-af93-aa06990a045f",
1504
+ // "price":0.05000000000000000000,
1505
+ // "origQty":100.00000000000000000000,
1506
+ // "tradeType":"buy",
1507
+ // "status":0
1508
+ // }
1509
+ //
1489
1510
  const id = this.safeString2(order, 'orderId', 'order_id');
1490
1511
  const clientOrderId = this.safeString2(order, 'clientOrderId', 'custom_id');
1491
1512
  const timestamp = this.safeInteger2(order, 'time', 'create_time');
@@ -1495,7 +1516,7 @@ class lbank extends lbank$1 {
1495
1516
  let timeInForce = undefined;
1496
1517
  let postOnly = false;
1497
1518
  let type = 'limit';
1498
- const rawType = this.safeString(order, 'type'); // buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
1519
+ const rawType = this.safeString2(order, 'type', 'tradeType'); // buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
1499
1520
  const parts = rawType.split('_');
1500
1521
  const side = this.safeString(parts, 0);
1501
1522
  const typePart = this.safeString(parts, 1); // market, maker, ioc, fok or undefined (limit)
@@ -1859,12 +1880,12 @@ class lbank extends lbank$1 {
1859
1880
  // "origQty":100.0,
1860
1881
  // "tradeType":"buy",
1861
1882
  // "status":0
1862
- // },
1883
+ // },
1863
1884
  // "error_code":0,
1864
1885
  // "ts":1648501286196
1865
1886
  // }
1866
- const result = this.safeValue(response, 'data', {});
1867
- return result;
1887
+ const data = this.safeDict(response, 'data', {});
1888
+ return this.parseOrder(data);
1868
1889
  }
1869
1890
  async cancelAllOrders(symbol = undefined, params = {}) {
1870
1891
  /**
@@ -1902,8 +1923,8 @@ class lbank extends lbank$1 {
1902
1923
  // "ts":1648506641469
1903
1924
  // }
1904
1925
  //
1905
- const result = this.safeValue(response, 'data', []);
1906
- return result;
1926
+ const data = this.safeList(response, 'data', []);
1927
+ return this.parseOrders(data);
1907
1928
  }
1908
1929
  getNetworkCodeForCurrency(currencyCode, params) {
1909
1930
  const defaultNetworks = this.safeValue(this.options, 'defaultNetworks');
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 type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, TransferEntries, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.54";
7
+ declare const version = "4.3.56";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.55';
41
+ const version = '4.3.57';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -75,6 +75,22 @@ interface Exchange {
75
75
  swapV2PrivateDeleteTradeBatchOrders(params?: {}): Promise<implicitReturnType>;
76
76
  swapV2PrivateDeleteTradeAllOpenOrders(params?: {}): Promise<implicitReturnType>;
77
77
  swapV3PublicGetQuoteKlines(params?: {}): Promise<implicitReturnType>;
78
+ cswapV1PublicGetMarketContracts(params?: {}): Promise<implicitReturnType>;
79
+ cswapV1PublicGetMarketPremiumIndex(params?: {}): Promise<implicitReturnType>;
80
+ cswapV1PublicGetMarketOpenInterest(params?: {}): Promise<implicitReturnType>;
81
+ cswapV1PublicGetMarketKlines(params?: {}): Promise<implicitReturnType>;
82
+ cswapV1PublicGetMarketDepth(params?: {}): Promise<implicitReturnType>;
83
+ cswapV1PublicGetMarketTicker(params?: {}): Promise<implicitReturnType>;
84
+ cswapV1PrivateGetTradeLeverage(params?: {}): Promise<implicitReturnType>;
85
+ cswapV1PrivateGetTradeForceOrders(params?: {}): Promise<implicitReturnType>;
86
+ cswapV1PrivateGetTradeAllFillOrders(params?: {}): Promise<implicitReturnType>;
87
+ cswapV1PrivateGetUserCommissionRate(params?: {}): Promise<implicitReturnType>;
88
+ cswapV1PrivateGetUserPositions(params?: {}): Promise<implicitReturnType>;
89
+ cswapV1PrivateGetUserBalance(params?: {}): Promise<implicitReturnType>;
90
+ cswapV1PrivatePostTradeOrder(params?: {}): Promise<implicitReturnType>;
91
+ cswapV1PrivatePostTradeLeverage(params?: {}): Promise<implicitReturnType>;
92
+ cswapV1PrivatePostTradeAllOpenOrders(params?: {}): Promise<implicitReturnType>;
93
+ cswapV1PrivatePostTradeCloseAllPositions(params?: {}): Promise<implicitReturnType>;
78
94
  contractV1PrivateGetAllPosition(params?: {}): Promise<implicitReturnType>;
79
95
  contractV1PrivateGetAllOrders(params?: {}): Promise<implicitReturnType>;
80
96
  contractV1PrivateGetBalance(params?: {}): Promise<implicitReturnType>;
@@ -15,6 +15,7 @@ export default class Exchange {
15
15
  [key: string]: any;
16
16
  };
17
17
  throttleProp: any;
18
+ sleep: (ms: any) => Promise<unknown>;
18
19
  api: any;
19
20
  proxy: any;
20
21
  proxyUrl: string;
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------
8
8
  /* eslint-disable */
9
9
  import * as functions from './functions.js';
10
- const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS } = functions;
10
+ const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
11
11
  import { keys as keysFunc, values as valuesFunc, vwap as vwapFunc } from './functions.js';
12
12
  // import exceptions from "./errors.js"
13
13
  import { // eslint-disable-line object-curly-newline
@@ -31,6 +31,7 @@ import { SecureRandom } from "../static_dependencies/jsencrypt/lib/jsbn/rng.js";
31
31
  export default class Exchange {
32
32
  constructor(userConfig = {}) {
33
33
  this.throttleProp = undefined;
34
+ this.sleep = sleep;
34
35
  this.api = undefined;
35
36
  this.userAgent = undefined;
36
37
  this.user_agent = undefined;
@@ -3792,7 +3793,30 @@ export default class Exchange {
3792
3793
  this.last_request_headers = request['headers'];
3793
3794
  this.last_request_body = request['body'];
3794
3795
  this.last_request_url = request['url'];
3795
- return await this.fetch(request['url'], request['method'], request['headers'], request['body']);
3796
+ let retries = undefined;
3797
+ [retries, params] = this.handleOptionAndParams(params, path, 'maxRetriesOnFailure', 0);
3798
+ let retryDelay = undefined;
3799
+ [retryDelay, params] = this.handleOptionAndParams(params, path, 'maxRetriesOnFailureDelay', 0);
3800
+ for (let i = 0; i < retries + 1; i++) {
3801
+ try {
3802
+ return await this.fetch(request['url'], request['method'], request['headers'], request['body']);
3803
+ }
3804
+ catch (e) {
3805
+ if (e instanceof NetworkError) {
3806
+ if (i < retries) {
3807
+ if (this.verbose) {
3808
+ this.log('Request failed with the error: ' + e.toString() + ', retrying ' + (i + 1).toString() + ' of ' + retries.toString() + '...');
3809
+ }
3810
+ if ((retryDelay !== undefined) && (retryDelay !== 0)) {
3811
+ await this.sleep(retryDelay);
3812
+ }
3813
+ continue;
3814
+ }
3815
+ }
3816
+ throw e;
3817
+ }
3818
+ }
3819
+ return undefined; // this line is never reached, but exists for c# value return requirement
3796
3820
  }
3797
3821
  async request(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined, config = {}) {
3798
3822
  return await this.fetch2(path, api, method, params, headers, body, config);