ccxt 4.3.89 → 4.3.91

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 (69) 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 +2 -2
  5. package/dist/cjs/src/ascendex.js +95 -97
  6. package/dist/cjs/src/binance.js +1 -1
  7. package/dist/cjs/src/bingx.js +31 -17
  8. package/dist/cjs/src/bitfinex2.js +21 -22
  9. package/dist/cjs/src/bitget.js +2 -2
  10. package/dist/cjs/src/bitmart.js +6 -9
  11. package/dist/cjs/src/coinbaseinternational.js +2 -1
  12. package/dist/cjs/src/coinex.js +1 -17
  13. package/dist/cjs/src/hitbtc.js +2 -0
  14. package/dist/cjs/src/htx.js +49 -49
  15. package/dist/cjs/src/huobijp.js +0 -9
  16. package/dist/cjs/src/kucoin.js +59 -21
  17. package/dist/cjs/src/kucoinfutures.js +26 -2
  18. package/dist/cjs/src/latoken.js +1 -0
  19. package/dist/cjs/src/okx.js +1 -8
  20. package/dist/cjs/src/pro/binance.js +323 -0
  21. package/dist/cjs/src/pro/bingx.js +263 -91
  22. package/dist/cjs/src/pro/bithumb.js +5 -1
  23. package/dist/cjs/src/pro/bybit.js +1 -1
  24. package/dist/cjs/src/pro/coinex.js +994 -679
  25. package/dist/cjs/src/pro/lbank.js +2 -3
  26. package/dist/cjs/src/pro/okx.js +159 -3
  27. package/dist/cjs/src/whitebit.js +5 -3
  28. package/dist/cjs/src/woo.js +1 -1
  29. package/js/ccxt.d.ts +1 -1
  30. package/js/ccxt.js +1 -1
  31. package/js/src/abstract/kucoin.d.ts +1 -0
  32. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  33. package/js/src/alpaca.js +2 -2
  34. package/js/src/ascendex.js +95 -97
  35. package/js/src/binance.js +1 -1
  36. package/js/src/bingx.js +31 -17
  37. package/js/src/bitfinex2.d.ts +0 -1
  38. package/js/src/bitfinex2.js +21 -22
  39. package/js/src/bitget.js +2 -2
  40. package/js/src/bitmart.d.ts +0 -1
  41. package/js/src/bitmart.js +6 -9
  42. package/js/src/coinbaseinternational.js +2 -1
  43. package/js/src/coinex.d.ts +0 -2
  44. package/js/src/coinex.js +1 -17
  45. package/js/src/hitbtc.js +2 -0
  46. package/js/src/htx.js +49 -49
  47. package/js/src/huobijp.d.ts +0 -1
  48. package/js/src/huobijp.js +0 -9
  49. package/js/src/kucoin.d.ts +3 -1
  50. package/js/src/kucoin.js +59 -21
  51. package/js/src/kucoinfutures.d.ts +1 -0
  52. package/js/src/kucoinfutures.js +26 -2
  53. package/js/src/latoken.js +1 -0
  54. package/js/src/okx.d.ts +0 -1
  55. package/js/src/okx.js +1 -8
  56. package/js/src/pro/binance.d.ts +9 -1
  57. package/js/src/pro/binance.js +327 -1
  58. package/js/src/pro/bingx.d.ts +2 -2
  59. package/js/src/pro/bingx.js +263 -91
  60. package/js/src/pro/bithumb.js +5 -1
  61. package/js/src/pro/bybit.js +1 -1
  62. package/js/src/pro/coinex.d.ts +12 -6
  63. package/js/src/pro/coinex.js +996 -681
  64. package/js/src/pro/lbank.js +2 -3
  65. package/js/src/pro/okx.d.ts +7 -0
  66. package/js/src/pro/okx.js +162 -4
  67. package/js/src/whitebit.js +5 -3
  68. package/js/src/woo.js +1 -1
  69. package/package.json +1 -1
@@ -1059,8 +1059,7 @@ class bingx extends bingx$1 {
1059
1059
  }
