ccxt 4.5.44 → 4.5.46

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 (111) hide show
  1. package/README.md +9 -12
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -12
  4. package/dist/cjs/src/abstract/kucoinfutures.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +39 -3
  6. package/dist/cjs/src/base/functions/encode.js +2 -2
  7. package/dist/cjs/src/base/functions/generic.js +8 -2
  8. package/dist/cjs/src/binance.js +11 -2
  9. package/dist/cjs/src/bitget.js +3 -1
  10. package/dist/cjs/src/bitmart.js +144 -21
  11. package/dist/cjs/src/bitrue.js +1 -1
  12. package/dist/cjs/src/bitteam.js +1 -1
  13. package/dist/cjs/src/btcbox.js +1 -1
  14. package/dist/cjs/src/bybit.js +58 -56
  15. package/dist/cjs/src/bydfi.js +102 -100
  16. package/dist/cjs/src/cex.js +1 -0
  17. package/dist/cjs/src/gate.js +264 -170
  18. package/dist/cjs/src/grvt.js +3 -2
  19. package/dist/cjs/src/hyperliquid.js +16 -5
  20. package/dist/cjs/src/kraken.js +4 -2
  21. package/dist/cjs/src/krakenfutures.js +1 -5
  22. package/dist/cjs/src/kucoin.js +4733 -972
  23. package/dist/cjs/src/kucoinfutures.js +14 -3434
  24. package/dist/cjs/src/lbank.js +1 -1
  25. package/dist/cjs/src/okx.js +75 -57
  26. package/dist/cjs/src/paradex.js +2 -6
  27. package/dist/cjs/src/poloniex.js +1 -1
  28. package/dist/cjs/src/pro/bydfi.js +19 -19
  29. package/dist/cjs/src/pro/gate.js +114 -53
  30. package/dist/cjs/src/pro/grvt.js +5 -3
  31. package/dist/cjs/src/pro/htx.js +4 -4
  32. package/dist/cjs/src/pro/kucoin.js +819 -178
  33. package/dist/cjs/src/pro/kucoinfutures.js +95 -1261
  34. package/dist/cjs/src/pro/mexc.js +10 -5
  35. package/dist/cjs/src/pro/okx.js +85 -40
  36. package/index.d.cts +2 -0
  37. package/js/ccxt.d.ts +2 -14
  38. package/js/ccxt.js +2 -10
  39. package/js/src/abstract/bitmart.d.ts +7 -0
  40. package/js/src/abstract/bydfi.d.ts +29 -29
  41. package/js/src/abstract/kraken.d.ts +1 -0
  42. package/js/src/abstract/kucoin.d.ts +46 -2
  43. package/js/src/abstract/kucoinfutures.d.ts +27 -11
  44. package/js/src/base/Exchange.d.ts +13 -1
  45. package/js/src/base/Exchange.js +39 -3
  46. package/js/src/base/functions/encode.js +2 -2
  47. package/js/src/base/functions/generic.js +9 -3
  48. package/js/src/binance.js +11 -2
  49. package/js/src/bitget.js +3 -1
  50. package/js/src/bitmart.d.ts +18 -4
  51. package/js/src/bitmart.js +144 -21
  52. package/js/src/bitrue.js +1 -1
  53. package/js/src/bitteam.js +1 -1
  54. package/js/src/btcbox.js +1 -1
  55. package/js/src/bybit.d.ts +1 -0
  56. package/js/src/bybit.js +58 -56
  57. package/js/src/bydfi.d.ts +31 -31
  58. package/js/src/bydfi.js +102 -100
  59. package/js/src/cex.js +2 -1
  60. package/js/src/gate.d.ts +125 -119
  61. package/js/src/gate.js +264 -170
  62. package/js/src/grvt.js +3 -2
  63. package/js/src/hyperliquid.d.ts +3 -1
  64. package/js/src/hyperliquid.js +16 -5
  65. package/js/src/kraken.js +4 -2
  66. package/js/src/krakenfutures.js +1 -5
  67. package/js/src/kucoin.d.ts +696 -100
  68. package/js/src/kucoin.js +4734 -973
  69. package/js/src/kucoinfutures.d.ts +4 -522
  70. package/js/src/kucoinfutures.js +14 -3434
  71. package/js/src/lbank.js +1 -1
  72. package/js/src/okx.d.ts +1 -0
  73. package/js/src/okx.js +75 -57
  74. package/js/src/paradex.d.ts +0 -1
  75. package/js/src/paradex.js +2 -6
  76. package/js/src/poloniex.js +1 -1
  77. package/js/src/pro/bydfi.d.ts +18 -18
  78. package/js/src/pro/bydfi.js +19 -19
  79. package/js/src/pro/gate.d.ts +30 -1
  80. package/js/src/pro/gate.js +114 -53
  81. package/js/src/pro/grvt.js +5 -3
  82. package/js/src/pro/htx.js +4 -4
  83. package/js/src/pro/kucoin.d.ts +70 -30
  84. package/js/src/pro/kucoin.js +821 -180
  85. package/js/src/pro/kucoinfutures.d.ts +17 -195
  86. package/js/src/pro/kucoinfutures.js +96 -1262
  87. package/js/src/pro/mexc.js +10 -5
  88. package/js/src/pro/okx.d.ts +1 -0
  89. package/js/src/pro/okx.js +85 -40
  90. package/package.json +2 -2
  91. package/dist/cjs/src/abstract/alp.js +0 -11
  92. package/dist/cjs/src/abstract/defx.js +0 -11
  93. package/dist/cjs/src/abstract/timex.js +0 -11
  94. package/dist/cjs/src/alp.js +0 -1059
  95. package/dist/cjs/src/defx.js +0 -2142
  96. package/dist/cjs/src/pro/defx.js +0 -866
  97. package/dist/cjs/src/timex.js +0 -1793
  98. package/js/src/abstract/alp.d.ts +0 -21
  99. package/js/src/abstract/alp.js +0 -5
  100. package/js/src/abstract/defx.d.ts +0 -72
  101. package/js/src/abstract/defx.js +0 -5
  102. package/js/src/abstract/timex.d.ts +0 -65
  103. package/js/src/abstract/timex.js +0 -5
  104. package/js/src/alp.d.ts +0 -209
  105. package/js/src/alp.js +0 -1052
  106. package/js/src/defx.d.ts +0 -348
  107. package/js/src/defx.js +0 -2135
  108. package/js/src/pro/defx.d.ts +0 -236
  109. package/js/src/pro/defx.js +0 -859
  110. package/js/src/timex.d.ts +0 -247
  111. package/js/src/timex.js +0 -1786