1060
1060
  parseTrade(trade, market = undefined) {
1061
1061
  //
1062
- // spot
1063
- // fetchTrades
1062
+ // spot fetchTrades
1064
1063
  //
1065
1064
  // {
1066
1065
  // "id": 43148253,
@@ -1070,8 +1069,8 @@ class bingx extends bingx$1 {
1070
1069
  // "buyerMaker": false
1071
1070
  // }
1072
1071
  //
1073
- // spot
1074
- // fetchMyTrades
1072
+ // spot fetchMyTrades
1073
+ //
1075
1074
  // {
1076
1075
  // "symbol": "LTC-USDT",
1077
1076
  // "id": 36237072,
@@ -1086,8 +1085,7 @@ class bingx extends bingx$1 {
1086
1085
  // "isMaker": false
1087
1086
  // }
1088
1087
  //
1089
- // swap
1090
- // fetchTrades
1088
+ // swap fetchTrades
1091
1089
  //
1092
1090
  // {
1093
1091
  // "time": 1672025549368,
@@ -1097,8 +1095,7 @@ class bingx extends bingx$1 {
1097
1095
  // "quoteQty": "55723.87"
1098
1096
  // }
1099
1097
  //
1100
- // swap
1101
- // fetchMyTrades
1098
+ // swap fetchMyTrades
1102
1099
  //
1103
1100
  // {
1104
1101
  // "volume": "0.1",
@@ -1112,10 +1109,7 @@ class bingx extends bingx$1 {
1112
1109
  // "filledTime": "2023-07-04T20:56:01.000+0800"
1113
1110
  // }
1114
1111
  //
1115
- //
1116
- // ws
1117
- //
1118
- // spot
1112
+ // ws spot
1119
1113
  //
1120
1114
  // {
1121
1115
  // "E": 1690214529432,
@@ -1128,7 +1122,7 @@ class bingx extends bingx$1 {
1128
1122
  // "t": "57903921"
1129
1123
  // }
1130
1124
  //
1131
- // swap
1125
+ // ws linear swap
1132
1126
  //
1133
1127
  // {
1134
1128
  // "q": "0.0421",
@@ -1138,6 +1132,19 @@ class bingx extends bingx$1 {
1138
1132
  // "s": "BTC-USDT"
1139
1133
  // }
1140
1134
  //
1135
+ // ws inverse swap
1136
+ //
1137
+ // {
1138
+ // "e": "trade",
1139
+ // "E": 1722920589665,
1140
+ // "s": "BTC-USD",
1141
+ // "t": "39125001",
1142
+ // "p": "55360.0",
1143
+ // "q": "1",
1144
+ // "T": 1722920589582,
1145
+ // "m": false
1146
+ // }
1147
+ //
1141
1148
  // inverse swap fetchMyTrades
1142
1149
  //
1143
1150
  // {
@@ -2547,16 +2554,22 @@ class bingx extends bingx$1 {
2547
2554
  }
2548
2555
  }
2549
2556
  let positionSide = undefined;
2550
- if (reduceOnly) {
2551
- positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
2557
+ const hedged = this.safeBool(params, 'hedged', false);
2558
+ if (hedged) {
2559
+ if (reduceOnly) {
2560
+ positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
2561
+ }
2562
+ else {
2563
+ positionSide = (side === 'buy') ? 'LONG' : 'SHORT';
2564
+ }
2552
2565
  }
2553
2566
  else {
2554
- positionSide = (side === 'buy') ? 'LONG' : 'SHORT';
2567
+ positionSide = 'BOTH';
2555
2568
  }
2556
2569
  request['positionSide'] = positionSide;
2557
2570
  request['quantity'] = (market['inverse']) ? amount : this.parseToNumeric(this.amountToPrecision(symbol, amount)); // precision not available for inverse contracts
2558
2571
  }
2559
- params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
2572
+ params = this.omit(params, ['hedged', 'reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
2560
2573
  return this.extend(request, params);
2561
2574
  }
2562
2575
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -2588,6 +2601,7 @@ class bingx extends bingx$1 {
2588
2601
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
2589
2602
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
2590
2603
  * @param {boolean} [params.test] *swap only* whether to use the test endpoint or not, default is false
2604
+ * @param {boolean} [params.hedged] *swap only* whether the order is in hedged mode or one way mode
2591
2605
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2592
2606
  */
2593
2607
  await this.loadMarkets();
@@ -378,6 +378,25 @@ class bitfinex2 extends bitfinex2$1 {
378
378
  'withdraw': {
379
379
  'includeFee': false,
380
380
  },
381
+ 'networks': {
382
+ 'BTC': 'BITCOIN',
383
+ 'LTC': 'LITECOIN',
384
+ 'ERC20': 'ETHEREUM',
385
+ 'OMNI': 'TETHERUSO',
386
+ 'LIQUID': 'TETHERUSL',
387
+ 'TRC20': 'TETHERUSX',
388
+ 'EOS': 'TETHERUSS',
389
+ 'AVAX': 'TETHERUSDTAVAX',
390
+ 'SOL': 'TETHERUSDTSOL',
391
+ 'ALGO': 'TETHERUSDTALG',
392
+ 'BCH': 'TETHERUSDTBCH',
393
+ 'KSM': 'TETHERUSDTKSM',
394
+ 'DVF': 'TETHERUSDTDVF',
395
+ 'OMG': 'TETHERUSDTOMG',
396
+ },
397
+ 'networksById': {
398
+ 'TETHERUSE': 'ERC20',
399
+ },
381
400
  },
382
401
  'exceptions': {
383
402
  'exact': {
@@ -786,7 +805,7 @@ class bitfinex2 extends bitfinex2$1 {
786
805
  const networkId = this.safeString(pair, 0);
787
806
  const currencyId = this.safeString(this.safeValue(pair, 1, []), 0);
788
807
  if (currencyId === cleanId) {
789
- const network = this.safeNetwork(networkId);
808
+ const network = this.networkIdToCode(networkId);
790
809
  networks[network] = {
791
810
  'info': networkId,
792
811
  'id': networkId.toLowerCase(),
@@ -813,26 +832,6 @@ class bitfinex2 extends bitfinex2$1 {
813
832
  }
814
833
  return result;
815
834
  }
816
- safeNetwork(networkId) {
817
- const networksById = {
818
- 'BITCOIN': 'BTC',
819
- 'LITECOIN': 'LTC',
820
- 'ETHEREUM': 'ERC20',
821
- 'TETHERUSE': 'ERC20',
822
- 'TETHERUSO': 'OMNI',
823
- 'TETHERUSL': 'LIQUID',
824
- 'TETHERUSX': 'TRC20',
825
- 'TETHERUSS': 'EOS',
826
- 'TETHERUSDTAVAX': 'AVAX',
827
- 'TETHERUSDTSOL': 'SOL',
828
- 'TETHERUSDTALG': 'ALGO',
829
- 'TETHERUSDTBCH': 'BCH',
830
- 'TETHERUSDTKSM': 'KSM',
831
- 'TETHERUSDTDVF': 'DVF',
832
- 'TETHERUSDTOMG': 'OMG',
833
- };
834
- return this.safeString(networksById, networkId, networkId);
835
- }
836
835
  async fetchBalance(params = {}) {
837
836
  /**
838
837
  * @method
@@ -2371,7 +2370,7 @@ class bitfinex2 extends bitfinex2$1 {
2371
2370
  const currencyId = this.safeString(transaction, 1);
2372
2371
  code = this.safeCurrencyCode(currencyId, currency);
2373
2372
  const networkId = this.safeString(transaction, 2);
2374
- network = this.safeNetwork(networkId);
2373
+ network = this.networkIdToCode(networkId);
2375
2374
  timestamp = this.safeInteger(transaction, 5);
2376
2375
  updated = this.safeInteger(transaction, 6);
2377
2376
  status = this.parseTransactionStatus(this.safeString(transaction, 9));
@@ -4001,7 +4001,7 @@ class bitget extends bitget$1 {
4001
4001
  if (feeCostString !== undefined) {
4002
4002
  // swap
4003
4003
  fee = {
4004
- 'cost': this.parseNumber(Precise["default"].stringAbs(feeCostString)),
4004
+ 'cost': this.parseNumber(Precise["default"].stringNeg(feeCostString)),
4005
4005
  'currency': market['settle'],
4006
4006
  };
4007
4007
  }
@@ -4018,7 +4018,7 @@ class bitget extends bitget$1 {
4018
4018
  }
4019
4019
  }
4020
4020
  fee = {
4021
- 'cost': this.parseNumber(Precise["default"].stringAbs(this.safeString(feeObject, 'totalFee'))),
4021
+ 'cost': this.parseNumber(Precise["default"].stringNeg(this.safeString(feeObject, 'totalFee'))),
4022
4022
  'currency': this.safeCurrencyCode(this.safeString(feeObject, 'feeCoinCode')),
4023
4023
  };
4024
4024
  }
@@ -3435,7 +3435,12 @@ class bitmart extends bitmart$1 {
3435
3435
  const parts = chain.split('-');
3436
3436
  const partsLength = parts.length;
3437
3437
  const networkId = this.safeString(parts, partsLength - 1);
3438
- network = this.safeNetworkCode(networkId, currency);
3438
+ if (networkId === this.safeString(currency, 'name')) {
3439
+ network = this.safeString(currency, 'code');
3440
+ }
3441
+ else {
3442
+ network = this.networkIdToCode(networkId);
3443
+ }
3439
3444
  }
3440
3445
  this.checkAddress(address);
3441
3446
  return {
@@ -3446,14 +3451,6 @@ class bitmart extends bitmart$1 {
3446
3451
  'network': network,
3447
3452
  };
3448
3453
  }
3449
- safeNetworkCode(networkId, currency = undefined) {
3450
- const name = this.safeString(currency, 'name');
3451
- if (networkId === name) {
3452
- const code = this.safeString(currency, 'code');
3453
- return code;
3454
- }
3455
- return this.networkIdToCode(networkId);
3456
- }
3457
3454
  async withdraw(code, amount, address, tag = undefined, params = {}) {
3458
3455
  /**
3459
3456
  * @method
@@ -802,11 +802,12 @@ class coinbaseinternational extends coinbaseinternational$1 {
802
802
  const currencyId = this.safeString(network, 'asset_name');
803
803
  const currencyCode = this.safeCurrencyCode(currencyId);
804
804
  const networkId = this.safeString(network, 'network_arn_id');
805
+ const networkIdForCode = this.safeStringN(network, ['network_name', 'display_name', 'network_arn_id'], '');
805
806
  return this.safeNetwork({
806
807
  'info': network,
807
808
  'id': networkId,
808
809
  'name': this.safeString(network, 'display_name'),
809
- 'network': this.networkIdToCode(this.safeStringN(network, ['network_name', 'display_name', 'network_arn_id'], ''), currencyCode),
810
+ 'network': this.networkIdToCode(networkIdForCode, currencyCode),
810
811
  'active': undefined,
811
812
  'deposit': undefined,
812
813
  'withdraw': undefined,
@@ -3766,26 +3766,10 @@ class coinex extends coinex$1 {
3766
3766
  const options = this.safeDict(this.options, 'fetchDepositAddress', {});
3767
3767
  const fillResponseFromRequest = this.safeBool(options, 'fillResponseFromRequest', true);
3768
3768
  if (fillResponseFromRequest) {
3769
- depositAddress['network'] = this.safeNetworkCode(network, currency);
3769
+ depositAddress['network'] = this.networkIdToCode(network, currency).toUpperCase();
3770
3770
  }
3771
3771
  return depositAddress;
3772
3772
  }
3773
- safeNetwork(networkId, currency = undefined) {
3774
- const networks = this.safeValue(currency, 'networks', {});
3775
- const networksCodes = Object.keys(networks);
3776
- const networksCodesLength = networksCodes.length;
3777
- if (networkId === undefined && networksCodesLength === 1) {
3778
- return networks[networksCodes[0]];
3779
- }
3780
- return {
3781
- 'id': networkId,
3782
- 'network': (networkId === undefined) ? undefined : networkId.toUpperCase(),
3783
- };
3784
- }
3785
- safeNetworkCode(networkId, currency = undefined) {
3786
- const network = this.safeNetwork(networkId, currency);
3787
- return network['network'];
3788
- }
3789
3773
  parseDepositAddress(depositAddress, currency = undefined) {
3790
3774
  //
3791
3775
  // {
@@ -1415,8 +1415,10 @@ class hitbtc extends hitbtc$1 {
1415
1415
  }
1416
1416
  parseTransactionStatus(status) {
1417
1417
  const statuses = {
1418
+ 'CREATED': 'pending',
1418
1419
  'PENDING': 'pending',
1419
1420
  'FAILED': 'failed',
1421
+ 'ROLLED_BACK': 'failed',
1420
1422
  'SUCCESS': 'ok',
1421
1423
  };
1422
1424
  return this.safeString(statuses, status, status);