package/dist/cjs/ccxt.js CHANGED
@@ -9,7 +9,6 @@ var Precise = require('./src/base/Precise.js');
9
9
  var functions = require('./src/base/functions.js');
10
10
  var errors = require('./src/base/errors.js');
11
11
  var aftermath = require('./src/aftermath.js');
12
- var alp = require('./src/alp.js');
13
12
  var alpaca = require('./src/alpaca.js');
14
13
  var apex = require('./src/apex.js');
15
14
  var arkham = require('./src/arkham.js');
@@ -63,7 +62,6 @@ var coinspot = require('./src/coinspot.js');
63
62
  var cryptocom = require('./src/cryptocom.js');
64
63
  var cryptomus = require('./src/cryptomus.js');
65
64
  var deepcoin = require('./src/deepcoin.js');
66
- var defx = require('./src/defx.js');
67
65
  var delta = require('./src/delta.js');
68
66
  var deribit = require('./src/deribit.js');
69
67
  var derive = require('./src/derive.js');
@@ -108,7 +106,6 @@ var paradex = require('./src/paradex.js');
108
106
  var paymium = require('./src/paymium.js');
109
107
  var phemex = require('./src/phemex.js');
110
108
  var poloniex = require('./src/poloniex.js');
111
- var timex = require('./src/timex.js');
112
109
  var tokocrypto = require('./src/tokocrypto.js');
113
110
  var toobit = require('./src/toobit.js');
114
111
  var upbit = require('./src/upbit.js');
@@ -160,7 +157,6 @@ var coinex$1 = require('./src/pro/coinex.js');
160
157
  var coinone$1 = require('./src/pro/coinone.js');
161
158
  var cryptocom$1 = require('./src/pro/cryptocom.js');
162
159
  var deepcoin$1 = require('./src/pro/deepcoin.js');
163
- var defx$1 = require('./src/pro/defx.js');
164
160
  var deribit$1 = require('./src/pro/deribit.js');
165
161
  var derive$1 = require('./src/pro/derive.js');
166
162
  var dydx$1 = require('./src/pro/dydx.js');
@@ -204,11 +200,10 @@ var xt$1 = require('./src/pro/xt.js');
204
200
 
205
201
  //-----------------------------------------------------------------------------
206
202
  // this is updated by vss.js when building
207
- const version = '4.5.44';
203
+ const version = '4.5.46';
208
204
  Exchange["default"].ccxtVersion = version;
209
205
  const exchanges = {
210
206
  'aftermath': aftermath["default"],
211
- 'alp': alp["default"],
212
207
  'alpaca': alpaca["default"],
213
208
  'apex': apex["default"],
214
209
  'arkham': arkham["default"],
@@ -262,7 +257,6 @@ const exchanges = {
262
257
  'cryptocom': cryptocom["default"],
263
258
  'cryptomus': cryptomus["default"],
264
259
  'deepcoin': deepcoin["default"],
265
- 'defx': defx["default"],
266
260
  'delta': delta["default"],
267
261
  'deribit': deribit["default"],
268
262
  'derive': derive["default"],
@@ -307,7 +301,6 @@ const exchanges = {
307
301
  'paymium': paymium["default"],
308
302
  'phemex': phemex["default"],
309
303
  'poloniex': poloniex["default"],
310
- 'timex': timex["default"],
311
304
  'tokocrypto': tokocrypto["default"],
312
305
  'toobit': toobit["default"],
313
306
  'upbit': upbit["default"],
@@ -361,7 +354,6 @@ const pro = {
361
354
  'coinone': coinone$1["default"],
362
355
  'cryptocom': cryptocom$1["default"],
363
356
  'deepcoin': deepcoin$1["default"],
364
- 'defx': defx$1["default"],
365
357
  'deribit': deribit$1["default"],
366
358
  'derive': derive$1["default"],
367
359
  'dydx': dydx$1["default"],
@@ -455,7 +447,6 @@ exports.RestrictedLocation = errors.RestrictedLocation;
455
447
  exports.UnsubscribeError = errors.UnsubscribeError;
456
448
  exports.errors = errors;
457
449
  exports.aftermath = aftermath["default"];
458
- exports.alp = alp["default"];
459
450
  exports.alpaca = alpaca["default"];
460
451
  exports.apex = apex["default"];
461
452
  exports.arkham = arkham["default"];
@@ -509,7 +500,6 @@ exports.coinspot = coinspot["default"];
509
500
  exports.cryptocom = cryptocom["default"];
510
501
  exports.cryptomus = cryptomus["default"];
511
502
  exports.deepcoin = deepcoin["default"];
512
- exports.defx = defx["default"];
513
503
  exports.delta = delta["default"];
514
504
  exports.deribit = deribit["default"];
515
505
  exports.derive = derive["default"];
@@ -554,7 +544,6 @@ exports.paradex = paradex["default"];
554
544
  exports.paymium = paymium["default"];
555
545
  exports.phemex = phemex["default"];
556
546
  exports.poloniex = poloniex["default"];
557
- exports.timex = timex["default"];
558
547
  exports.tokocrypto = tokocrypto["default"];
559
548
  exports.toobit = toobit["default"];
560
549
  exports.upbit = upbit["default"];
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var kucoin$1 = require('../kucoin.js');
6
6
 
7
- // -------------------------------------------------------------------------------
7
+ // ----------------------------------------------------------------------------
8
8
  class kucoin extends kucoin$1["default"] {
9
9
  }
10
10
 
@@ -2872,8 +2872,8 @@ class Exchange {
2872
2872
  const res = this.parseToNumeric((value % 1));
2873
2873
  return res === 0;
2874
2874
  }
2875
- nonEmptyString(value) {
2876
- return this.valueIsDefined(value) && value !== '';
2875
+ isEmptyString(value) {
2876
+ return !this.valueIsDefined(value) || value === '';
2877
2877
  }
2878
2878
  safeNumberOmitZero(obj, key, defaultValue = undefined) {
2879
2879
  const value = this.safeString(obj, key);
@@ -4073,6 +4073,9 @@ class Exchange {
4073
4073
  }
4074
4074
  return reversed;
4075
4075
  }
4076
+ stringToBase16(str) {
4077
+ return '0x' + this.binaryToBase16(this.base64ToBinary(this.stringToBase64(str)));
4078
+ }
4076
4079
  reduceFeesByCurrency(fees) {
4077
4080
  //
4078
4081
  // this function takes a list of fee structures having the following format
@@ -4281,6 +4284,12 @@ class Exchange {
4281
4284
  }
4282
4285
  throw new errors.NotSupported(this.id + ' fetchOHLCV() is not supported yet' + message);
4283
4286
  }
4287
+ async fetchSpotOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
4288
+ throw new errors.NotSupported(this.id + ' fetchSpotOHLCV() is not supported yet');
4289
+ }
4290
+ async fetchContractOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
4291
+ throw new errors.NotSupported(this.id + ' fetchContractOHLCV() is not supported yet');
4292
+ }
4284
4293
  async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
4285
4294
  let message = '';
4286
4295
  if (this.has['fetchTradesWs']) {
@@ -5615,11 +5624,17 @@ class Exchange {
5615
5624
  async fetchTickers(symbols = undefined, params = {}) {
5616
5625
  throw new errors.NotSupported(this.id + ' fetchTickers() is not supported yet');
5617
5626
  }
5627
+ async fetchSpotTickers(symbols = undefined, params = {}) {
5628
+ throw new errors.NotSupported(this.id + ' fetchSpotTickers() is not supported yet');
5629
+ }
5630
+ async fetchContractTickers(symbols = undefined, params = {}) {
5631
+ throw new errors.NotSupported(this.id + ' fetchContractTickers() is not supported yet');
5632
+ }
5618
5633
  async fetchMarkPrices(symbols = undefined, params = {}) {
5619
5634
  throw new errors.NotSupported(this.id + ' fetchMarkPrices() is not supported yet');
5620
5635
  }
5621
5636
  async fetchTickersWs(symbols = undefined, params = {}) {
5622
- throw new errors.NotSupported(this.id + ' fetchTickers() is not supported yet');
5637
+ throw new errors.NotSupported(this.id + ' fetchTickersWs() is not supported yet');
5623
5638
  }
5624
5639
  async fetchOrderBooks(symbols = undefined, limit = undefined, params = {}) {
5625
5640
  throw new errors.NotSupported(this.id + ' fetchOrderBooks() is not supported yet');
@@ -6124,6 +6139,12 @@ class Exchange {
6124
6139
  async createOrders(orders, params = {}) {
6125
6140
  throw new errors.NotSupported(this.id + ' createOrders() is not supported yet');
6126
6141
  }
6142
+ async createSpotOrders(orders, params = {}) {
6143
+ throw new errors.NotSupported(this.id + ' createSpotOrders() is not supported yet');
6144
+ }
6145
+ async createContractOrders(orders, params = {}) {
6146
+ throw new errors.NotSupported(this.id + ' createContractOrders() is not supported yet');
6147
+ }
6127
6148
  async editOrders(orders, params = {}) {
6128
6149
  throw new errors.NotSupported(this.id + ' editOrders() is not supported yet');
6129
6150
  }
@@ -6133,6 +6154,12 @@ class Exchange {
6133
6154
  async cancelOrder(id, symbol = undefined, params = {}) {
6134
6155
  throw new errors.NotSupported(this.id + ' cancelOrder() is not supported yet');
6135
6156
  }
6157
+ async cancelSpotOrder(id, symbol = undefined, params = {}) {
6158
+ throw new errors.NotSupported(this.id + ' cancelSpotOrder() is not supported yet');
6159
+ }
6160
+ async cancelContractOrder(id, symbol = undefined, params = {}) {
6161
+ throw new errors.NotSupported(this.id + ' cancelContractOrder() is not supported yet');
6162
+ }
6136
6163
  /**
6137
6164
  * @method
6138
6165
  * @name cancelOrderWithClientOrderId
@@ -6171,6 +6198,12 @@ class Exchange {
6171
6198
  async cancelAllOrders(symbol = undefined, params = {}) {
6172
6199
  throw new errors.NotSupported(this.id + ' cancelAllOrders() is not supported yet');
6173
6200
  }
6201
+ async cancelAllSpotOrders(symbol = undefined, params = {}) {
6202
+ throw new errors.NotSupported(this.id + ' cancelAllSpotOrders() is not supported yet');
6203
+ }
6204
+ async cancelAllContractOrders(symbol = undefined, params = {}) {
6205
+ throw new errors.NotSupported(this.id + ' cancelAllContractOrders() is not supported yet');
6206
+ }
6174
6207
  async cancelAllOrdersAfter(timeout, params = {}) {
6175
6208
  throw new errors.NotSupported(this.id + ' cancelAllOrdersAfter() is not supported yet');
6176
6209
  }
@@ -6333,6 +6366,9 @@ class Exchange {
6333
6366
  throw new errors.NotSupported(this.id + ' fetchDepositAddress() is not supported yet');
6334
6367
  }
6335
6368
  }
6369
+ async fetchContractDepositAddress(code, params = {}) {
6370
+ throw new errors.NotSupported(this.id + ' fetchContractDepositAddress() is not supported yet');
6371
+ }
6336
6372
  account() {
6337
6373
  return {
6338
6374
  'free': undefined,
@@ -10,8 +10,8 @@ var index$1 = require('../../static_dependencies/qs/index.js');
10
10
  /* eslint-disable */
11
11
  /* ------------------------------------------------------------------------ */
12
12
  const json = (data, params = undefined) => JSON.stringify(data), isJsonEncodedObject = (object) => ((typeof object === 'string') &&
13
- (object.length >= 2) &&
14
- ((object[0] === '{') || (object[0] === '['))), binaryToString = index.utf8.encode, stringToBinary = index.utf8.decode, stringToBase64 = (string) => index.base64.encode(index.utf8.decode(string)), base64ToString = (string) => index.utf8.encode(index.base64.decode(string)), base64ToBinary = index.base64.decode, binaryToBase64 = index.base64.encode, base16ToBinary = index.base16.decode, binaryToBase16 = index.base16.encode, base58ToBinary = index.base58.decode, binaryToBase58 = index.base58.encode, binaryConcat = utils.concatBytes, binaryConcatArray = (arr) => utils.concatBytes(...arr), urlencode = (object, sort = false) => index$1["default"].stringify(object), urlencodeNested = (object) => index$1["default"].stringify(object) // implemented only in python
13
+ // (object.length >= 2) && // commented: https://github.com/ccxt/ccxt/pull/28193
14
+ ((object[0] === '{') || (object[0] === '['))), binaryToString = index.utf8.encode, stringToBinary = index.utf8.decode, stringToBase64 = (string) => index.base64.encode(index.utf8.decode(string)), base64ToString = (string) => index.utf8.encode(index.base64.decode(string)), base64ToBinary = index.base64.decode, binaryToBase64 = index.base64.encode, base16ToBinary = index.base16.decode, binaryToBase16 = index.base16.encode, base58ToBinary = index.base58.decode, binaryToBase58 = index.base58.encode, binaryConcat = utils.concatBytes, binaryConcatArray = (arr) => utils.concatBytes(...arr), urlencode = (object, sort = false) => index$1["default"].stringify(object), urlencodeNested = (object) => index$1["default"].stringify(object, { encodeValuesOnly: true }) // implemented only in python
15
15
  , urlencodeWithArrayRepeat = (object) => index$1["default"].stringify(object, { arrayFormat: 'repeat' }), rawencode = (object, sort = false) => index$1["default"].stringify(object, { encode: false }), encode = index.utf8.decode // lol
16
16
  , decode = index.utf8.encode
17
17
  // Url-safe-base64 without equals signs, with + replaced by - and slashes replaced by underscores
@@ -19,10 +19,16 @@ const arrayConcat = (a, b) => a.concat(b);
19
19
  const inArray = (needle, haystack) => haystack.includes(needle);
20
20
  const toArray = (object) => Object.values(object);
21
21
  const isEmpty = (object) => {
22
- if (!object) {
22
+ if (object === null || object === undefined) {
23
23
  return true;
24
24
  }
25
- return (Array.isArray(object) ? object : Object.keys(object)).length < 1;
25
+ if (Array.isArray(object)) {
26
+ return object.length < 1;
27
+ }
28
+ if (type.isDictionary(object)) {
29
+ return Object.keys(object).length < 1;
30
+ }
31
+ return false;
26
32
  };
27
33
  const keysort = (x, out = {}) => {
28
34
  for (const k of keys(x).sort()) {
@@ -1384,8 +1384,11 @@ class binance extends binance$1["default"] {
1384
1384
  },
1385
1385
  'networks': {
1386
1386
  'ERC20': 'ETH',
1387
+ 'ETH': 'ETH',
1387
1388
  'TRC20': 'TRX',
1389
+ 'TRX': 'TRX',
1388
1390
  'BEP2': 'BNB',
1391
+ 'BSC': 'BSC',
1389
1392
  'BEP20': 'BSC',
1390
1393
  'EOS': 'EOS',
1391
1394
  'SPL': 'SOL',
@@ -1398,6 +1401,7 @@ class binance extends binance$1["default"] {
1398
1401
  'MATIC': 'MATIC',
1399
1402
  'BASE': 'BASE',
1400
1403
  'SUI': 'SUI',
1404
+ 'OP': 'OPTIMISM',
1401
1405
  'OPTIMISM': 'OPTIMISM',
1402
1406
  'NEAR': 'NEAR',
1403
1407
  'APT': 'APT',
@@ -1443,7 +1447,11 @@ class binance extends binance$1["default"] {
1443
1447
  'ONT': 'ONT', // ontology
1444
1448
  },
1445
1449
  'networksById': {
1446
- 'SOL': 'SOL', // temporary fix for SPL definition
1450
+ 'TRX': 'TRC20',
1451
+ 'BSC': 'BEP20',
1452
+ 'ETH': 'ERC20',
1453
+ 'SOL': 'SOL',
1454
+ 'OPTIMISM': 'OP',
1447
1455
  },
1448
1456
  'impliedNetworks': {
1449
1457
  'ETH': { 'ERC20': 'ETH' },
@@ -8964,7 +8972,8 @@ class binance extends binance$1["default"] {
8964
8972
  if (internalInteger !== undefined) {
8965
8973
  internal = (internalInteger !== 0) ? true : false;
8966
8974
  }
8967
- const network = this.safeString(transaction, 'network');
8975
+ const networkId = this.safeString(transaction, 'network');
8976
+ const network = this.networkIdToCode(networkId, code);
8968
8977
  return {
8969
8978
  'info': transaction,
8970
8979
  'id': id,
@@ -1457,7 +1457,9 @@ class bitget extends bitget$1["default"] {
1457
1457
  '20003': errors.ExchangeError,
1458
1458
  '01001': errors.ExchangeError,
1459
1459
  '40024': errors.RestrictedLocation,
1460
- '43111': errors.PermissionDenied, // {"code":"43111","msg":"参数错误 address not in address book","requestTime":1665394201164,"data":null}
1460
+ '41117': errors.InvalidOrder,
1461
+ '43111': errors.PermissionDenied,
1462
+ '45113': errors.InvalidOrder, // {"code":"45113","msg":"Maximum order value limit triggered","requestTime":1774884278712,"data":null}
1461
1463
  },
1462
1464
  'broad': {
1463
1465
  'invalid size, valid range': errors.ExchangeError,
@@ -244,6 +244,13 @@ class bitmart extends bitmart$1["default"] {
244
244
  'spot/v4/cancel_orders': 3,
245
245
  'spot/v4/cancel_all': 90,
246
246
  'spot/v4/batch_orders': 3,
247
+ 'spot/v4/algo/submit_order': 6,
248
+ 'spot/v4/algo/cancel_order': 6,
249
+ 'spot/v4/algo/cancel_all': 12,
250
+ 'spot/v4/query/algo/order': 1.5,
251
+ 'spot/v4/query/algo/client-order': 1.5,
252
+ 'spot/v4/query/algo/open-orders': 3,
253
+ 'spot/v4/query/algo/history-orders': 3,
247
254
  // newer endpoint
248
255
  'spot/v3/cancel_order': 1,
249
256
  'spot/v2/batch_orders': 1,
@@ -931,7 +938,7 @@ class bitmart extends bitmart$1["default"] {
931
938
  if (type === 'swap') {
932
939
  type = 'contract';
933
940
  }
934
- const service = this.safeString(servicesByType, type);
941
+ const service = this.safeDict(servicesByType, type);
935
942
  let status = undefined;
936
943
  let eta = undefined;
937
944
  if (service !== undefined) {
@@ -2769,6 +2776,7 @@ class bitmart extends bitmart$1["default"] {
2769
2776
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
2770
2777
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-tp-sl-order-signed
2771
2778
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-trail-order-signed
2779
+ * @see https://developer-pro.bitmart.com/en/spot/#new-algo-order-v4-signed
2772
2780
  * @param {string} symbol unified symbol of the market to create an order in
2773
2781
  * @param {string} type 'market', 'limit' or 'trailing' for swap markets only
2774
2782
  * @param {string} side 'buy' or 'sell'
@@ -2806,7 +2814,10 @@ class bitmart extends bitmart$1["default"] {
2806
2814
  let response = undefined;
2807
2815
  if (market['spot']) {
2808
2816
  const spotRequest = this.createSpotOrderRequest(symbol, type, side, amount, price, params);
2809
- if (marginMode === 'isolated') {
2817
+ if (isStopLoss || isTakeProfit || isTriggerOrder) {
2818
+ response = await this.privatePostSpotV4AlgoSubmitOrder(spotRequest);
2819
+ }
2820
+ else if (marginMode === 'isolated') {
2810
2821
  response = await this.privatePostSpotV1MarginSubmitOrder(spotRequest);
2811
2822
  }
2812
2823
  else {
@@ -3086,6 +3097,7 @@ class bitmart extends bitmart$1["default"] {
3086
3097
  * @description create a spot order request
3087
3098
  * @see https://developer-pro.bitmart.com/en/spot/#new-order-v2-signed
3088
3099
  * @see https://developer-pro.bitmart.com/en/spot/#new-margin-order-v1-signed
3100
+ * @see https://developer-pro.bitmart.com/en/spot/#new-algo-order-v4-signed
3089
3101
  * @param {string} symbol unified symbol of the market to create an order in
3090
3102
  * @param {string} type 'market' or 'limit'
3091
3103
  * @param {string} side 'buy' or 'sell'
@@ -3093,13 +3105,23 @@ class bitmart extends bitmart$1["default"] {
3093
3105
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
3094
3106
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3095
3107
  * @param {string} [params.marginMode] 'cross' or 'isolated'
3108
+ * @param {string} [params.clientOrderId] client order id of the order
3109
+ * @param {string} [params.triggerPrice] the price to trigger a stop order
3110
+ * @param {string} [params.stopLossPrice] the price to trigger a stop-loss order
3111
+ * @param {string} [params.takeProfitPrice] the price to trigger a take-profit order
3096
3112
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
3097
3113
  */
3098
3114
  const market = this.market(symbol);
3115
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
3116
+ const stopLossPrice = this.safeString(params, 'stopLossPrice');
3117
+ const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
3118
+ const isStopLoss = stopLossPrice !== undefined;
3119
+ const isTakeProfit = takeProfitPrice !== undefined;
3120
+ const isTriggerOrder = triggerPrice !== undefined;
3121
+ const isAlgoOrder = isStopLoss || isTakeProfit || isTriggerOrder;
3099
3122
  const request = {
3100
3123
  'symbol': market['id'],
3101
3124
  'side': side,
3102
- 'type': type,
3103
3125
  };
3104
3126
  const timeInForce = this.safeString(params, 'timeInForce');
3105
3127
  if (timeInForce === 'FOK') {
@@ -3113,7 +3135,32 @@ class bitmart extends bitmart$1["default"] {
3113
3135
  params = this.omit(params, ['timeInForce', 'postOnly']);
3114
3136
  const ioc = ((timeInForce === 'IOC') || (type === 'ioc'));
3115
3137
  const isLimitOrder = (type === 'limit') || postOnly || ioc;
3116
- // method = 'privatePostSpotV2SubmitOrder';
3138
+ if (isAlgoOrder) {
3139
+ if (isTriggerOrder) {
3140
+ request['type'] = 'trigger';
3141
+ }
3142
+ else {
3143
+ request['type'] = 'tp/sl';
3144
+ }
3145
+ if (isLimitOrder) {
3146
+ request['trigger_type'] = 'limit';
3147
+ }
3148
+ else {
3149
+ request['trigger_type'] = 'market';
3150
+ }
3151
+ if (isStopLoss) {
3152
+ request['trigger_price'] = this.priceToPrecision(symbol, stopLossPrice);
3153
+ }
3154
+ else if (isTakeProfit) {
3155
+ request['trigger_price'] = this.priceToPrecision(symbol, takeProfitPrice);
3156
+ }
3157
+ else if (isTriggerOrder) {
3158
+ request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
3159
+ }
3160
+ }
3161
+ else {
3162
+ request['type'] = type;
3163
+ }
3117
3164
  if (isLimitOrder) {
3118
3165
  request['size'] = this.amountToPrecision(symbol, amount);
3119
3166
  request['price'] = this.priceToPrecision(symbol, price);
@@ -3166,12 +3213,14 @@ class bitmart extends bitmart$1["default"] {
3166
3213
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-plan-order-signed
3167
3214
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-order-signed
3168
3215
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-trail-order-signed
3216
+ * @see https://developer-pro.bitmart.com/en/spot/#cancel-algo-order-v4-signed
3169
3217
  * @param {string} id order id
3170
3218
  * @param {string} symbol unified symbol of the market the order was made in
3171
3219
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3172
3220
  * @param {string} [params.clientOrderId] *spot only* the client order id of the order to cancel
3173
- * @param {boolean} [params.trigger] *swap only* whether the order is a trigger order
3174
3221
  * @param {boolean} [params.trailing] *swap only* whether the order is a stop order
3222
+ * @param {boolean} [params.trigger] whether the order is a trigger order
3223
+ * @param {boolean} [params.stopLossTakeProfit] whether the order is a stopLossPrice or takeProfitPrice order
3175
3224
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
3176
3225
  */
3177
3226
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -3190,15 +3239,26 @@ class bitmart extends bitmart$1["default"] {
3190
3239
  else {
3191
3240
  request['order_id'] = id.toString();
3192
3241
  }
3193
- params = this.omit(params, ['clientOrderId']);
3242
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
3243
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3244
+ const trailing = this.safeBool(params, 'trailing');
3245
+ params = this.omit(params, ['clientOrderId', 'stop', 'trigger', 'trailing', 'stopLossTakeProfit']);
3194
3246
  let response = undefined;
3195
3247
  if (market['spot']) {
3196
- response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
3248
+ if (trigger || stopLossTakeProfit) {
3249
+ if (stopLossTakeProfit) {
3250
+ request['type'] = 'tp/sl';
3251
+ }
3252
+ else if (trigger) {
3253
+ request['type'] = 'trigger';
3254
+ }
3255
+ response = await this.privatePostSpotV4AlgoCancelOrder(this.extend(request, params));
3256
+ }
3257
+ else {
3258
+ response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
3259
+ }
3197
3260
  }
3198
3261
  else {
3199
- const trigger = this.safeBool2(params, 'stop', 'trigger');
3200
- const trailing = this.safeBool(params, 'trailing');
3201
- params = this.omit(params, ['stop', 'trigger']);
3202
3262
  if (trigger) {
3203
3263
  response = await this.privatePostContractPrivateCancelPlanOrder(this.extend(request, params));
3204
3264
  }
@@ -3323,9 +3383,12 @@ class bitmart extends bitmart$1["default"] {
3323
3383
  * @description cancel all open orders in a market
3324
3384
  * @see https://developer-pro.bitmart.com/en/spot/#cancel-all-order-v4-signed
3325
3385
  * @see https://developer-pro.bitmart.com/en/futuresv2/#cancel-all-orders-signed
3386
+ * @see https://developer-pro.bitmart.com/en/spot/#cancel-all-algo-order-v4-signed
3326
3387
  * @param {string} symbol unified market symbol of the market to cancel orders in
3327
3388
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3328
3389
  * @param {string} [params.side] *spot only* 'buy' or 'sell'
3390
+ * @param {boolean} [params.trigger] whether the orders are trigger orders
3391
+ * @param {boolean} [params.stopLossTakeProfit] whether the orders are stopLossPrice or takeProfitPrice orders
3329
3392
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
3330
3393
  */
3331
3394
  async cancelAllOrders(symbol = undefined, params = {}) {
@@ -3340,7 +3403,21 @@ class bitmart extends bitmart$1["default"] {
3340
3403
  let type = undefined;
3341
3404
  [type, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
3342
3405
  if (type === 'spot') {
3343
- response = await this.privatePostSpotV4CancelAll(this.extend(request, params));
3406
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
3407
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3408
+ params = this.omit(params, ['stop', 'trigger', 'stopLossTakeProfit']);
3409
+ if (trigger || stopLossTakeProfit) {
3410
+ if (stopLossTakeProfit) {
3411
+ request['type'] = 'tp/sl';
3412
+ }
3413
+ else if (trigger) {
3414
+ request['type'] = 'trigger';
3415
+ }
3416
+ response = await this.privatePostSpotV4AlgoCancelAll(this.extend(request, params));
3417
+ }
3418
+ else {
3419
+ response = await this.privatePostSpotV4CancelAll(this.extend(request, params));
3420
+ }
3344
3421
  }
3345
3422
  else if (type === 'swap') {
3346
3423
  if (symbol === undefined) {
@@ -3430,10 +3507,11 @@ class bitmart extends bitmart$1["default"] {
3430
3507
  /**
3431
3508
  * @method
3432
3509
  * @name bitmart#fetchOpenOrders
3510
+ * @description fetch all unfilled currently open orders
3433
3511
  * @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
3434
3512
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-all-open-orders-keyed
3435
3513
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-all-current-plan-orders-keyed
3436
- * @description fetch all unfilled currently open orders
3514
+ * @see https://developer-pro.bitmart.com/en/spot/#current-algo-open-orders-v4-signed
3437
3515
  * @param {string} symbol unified market symbol
3438
3516
  * @param {int} [since] the earliest time in ms to fetch open orders for
3439
3517
  * @param {int} [limit] the maximum number of open order structures to retrieve
@@ -3444,7 +3522,8 @@ class bitmart extends bitmart$1["default"] {
3444
3522
  * @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
3445
3523
  * @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
3446
3524
  * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
3447
- * @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
3525
+ * @param {boolean} [params.trigger] set to true if you want to fetch trigger orders
3526
+ * @param {boolean} [params.stopLossTakeProfit] set to true if you want to fetch stopLossPrice or takeProfitPrice orders
3448
3527
  * @param {string} [params.stpMode] self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3449
3528
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
3450
3529
  */
@@ -3459,6 +3538,9 @@ class bitmart extends bitmart$1["default"] {
3459
3538
  let type = undefined;
3460
3539
  let response = undefined;
3461
3540
  [type, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
3541
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger');
3542
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3543
+ params = this.omit(params, ['stop', 'trigger', 'stopLossTakeProfit']);
3462
3544
  if (type === 'spot') {
3463
3545
  if (limit !== undefined) {
3464
3546
  request['limit'] = Math.min(limit, 200);
@@ -3476,14 +3558,23 @@ class bitmart extends bitmart$1["default"] {
3476
3558
  params = this.omit(params, ['endTime']);
3477
3559
  request['endTime'] = until;
3478
3560
  }
3479
- response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
3561
+ if (isTrigger || stopLossTakeProfit) {
3562
+ if (isTrigger) {
3563
+ request['orderMode'] = 'trigger';
3564
+ }
3565
+ else if (stopLossTakeProfit) {
3566
+ request['orderMode'] = 'tp/sl';
3567
+ }
3568
+ response = await this.privatePostSpotV4QueryAlgoOpenOrders(this.extend(request, params));
3569
+ }
3570
+ else {
3571
+ response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
3572
+ }
3480
3573
  }
3481
3574
  else if (type === 'swap') {
3482
3575
  if (limit !== undefined) {
3483
3576
  request['limit'] = Math.min(limit, 100);
3484
3577
  }
3485
- const isTrigger = this.safeBool2(params, 'stop', 'trigger');
3486
- params = this.omit(params, ['stop', 'trigger']);
3487
3578
  if (isTrigger) {
3488
3579
  response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
3489
3580
  }
@@ -3563,9 +3654,10 @@ class bitmart extends bitmart$1["default"] {
3563
3654
  /**
3564
3655
  * @method
3565
3656
  * @name bitmart#fetchClosedOrders
3657
+ * @description fetches information on multiple closed orders made by the user
3566
3658
  * @see https://developer-pro.bitmart.com/en/spot/#account-orders-v4-signed
3567
3659
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-order-history-keyed
3568
- * @description fetches information on multiple closed orders made by the user
3660
+ * @see https://developer-pro.bitmart.com/en/spot/#account-algo-orders-v4-signed
3569
3661
  * @param {string} symbol unified market symbol of the market orders were made in
3570
3662
  * @param {int} [since] the earliest time in ms to fetch orders for
3571
3663
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -3573,6 +3665,8 @@ class bitmart extends bitmart$1["default"] {
3573
3665
  * @param {int} [params.until] timestamp in ms of the latest entry
3574
3666
  * @param {string} [params.marginMode] *spot only* 'cross' or 'isolated', for margin trading
3575
3667
  * @param {string} [params.stpMode] self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3668
+ * @param {boolean} [params.trigger] set to true if you want to fetch trigger orders
3669
+ * @param {boolean} [params.stopLossTakeProfit] set to true if you want to fetch stopLossPrice or takeProfitPrice orders
3576
3670
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
3577
3671
  */
3578
3672
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3600,6 +3694,9 @@ class bitmart extends bitmart$1["default"] {
3600
3694
  params = this.omit(params, ['until']);
3601
3695
  request[endTimeKey] = until;
3602
3696
  }
3697
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger');
3698
+ const stopLossTakeProfit = this.safeBool(params, 'stopLossTakeProfit');
3699
+ params = this.omit(params, ['stop', 'trigger', 'stopLossTakeProfit']);
3603
3700
  let response = undefined;
3604
3701
  if (type === 'spot') {
3605
3702
  let marginMode = undefined;
@@ -3607,7 +3704,18 @@ class bitmart extends bitmart$1["default"] {
3607
3704
  if (marginMode === 'isolated') {
3608
3705
  request['orderMode'] = 'iso_margin';
3609
3706
  }
3610
- response = await this.privatePostSpotV4QueryHistoryOrders(this.extend(request, params));
3707
+ if (isTrigger || stopLossTakeProfit) {
3708
+ if (isTrigger) {
3709
+ request['orderMode'] = 'trigger';
3710
+ }
3711
+ else if (stopLossTakeProfit) {
3712
+ request['orderMode'] = 'tp/sl';
3713
+ }
3714
+ response = await this.privatePostSpotV4QueryAlgoHistoryOrders(this.extend(request, params));
3715
+ }
3716
+ else {
3717
+ response = await this.privatePostSpotV4QueryHistoryOrders(this.extend(request, params));
3718
+ }
3611
3719
  }
3612
3720
  else {
3613
3721
  response = await this.privateGetContractPrivateOrderHistory(this.extend(request, params));
@@ -3635,6 +3743,8 @@ class bitmart extends bitmart$1["default"] {
3635
3743
  * @see https://developer-pro.bitmart.com/en/spot/#query-order-by-id-v4-signed
3636
3744
  * @see https://developer-pro.bitmart.com/en/spot/#query-order-by-clientorderid-v4-signed
3637
3745
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-order-detail-keyed
3746
+ * @see https://developer-pro.bitmart.com/en/spot/#query-algo-order-by-id-v4-signed
3747
+ * @see https://developer-pro.bitmart.com/en/spot/#query-algo-order-by-clientorderid-v4-signed
3638
3748
  * @param {string} id the id of the order
3639
3749
  * @param {string} symbol unified symbol of the market the order was made in
3640
3750
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3642,6 +3752,7 @@ class bitmart extends bitmart$1["default"] {
3642
3752
  * @param {string} [params.orderType] *swap only* 'limit', 'market', 'liquidate', 'bankruptcy', 'adl' or 'trailing'
3643
3753
  * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch a trailing order
3644
3754
  * @param {string} [params.stpMode] self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3755
+ * @param {boolean} [params.trigger] whether the orders is a trigger, stopLossPrice or takeProfitPrice order
3645
3756
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
3646
3757
  */
3647
3758
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -3656,14 +3767,26 @@ class bitmart extends bitmart$1["default"] {
3656
3767
  [type, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
3657
3768
  if (type === 'spot') {
3658
3769
  const clientOrderId = this.safeString(params, 'clientOrderId');
3770
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
3771
+ params = this.omit(params, ['stop', 'trigger']);
3659
3772
  if (!clientOrderId) {
3660
3773
  request['orderId'] = id;
3661
3774
  }
3662
- if (clientOrderId !== undefined) {
3663
- response = await this.privatePostSpotV4QueryClientOrder(this.extend(request, params));
3775
+ if (trigger) {
3776
+ if (clientOrderId !== undefined) {
3777
+ response = await this.privatePostSpotV4QueryAlgoClientOrder(this.extend(request, params));
3778
+ }
3779
+ else {
3780
+ response = await this.privatePostSpotV4QueryAlgoOrder(this.extend(request, params));
3781
+ }
3664
3782
  }
3665
3783
  else {
3666
- response = await this.privatePostSpotV4QueryOrder(this.extend(request, params));
3784
+ if (clientOrderId !== undefined) {
3785
+ response = await this.privatePostSpotV4QueryClientOrder(this.extend(request, params));
3786
+ }
3787
+ else {
3788
+ response = await this.privatePostSpotV4QueryOrder(this.extend(request, params));
3789
+ }
3667
3790
  }
3668
3791
  }
3669
3792
  else if (type === 'swap') {
@@ -753,7 +753,7 @@ class bitrue extends bitrue$1["default"] {
753
753
  // {
754
754
  // "chain": "BEP20",
755
755
  // "enableWithdraw": true,
756
- // "enableDeposit": true,
756
+ // "enableDeposit": false,
757
757
  // "withdrawFee": "0.2000",
758
758
  // "minWithdraw": "5.0000",
759
759
  // "maxWithdraw": "1000000000000000.0000",