ccxt 4.1.23 → 4.1.25

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 (68) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1249 -232
  3. package/dist/ccxt.browser.min.js +4 -4
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ace.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +7 -3
  7. package/dist/cjs/src/base/functions/crypto.js +11 -2
  8. package/dist/cjs/src/base/functions/generic.js +5 -3
  9. package/dist/cjs/src/base/functions.js +1 -0
  10. package/dist/cjs/src/binance.js +112 -34
  11. package/dist/cjs/src/bitget.js +289 -21
  12. package/dist/cjs/src/bitmart.js +1 -1
  13. package/dist/cjs/src/bybit.js +132 -15
  14. package/dist/cjs/src/cryptocom.js +262 -15
  15. package/dist/cjs/src/gate.js +191 -88
  16. package/dist/cjs/src/krakenfutures.js +158 -22
  17. package/dist/cjs/src/oceanex.js +0 -12
  18. package/dist/cjs/src/okx.js +60 -1
  19. package/dist/cjs/src/pro/bybit.js +1 -1
  20. package/dist/cjs/src/static_dependencies/noble-curves/abstract/edwards.js +8 -6
  21. package/dist/cjs/src/wavesexchange.js +6 -6
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/binance.d.ts +1 -14
  25. package/js/src/abstract/binancecoinm.d.ts +1 -14
  26. package/js/src/abstract/binanceus.d.ts +1 -14
  27. package/js/src/abstract/binanceusdm.d.ts +1 -14
  28. package/js/src/abstract/gate.d.ts +2 -7
  29. package/js/src/abstract/gateio.d.ts +2 -7
  30. package/js/src/ace.js +1 -1
  31. package/js/src/base/Exchange.d.ts +4 -2
  32. package/js/src/base/Exchange.js +7 -3
  33. package/js/src/base/functions/crypto.d.ts +3 -2
  34. package/js/src/base/functions/crypto.js +11 -3
  35. package/js/src/base/functions/generic.d.ts +1 -1
  36. package/js/src/base/functions/generic.js +5 -3
  37. package/js/src/base/types.d.ts +8 -0
  38. package/js/src/binance.d.ts +2 -1
  39. package/js/src/binance.js +112 -34
  40. package/js/src/bitget.d.ts +15 -1
  41. package/js/src/bitget.js +289 -21
  42. package/js/src/bitmart.js +1 -1
  43. package/js/src/bybit.d.ts +4 -2
  44. package/js/src/bybit.js +132 -15
  45. package/js/src/cryptocom.d.ts +4 -1
  46. package/js/src/cryptocom.js +262 -15
  47. package/js/src/gate.d.ts +3 -1
  48. package/js/src/gate.js +191 -88
  49. package/js/src/krakenfutures.d.ts +4 -1
  50. package/js/src/krakenfutures.js +158 -22
  51. package/js/src/oceanex.d.ts +0 -1
  52. package/js/src/oceanex.js +0 -12
  53. package/js/src/okx.d.ts +2 -1
  54. package/js/src/okx.js +60 -1
  55. package/js/src/pro/bybit.js +1 -1
  56. package/js/src/static_dependencies/noble-curves/abstract/edwards.d.ts +1 -0
  57. package/js/src/static_dependencies/noble-curves/abstract/edwards.js +5 -3
  58. package/js/src/wavesexchange.js +7 -7
  59. package/package.json +1 -1
  60. package/skip-tests.json +2 -3
  61. package/js/src/bkex.d.ts +0 -95
  62. package/js/src/bkex.js +0 -1962
  63. package/js/src/pro/btcex.d.ts +0 -32
  64. package/js/src/pro/btcex.js +0 -776
  65. package/js/src/pro/ripio.d.ts +0 -18
  66. package/js/src/pro/ripio.js +0 -296
  67. package/js/src/pro/zb.d.ts +0 -22
  68. package/js/src/pro/zb.js +0 -605
@@ -2482,7 +2482,7 @@ class ace extends _abstract_ace_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
2482
2482
  'timeStamp': nonce,
2483
2483
  }, params);
2484
2484
  const dataKeys = Object.keys(data);
2485
- const sortedDataKeys = this.sortBy(dataKeys, 0);
2485
+ const sortedDataKeys = this.sortBy(dataKeys, 0, false, '');
2486
2486
  for (let i = 0; i < sortedDataKeys.length; i++) {
2487
2487
  const key = sortedDataKeys[i];
2488
2488
  auth += this.safeString(data, key);
@@ -6868,6 +6868,7 @@ class Exchange {
6868
6868
  'createLimitOrder': true,
6869
6869
  'createMarketOrder': true,
6870
6870
  'createOrder': true,
6871
+ 'createOrders': undefined,
6871
6872
  'createPostOnlyOrder': undefined,
6872
6873
  'createReduceOnlyOrder': undefined,
6873
6874
  'createStopOrder': undefined,
@@ -8142,7 +8143,7 @@ class Exchange {
8142
8143
  this.markets_by_id = {};
8143
8144
  // handle marketId conflicts
8144
8145
  // we insert spot markets first
8145
- const marketValues = this.sortBy(this.toArray(markets), 'spot', true);
8146
+ const marketValues = this.sortBy(this.toArray(markets), 'spot', true, true);
8146
8147
  for (let i = 0; i < marketValues.length; i++) {
8147
8148
  const value = marketValues[i];
8148
8149
  if (value['id'] in this.markets_by_id) {
@@ -8192,8 +8193,8 @@ class Exchange {
8192
8193
  quoteCurrencies.push(currency);
8193
8194
  }
8194
8195
  }
8195
- baseCurrencies = this.sortBy(baseCurrencies, 'code');
8196
- quoteCurrencies = this.sortBy(quoteCurrencies, 'code');
8196
+ baseCurrencies = this.sortBy(baseCurrencies, 'code', false, '');
8197
+ quoteCurrencies = this.sortBy(quoteCurrencies, 'code', false, '');
8197
8198
  this.baseCurrencies = this.indexBy(baseCurrencies, 'code');
8198
8199
  this.quoteCurrencies = this.indexBy(quoteCurrencies, 'code');
8199
8200
  const allCurrencies = this.arrayConcat(baseCurrencies, quoteCurrencies);
@@ -9855,6 +9856,9 @@ class Exchange {
9855
9856
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
9856
9857
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrder() is not supported yet');
9857
9858
  }
9859
+ async createOrders(orders, params = {}) {
9860
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrders() is not supported yet');
9861
+ }
9858
9862
  async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
9859
9863
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrderWs() is not supported yet');
9860
9864
  }
@@ -11633,6 +11637,7 @@ __webpack_require__.r(__webpack_exports__);
11633
11637
  /* harmony export */ "arrayConcat": () => (/* reexport safe */ _functions_generic_js__WEBPACK_IMPORTED_MODULE_1__.oE),
11634
11638
  /* harmony export */ "asFloat": () => (/* reexport safe */ _functions_type_js__WEBPACK_IMPORTED_MODULE_3__.GX),
11635
11639
  /* harmony export */ "asInteger": () => (/* reexport safe */ _functions_type_js__WEBPACK_IMPORTED_MODULE_3__.xJ),
11640
+ /* harmony export */ "axolotl": () => (/* reexport safe */ _functions_crypto_js__WEBPACK_IMPORTED_MODULE_6__.gC),
11636
11641
  /* harmony export */ "base16ToBinary": () => (/* reexport safe */ _functions_encode_js__WEBPACK_IMPORTED_MODULE_5__.aj),
11637
11642
  /* harmony export */ "base58ToBinary": () => (/* reexport safe */ _functions_encode_js__WEBPACK_IMPORTED_MODULE_5__.ZA),
11638
11643
  /* harmony export */ "base64ToBinary": () => (/* reexport safe */ _functions_encode_js__WEBPACK_IMPORTED_MODULE_5__.R5),
@@ -11790,14 +11795,17 @@ __webpack_require__.r(__webpack_exports__);
11790
11795
  /* harmony export */ "UZ": () => (/* binding */ eddsa),
11791
11796
  /* harmony export */ "bD": () => (/* binding */ hmac),
11792
11797
  /* harmony export */ "bu": () => (/* binding */ ecdsa),
11798
+ /* harmony export */ "gC": () => (/* binding */ axolotl),
11793
11799
  /* harmony export */ "kn": () => (/* binding */ crc32),
11794
11800
  /* harmony export */ "vp": () => (/* binding */ hash)
11795
11801
  /* harmony export */ });
11796
11802
  /* harmony import */ var _static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(138);
11797
11803
  /* harmony import */ var _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9651);
11804
+ /* harmony import */ var _static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9285);
11798
11805
  /* ------------------------------------------------------------------------ */
11799
11806
 
11800
11807
 
11808
+
11801
11809
  /* ------------------------------------------------------------------------ */
11802
11810
  const encoders = {
11803
11811
  binary: x => x,
@@ -11826,11 +11834,18 @@ function ecdsa(request, secret, curve, prehash = null) {
11826
11834
  'v': signature.recovery,
11827
11835
  };
11828
11836
  }
11829
- function eddsa(request, secret, curve) {
11837
+ function axolotl(request, secret, curve) {
11830
11838
  // used for waves.exchange (that's why the output is base58)
11831
- const signature = curve.sign(request, secret);
11839
+ const signature = curve.signModified(request, secret);
11832
11840
  return _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base58.encode */ .Jq.encode(signature);
11833
11841
  }
11842
+ function eddsa(request, secret, curve) {
11843
+ // secret is the base64 pem encoded key
11844
+ // we get the last 32 bytes
11845
+ const privateKey = new Uint8Array(_static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_2__/* .Base64.unarmor */ .D.unarmor(secret).slice(16));
11846
+ const signature = curve.sign(request, privateKey);
11847
+ return _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base64.encode */ .US.encode(signature);
11848
+ }
11834
11849
  /* ------------------------------------------------------------------------ */
11835
11850
  // source: https://stackoverflow.com/a/18639975/1067003
11836
11851
  function crc32(str, signed = false) {
@@ -12009,11 +12024,13 @@ const filterBy = (x, k, value = undefined, out = []) => {
12009
12024
  }
12010
12025
  return out;
12011
12026
  };
12012
- const sortBy = (array, key, descending = false, direction = descending ? -1 : 1) => array.sort((a, b) => {
12013
- if (a[key] < b[key]) {
12027
+ const sortBy = (array, key, descending = false, defaultValue = 0, direction = descending ? -1 : 1) => array.sort((a, b) => {
12028
+ const first = (key in a) ? a[key] : defaultValue;
12029
+ const second = (key in b) ? b[key] : defaultValue;
12030
+ if (first < second) {
12014
12031
  return -direction;
12015
12032
  }
12016
- else if (a[key] > b[key]) {
12033
+ else if (first > second) {
12017
12034
  return direction;
12018
12035
  }
12019
12036
  else {
@@ -16133,6 +16150,8 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
16133
16150
  /* harmony import */ var _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9292);
16134
16151
  /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1372);
16135
16152
  /* harmony import */ var _base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5981);
16153
+ /* harmony import */ var _base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6890);
16154
+ /* harmony import */ var _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(8817);
16136
16155
  // ---------------------------------------------------------------------------
16137
16156
 
16138
16157
 
@@ -16140,6 +16159,8 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
16140
16159
 
16141
16160
 
16142
16161
 
16162
+
16163
+
16143
16164
  // ---------------------------------------------------------------------------
16144
16165
  /**
16145
16166
  * @class binance
@@ -16169,6 +16190,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16169
16190
  'cancelOrders': true,
16170
16191
  'createDepositAddress': false,
16171
16192
  'createOrder': true,
16193
+ 'createOrders': true,
16172
16194
  'createPostOnlyOrder': true,
16173
16195
  'createReduceOnlyOrder': true,
16174
16196
  'createStopLimitOrder': true,
@@ -16288,7 +16310,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16288
16310
  'v1': 'https://testnet.binance.vision/api/v1',
16289
16311
  },
16290
16312
  'api': {
16291
- 'wapi': 'https://api.binance.com/wapi/v3',
16292
16313
  'sapi': 'https://api.binance.com/sapi/v1',
16293
16314
  'sapiV2': 'https://api.binance.com/sapi/v2',
16294
16315
  'sapiV3': 'https://api.binance.com/sapi/v3',
@@ -16732,27 +16753,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16732
16753
  'sub-account/assets': 0.40002, // Weight(UID): 60 => cost = 0.006667 * 60 = 0.40002
16733
16754
  },
16734
16755
  },
16735
- // deprecated
16736
- 'wapi': {
16737
- 'post': {
16738
- 'withdraw': 1,
16739
- 'sub-account/transfer': 1,
16740
- },
16741
- 'get': {
16742
- 'depositHistory': 1,
16743
- 'withdrawHistory': 1,
16744
- 'depositAddress': 1,
16745
- 'accountStatus': 1,
16746
- 'systemStatus': 1,
16747
- 'apiTradingStatus': 1,
16748
- 'userAssetDribbletLog': 1,
16749
- 'tradeFee': 1,
16750
- 'assetDetail': 1,
16751
- 'sub-account/list': 1,
16752
- 'sub-account/transfer/history': 1,
16753
- 'sub-account/assets': 1,
16754
- },
16755
- },
16756
16756
  'dapiPublic': {
16757
16757
  'get': {
16758
16758
  'ping': 1,
@@ -16866,6 +16866,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16866
16866
  },
16867
16867
  'fapiData': {
16868
16868
  'get': {
16869
+ 'delivery-price': 1,
16869
16870
  'openInterestHist': 1,
16870
16871
  'topLongShortAccountRatio': 1,
16871
16872
  'topLongShortPositionRatio': 1,
@@ -20418,7 +20419,17 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20418
20419
  // "lastTrade": {"id":"69","time":"1676084430567","price":"24.9","qty":"1.00"},
20419
20420
  // "mmp": false
20420
20421
  // }
20422
+ // {
20423
+ // cancelOrders/createOrders
20424
+ // "code": -4005,
20425
+ // "msg": "Quantity greater than max quantity."
20426
+ // },
20421
20427
  //
20428
+ const code = this.safeString(order, 'code');
20429
+ if (code !== undefined) {
20430
+ // cancelOrders/createOrders might have a partial success
20431
+ return this.safeOrder({ 'info': order, 'status': 'rejected' }, market);
20432
+ }
20422
20433
  const status = this.parseOrderStatus(this.safeString(order, 'status'));
20423
20434
  const marketId = this.safeString(order, 'symbol');
20424
20435
  const marketType = ('closePosition' in order) ? 'contract' : 'spot';
@@ -20492,6 +20503,85 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20492
20503
  'trades': fills,
20493
20504
  }, market);
20494
20505
  }
20506
+ async createOrders(orders, params = {}) {
20507
+ /**
20508
+ * @method
20509
+ * @name binance#createOrders
20510
+ * @description *contract only* create a list of trade orders
20511
+ * @see https://binance-docs.github.io/apidocs/futures/en/#place-multiple-orders-trade
20512
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
20513
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
20514
+ */
20515
+ await this.loadMarkets();
20516
+ const ordersRequests = [];
20517
+ let orderSymbols = [];
20518
+ for (let i = 0; i < orders.length; i++) {
20519
+ const rawOrder = orders[i];
20520
+ const marketId = this.safeString(rawOrder, 'symbol');
20521
+ orderSymbols.push(marketId);
20522
+ const type = this.safeString(rawOrder, 'type');
20523
+ const side = this.safeString(rawOrder, 'side');
20524
+ const amount = this.safeValue(rawOrder, 'amount');
20525
+ const price = this.safeValue(rawOrder, 'price');
20526
+ const orderParams = this.safeValue(rawOrder, 'params', {});
20527
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
20528
+ ordersRequests.push(orderRequest);
20529
+ }
20530
+ orderSymbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
20531
+ const market = this.market(orderSymbols[0]);
20532
+ if (market['spot']) {
20533
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support ' + market['type'] + ' orders');
20534
+ }
20535
+ let response = undefined;
20536
+ let request = {
20537
+ 'batchOrders': ordersRequests,
20538
+ };
20539
+ request = this.extend(request, params);
20540
+ if (market['linear']) {
20541
+ response = await this.fapiPrivatePostBatchOrders(request);
20542
+ }
20543
+ else if (market['option']) {
20544
+ response = await this.eapiPrivatePostBatchOrders(request);
20545
+ }
20546
+ else {
20547
+ response = await this.dapiPrivatePostBatchOrders(request);
20548
+ }
20549
+ //
20550
+ // [
20551
+ // {
20552
+ // "code": -4005,
20553
+ // "msg": "Quantity greater than max quantity."
20554
+ // },
20555
+ // {
20556
+ // "orderId": 650640530,
20557
+ // "symbol": "LTCUSDT",
20558
+ // "status": "NEW",
20559
+ // "clientOrderId": "x-xcKtGhcu32184eb13585491289bbaf",
20560
+ // "price": "54.00",
20561
+ // "avgPrice": "0.00",
20562
+ // "origQty": "0.100",
20563
+ // "executedQty": "0.000",
20564
+ // "cumQty": "0.000",
20565
+ // "cumQuote": "0.00000",
20566
+ // "timeInForce": "GTC",
20567
+ // "type": "LIMIT",
20568
+ // "reduceOnly": false,
20569
+ // "closePosition": false,
20570
+ // "side": "BUY",
20571
+ // "positionSide": "BOTH",
20572
+ // "stopPrice": "0.00",
20573
+ // "workingType": "CONTRACT_PRICE",
20574
+ // "priceProtect": false,
20575
+ // "origType": "LIMIT",
20576
+ // "priceMatch": "NONE",
20577
+ // "selfTradePreventionMode": "NONE",
20578
+ // "goodTillDate": 0,
20579
+ // "updateTime": 1698073926929
20580
+ // }
20581
+ // ]
20582
+ //
20583
+ return this.parseOrders(response);
20584
+ }
20495
20585
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
20496
20586
  /**
20497
20587
  * @method
@@ -24546,9 +24636,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24546
24636
  }
24547
24637
  let url = this.urls['api'][api];
24548
24638
  url += '/' + path;
24549
- if (api === 'wapi') {
24550
- url += '.html';
24551
- }
24552
24639
  if (path === 'historicalTrades') {
24553
24640
  if (this.apiKey) {
24554
24641
  headers = {
@@ -24575,7 +24662,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24575
24662
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError(this.id + ' userDataStream endpoint requires `apiKey` credential');
24576
24663
  }
24577
24664
  }
24578
- else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi')) {
24665
+ else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi')) {
24579
24666
  this.checkRequiredCredentials();
24580
24667
  if (method === 'POST' && ((path === 'order') || (path === 'sor/order'))) {
24581
24668
  // inject in implicit API calls
@@ -24590,6 +24677,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24590
24677
  }
24591
24678
  }
24592
24679
  let query = undefined;
24680
+ // handle batchOrders
24681
+ if ((path === 'batchOrders') && (method === 'POST')) {
24682
+ const batchOrders = this.safeValue(params, 'batchOrders');
24683
+ const queryBatch = (this.json(batchOrders));
24684
+ params['batchOrders'] = queryBatch;
24685
+ }
24593
24686
  const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
24594
24687
  let extendedParams = this.extend({
24595
24688
  'timestamp': this.nonce(),
@@ -24628,7 +24721,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24628
24721
  }
24629
24722
  let signature = undefined;
24630
24723
  if (this.secret.indexOf('PRIVATE KEY') > -1) {
24631
- signature = this.encodeURIComponent((0,_base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__/* .rsa */ .j)(query, this.secret, _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J));
24724
+ if (this.secret.length > 120) {
24725
+ signature = this.encodeURIComponent((0,_base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__/* .rsa */ .j)(query, this.secret, _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J));
24726
+ }
24727
+ else {
24728
+ signature = this.encodeURIComponent((0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_6__/* .eddsa */ .UZ)(this.encode(query), this.secret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_7__/* .ed25519 */ .UN));
24729
+ }
24632
24730
  }
24633
24731
  else {
24634
24732
  signature = this.hmac(this.encode(query), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J);
@@ -24637,7 +24735,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24637
24735
  headers = {
24638
24736
  'X-MBX-APIKEY': this.apiKey,
24639
24737
  };
24640
- if ((method === 'GET') || (method === 'DELETE') || (api === 'wapi')) {
24738
+ if ((method === 'GET') || (method === 'DELETE')) {
24641
24739
  url += '?' + query;
24642
24740
  }
24643
24741
  else {
@@ -24673,7 +24771,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24673
24771
  if (response === undefined) {
24674
24772
  return undefined; // fallback to default error handler
24675
24773
  }
24676
- // check success value for wapi endpoints
24677
24774
  // response in format {'msg': 'The coin does not exist.', 'success': true/false}
24678
24775
  const success = this.safeValue(response, 'success', true);
24679
24776
  if (!success) {
@@ -24728,10 +24825,10 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24728
24825
  }
24729
24826
  if (Array.isArray(response)) {
24730
24827
  // cancelOrders returns an array like this: [{"code":-2011,"msg":"Unknown order sent."}]
24731
- const numElements = response.length;
24732
- if (numElements > 0) {
24733
- const firstElement = response[0];
24734
- const errorCode = this.safeString(firstElement, 'code');
24828
+ const arrayLength = response.length;
24829
+ if (arrayLength === 1) { // when there's a single error we can throw, otherwise we have a partial success
24830
+ const element = response[0];
24831
+ const errorCode = this.safeString(element, 'code');
24735
24832
  if (errorCode !== undefined) {
24736
24833
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, this.id + ' ' + body);
24737
24834
  }
@@ -24764,7 +24861,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24764
24861
  async request(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined, config = {}, context = {}) {
24765
24862
  const response = await this.fetch2(path, api, method, params, headers, body, config);
24766
24863
  // a workaround for {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
24767
- if ((api === 'private') || (api === 'wapi')) {
24864
+ if (api === 'private') {
24768
24865
  this.options['hasAlreadyAuthenticatedSuccessfully'] = true;
24769
24866
  }
24770
24867
  return response;
@@ -38736,6 +38833,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
38736
38833
  'cancelOrder': true,
38737
38834
  'cancelOrders': true,
38738
38835
  'createOrder': true,
38836
+ 'createOrders': true,
38739
38837
  'createReduceOnlyOrder': false,
38740
38838
  'editOrder': true,
38741
38839
  'fetchAccounts': false,
@@ -38761,10 +38859,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
38761
38859
  'fetchLedger': true,
38762
38860
  'fetchLeverage': true,
38763
38861
  'fetchLeverageTiers': false,
38862
+ 'fetchLiquidations': false,
38764
38863
  'fetchMarginMode': undefined,
38765
38864
  'fetchMarketLeverageTiers': true,
38766
38865
  'fetchMarkets': true,
38767
38866
  'fetchMarkOHLCV': true,
38867
+ 'fetchMyLiquidations': true,
38768
38868
  'fetchMyTrades': true,
38769
38869
  'fetchOHLCV': true,
38770
38870
  'fetchOpenInterest': true,
@@ -41682,7 +41782,23 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41682
41782
  // "fillTotalAmount": "0",
41683
41783
  // "ctime": "1697773902588"
41684
41784
  // }
41785
+ // cancelOrders failing
41685
41786
  //
41787
+ // {
41788
+ // "orderId": "1627293504611",
41789
+ // "clientOid": "BITGET#1627293504611",
41790
+ // "errorMsg":"Duplicate clientOid"
41791
+ // }
41792
+ //
41793
+ const errorMessage = this.safeString(order, 'errorMsg');
41794
+ if (errorMessage !== undefined) {
41795
+ return this.safeOrder({
41796
+ 'info': order,
41797
+ 'id': this.safeString(order, 'orderId'),
41798
+ 'clientOrderId': this.safeString(order, 'clientOrderId'),
41799
+ 'status': 'rejected',
41800
+ }, market);
41801
+ }
41686
41802
  const marketId = this.safeString(order, 'symbol');
41687
41803
  market = this.safeMarket(marketId, market);
41688
41804
  const timestamp = this.safeInteger2(order, 'cTime', 'ctime');
@@ -41773,9 +41889,60 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41773
41889
  */
41774
41890
  await this.loadMarkets();
41775
41891
  const market = this.market(symbol);
41776
- let marketType = undefined;
41777
41892
  let marginMode = undefined;
41893
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
41894
+ const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
41895
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
41896
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
41897
+ const isTriggerOrder = triggerPrice !== undefined;
41898
+ const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
41899
+ const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
41900
+ const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
41901
+ const request = this.createOrderRequest(symbol, type, side, amount, price, params);
41778
41902
  let response = undefined;
41903
+ if (market['spot']) {
41904
+ if (isTriggerOrder) {
41905
+ response = await this.privateSpotPostPlanPlacePlan(request);
41906
+ }
41907
+ else if (marginMode === 'isolated') {
41908
+ response = await this.privateMarginPostIsolatedOrderPlaceOrder(request);
41909
+ }
41910
+ else if (marginMode === 'cross') {
41911
+ response = await this.privateMarginPostCrossOrderPlaceOrder(request);
41912
+ }
41913
+ else {
41914
+ response = await this.privateSpotPostTradeOrders(request);
41915
+ }
41916
+ }
41917
+ else {
41918
+ if (isTriggerOrder) {
41919
+ response = await this.privateMixPostPlanPlacePlan(request);
41920
+ }
41921
+ else if (isStopLossOrTakeProfitTrigger) {
41922
+ response = await this.privateMixPostPlanPlacePositionsTPSL(request);
41923
+ }
41924
+ else {
41925
+ response = await this.privateMixPostOrderPlaceOrder(request);
41926
+ }
41927
+ }
41928
+ //
41929
+ // {
41930
+ // "code": "00000",
41931
+ // "msg": "success",
41932
+ // "requestTime": 1645932209602,
41933
+ // "data": {
41934
+ // "orderId": "881669078313766912",
41935
+ // "clientOrderId": "iauIBf#a45b595f96474d888d0ada"
41936
+ // }
41937
+ // }
41938
+ //
41939
+ const data = this.safeValue(response, 'data', {});
41940
+ return this.parseOrder(data, market);
41941
+ }
41942
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
41943
+ const market = this.market(symbol);
41944
+ let marketType = undefined;
41945
+ let marginMode = undefined;
41779
41946
  [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
41780
41947
  [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
41781
41948
  const marketId = market['id'];
@@ -41873,7 +42040,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41873
42040
  if (price !== undefined) {
41874
42041
  request['executePrice'] = this.priceToPrecision(symbol, price);
41875
42042
  }
41876
- response = await this.privateMixPostPlanPlacePlan(this.extend(request, params));
41877
42043
  }
41878
42044
  else if (isStopLossOrTakeProfitTrigger) {
41879
42045
  if (isStopLossTriggerOrder) {
@@ -41884,7 +42050,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41884
42050
  request['triggerPrice'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
41885
42051
  request['planType'] = 'pos_profit';
41886
42052
  }
41887
- response = await this.privateMixPostPlanPlacePositionsTPSL(this.extend(request, params));
41888
42053
  }
41889
42054
  else {
41890
42055
  if (isStopLoss) {
@@ -41895,7 +42060,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41895
42060
  const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice');
41896
42061
  request['presetTakeProfitPrice'] = this.priceToPrecision(symbol, tpTriggerPrice);
41897
42062
  }
41898
- response = await this.privateMixPostOrderPlaceOrder(this.extend(request, params));
41899
42063
  }
41900
42064
  }
41901
42065
  else if (marketType === 'spot') {
@@ -41931,7 +42095,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41931
42095
  if (clientOrderId !== undefined) {
41932
42096
  request['clientOrderId'] = clientOrderId;
41933
42097
  }
41934
- response = await this.privateSpotPostPlanPlacePlan(this.extend(request, params));
41935
42098
  }
41936
42099
  else if (marginMode !== undefined) {
41937
42100
  request['loanType'] = 'normal';
@@ -41944,12 +42107,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41944
42107
  else {
41945
42108
  request['baseQuantity'] = quantity;
41946
42109
  }
41947
- if (marginMode === 'isolated') {
41948
- response = await this.privateMarginPostIsolatedOrderPlaceOrder(this.extend(request, params));
41949
- }
41950
- else if (marginMode === 'cross') {
41951
- response = await this.privateMarginPostCrossOrderPlaceOrder(this.extend(request, params));
41952
- }
41953
42110
  }
41954
42111
  else {
41955
42112
  if (clientOrderId !== undefined) {
@@ -41958,25 +42115,86 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41958
42115
  if (quantity !== undefined) {
41959
42116
  request['quantity'] = quantity;
41960
42117
  }
41961
- response = await this.privateSpotPostTradeOrders(this.extend(request, params));
41962
42118
  }
41963
42119
  }
41964
42120
  else {
41965
42121
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' createOrder() does not support ' + marketType + ' orders');
41966
42122
  }
42123
+ return this.extend(request, params);
42124
+ }
42125
+ async createOrders(orders, params = {}) {
42126
+ /**
42127
+ * @method
42128
+ * @name bitget#createOrders
42129
+ * @description create a list of trade orders (all orders should be of the same symbol)
42130
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#batch-order
42131
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#batch-order
42132
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
42133
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
42134
+ */
42135
+ await this.loadMarkets();
42136
+ const ordersRequests = [];
42137
+ let symbol = undefined;
42138
+ for (let i = 0; i < orders.length; i++) {
42139
+ const rawOrder = orders[i];
42140
+ const marketId = this.safeString(rawOrder, 'symbol');
42141
+ if (symbol === undefined) {
42142
+ symbol = marketId;
42143
+ }
42144
+ else {
42145
+ if (symbol !== marketId) {
42146
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
42147
+ }
42148
+ }
42149
+ const type = this.safeString(rawOrder, 'type');
42150
+ const side = this.safeString(rawOrder, 'side');
42151
+ const amount = this.safeValue(rawOrder, 'amount');
42152
+ const price = this.safeValue(rawOrder, 'price');
42153
+ const orderParams = this.safeValue(rawOrder, 'params', {});
42154
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
42155
+ ordersRequests.push(orderRequest);
42156
+ }
42157
+ const market = this.market(symbol);
42158
+ const request = {
42159
+ 'symbol': market['id'],
42160
+ };
42161
+ let response = undefined;
42162
+ if (market['spot']) {
42163
+ request['orderList'] = ordersRequests;
42164
+ response = await this.privateSpotPostTradeBatchOrders(request);
42165
+ }
42166
+ else {
42167
+ request['orderDataList'] = ordersRequests;
42168
+ request['marginCoin'] = market['settleId'];
42169
+ response = await this.privateMixPostOrderBatchOrders(request);
42170
+ }
41967
42171
  //
41968
- // {
41969
- // "code": "00000",
41970
- // "msg": "success",
41971
- // "requestTime": 1645932209602,
41972
- // "data": {
41973
- // "orderId": "881669078313766912",
41974
- // "clientOrderId": "iauIBf#a45b595f96474d888d0ada"
42172
+ // {
42173
+ // "code": "00000",
42174
+ // "data": {
42175
+ // "orderInfo": [
42176
+ // {
42177
+ // "orderId": "1627293504612",
42178
+ // "clientOid": "BITGET#1627293504612"
41975
42179
  // }
41976
- // }
42180
+ // ],
42181
+ // "failure":[
42182
+ // {
42183
+ // "orderId": "1627293504611",
42184
+ // "clientOid": "BITGET#1627293504611",
42185
+ // "errorMsg":"Duplicate clientOid"
42186
+ // }
42187
+ // ]
42188
+ // },
42189
+ // "msg": "success",
42190
+ // "requestTime": 1627293504612
42191
+ // }
41977
42192
  //
41978
42193
  const data = this.safeValue(response, 'data', {});
41979
- return this.parseOrder(data, market);
42194
+ const failure = this.safeValue(data, 'failure', []);
42195
+ const orderInfo = this.safeValue2(data, 'orderInfo', 'resultList', []);
42196
+ const both = this.arrayConcat(orderInfo, failure);
42197
+ return this.parseOrders(both);
41980
42198
  }
41981
42199
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
41982
42200
  /**
@@ -44612,6 +44830,153 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44612
44830
  'info': info,
44613
44831
  };
44614
44832
  }
44833
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
44834
+ /**
44835
+ * @method
44836
+ * @name bitget#fetchMyLiquidations
44837
+ * @description retrieves the users liquidated positions
44838
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-liquidation-records
44839
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-liquidation-records
44840
+ * @param {string} [symbol] unified CCXT market symbol
44841
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
44842
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
44843
+ * @param {object} [params] exchange specific parameters for the bitget api endpoint
44844
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
44845
+ * @param {string} [params.marginMode] 'cross' or 'isolated' default value is 'cross'
44846
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
44847
+ */
44848
+ await this.loadMarkets();
44849
+ let market = undefined;
44850
+ if (symbol !== undefined) {
44851
+ market = this.market(symbol);
44852
+ }
44853
+ let type = undefined;
44854
+ [type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
44855
+ if (type !== 'spot') {
44856
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' fetchMyLiquidations() supports spot margin markets only');
44857
+ }
44858
+ let request = {};
44859
+ [request, params] = this.handleUntilOption('endTime', request, params);
44860
+ if (since !== undefined) {
44861
+ request['startTime'] = since;
44862
+ }
44863
+ else {
44864
+ request['startTime'] = this.milliseconds() - 7776000000;
44865
+ }
44866
+ if (limit !== undefined) {
44867
+ request['pageSize'] = limit;
44868
+ }
44869
+ let response = undefined;
44870
+ let marginMode = undefined;
44871
+ [marginMode, params] = this.handleMarginModeAndParams('fetchMyLiquidations', params, 'cross');
44872
+ if (marginMode === 'isolated') {
44873
+ this.checkRequiredSymbol('fetchMyLiquidations', symbol);
44874
+ request['symbol'] = market['info']['symbolName'];
44875
+ response = await this.privateMarginGetIsolatedLiquidationList(this.extend(request, params));
44876
+ }
44877
+ else if (marginMode === 'cross') {
44878
+ response = await this.privateMarginGetCrossLiquidationList(this.extend(request, params));
44879
+ }
44880
+ //
44881
+ // isolated
44882
+ //
44883
+ // {
44884
+ // "code": "00000",
44885
+ // "msg": "success",
44886
+ // "requestTime": 1698114119193,
44887
+ // "data": {
44888
+ // "resultList": [
44889
+ // {
44890
+ // "liqId": "123",
44891
+ // "symbol": "BTCUSDT",
44892
+ // "liqStartTime": "1653453245342",
44893
+ // "liqEndTime": "16312423423432",
44894
+ // "liqRisk": "1.01",
44895
+ // "totalAssets": "1242.34",
44896
+ // "totalDebt": "1100",
44897
+ // "LiqFee": "1.2",
44898
+ // "cTime": "1653453245342"
44899
+ // }
44900
+ // ],
44901
+ // "maxId": "0",
44902
+ // "minId": "0"
44903
+ // }
44904
+ // }
44905
+ //
44906
+ // cross
44907
+ //
44908
+ // {
44909
+ // "code": "00000",
44910
+ // "msg": "success",
44911
+ // "requestTime": 1698114119193,
44912
+ // "data": {
44913
+ // "resultList": [
44914
+ // {
44915
+ // "liqId": "123",
44916
+ // "liqStartTime": "1653453245342",
44917
+ // "liqEndTime": "16312423423432",
44918
+ // "liqRisk": "1.01",
44919
+ // "totalAssets": "1242.34",
44920
+ // "totalDebt": "1100",
44921
+ // "LiqFee": "1.2",
44922
+ // "cTime": "1653453245342"
44923
+ // }
44924
+ // ],
44925
+ // "maxId": "0",
44926
+ // "minId": "0"
44927
+ // }
44928
+ // }
44929
+ //
44930
+ const data = this.safeValue(response, 'data', {});
44931
+ const liquidations = this.safeValue(data, 'resultList', []);
44932
+ return this.parseLiquidations(liquidations, market, since, limit);
44933
+ }
44934
+ parseLiquidation(liquidation, market = undefined) {
44935
+ //
44936
+ // isolated
44937
+ //
44938
+ // {
44939
+ // "liqId": "123",
44940
+ // "symbol": "BTCUSDT",
44941
+ // "liqStartTime": "1653453245342",
44942
+ // "liqEndTime": "16312423423432",
44943
+ // "liqRisk": "1.01",
44944
+ // "totalAssets": "1242.34",
44945
+ // "totalDebt": "1100",
44946
+ // "LiqFee": "1.2",
44947
+ // "cTime": "1653453245342"
44948
+ // }
44949
+ //
44950
+ // cross
44951
+ //
44952
+ // {
44953
+ // "liqId": "123",
44954
+ // "liqStartTime": "1653453245342",
44955
+ // "liqEndTime": "16312423423432",
44956
+ // "liqRisk": "1.01",
44957
+ // "totalAssets": "1242.34",
44958
+ // "totalDebt": "1100",
44959
+ // "LiqFee": "1.2",
44960
+ // "cTime": "1653453245342"
44961
+ // }
44962
+ //
44963
+ const marketId = this.safeString(liquidation, 'symbol');
44964
+ const timestamp = this.safeInteger(liquidation, 'liqEndTime');
44965
+ const liquidationFee = this.safeString(liquidation, 'LiqFee');
44966
+ const totalDebt = this.safeString(liquidation, 'totalDebt');
44967
+ const quoteValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(liquidationFee, totalDebt);
44968
+ return {
44969
+ 'info': liquidation,
44970
+ 'symbol': this.safeSymbol(marketId, market),
44971
+ 'contracts': undefined,
44972
+ 'contractSize': undefined,
44973
+ 'price': undefined,
44974
+ 'baseValue': undefined,
44975
+ 'quoteValue': this.parseNumber(quoteValueString),
44976
+ 'timestamp': timestamp,
44977
+ 'datetime': this.iso8601(timestamp),
44978
+ };
44979
+ }
44615
44980
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
44616
44981
  if (!response) {
44617
44982
  return undefined; // fallback to default error handler
@@ -47927,7 +48292,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
47927
48292
  '7': 'canceling',
47928
48293
  '8': 'canceled',
47929
48294
  'new': 'open',
47930
- 'partially_filled': 'filled',
48295
+ 'partially_filled': 'open',
47931
48296
  'filled': 'filled',
47932
48297
  'partially_canceled': 'canceled',
47933
48298
  },
@@ -73069,6 +73434,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
73069
73434
  'cancelAllOrders': true,
73070
73435
  'cancelOrder': true,
73071
73436
  'createOrder': true,
73437
+ 'createOrders': true,
73072
73438
  'createPostOnlyOrder': true,
73073
73439
  'createReduceOnlyOrder': true,
73074
73440
  'createStopLimitOrder': true,
@@ -74484,7 +74850,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
74484
74850
  }
74485
74851
  return super.safeMarket(marketId, market, delimiter, marketType);
74486
74852
  }
74487
- getBybitType(method, market, params) {
74853
+ getBybitType(method, market, params = {}) {
74488
74854
  let type = undefined;
74489
74855
  [type, params] = this.handleMarketTypeAndParams(method, market, params);
74490
74856
  let subType = undefined;
@@ -76547,7 +76913,31 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76547
76913
  // "createdTime": "1684476068369",
76548
76914
  // "updatedTime": "1684476068372"
76549
76915
  // }
76916
+ // createOrders failed order
76917
+ // {
76918
+ // category: 'linear',
76919
+ // symbol: 'LTCUSDT',
76920
+ // orderId: '',
76921
+ // orderLinkId: '',
76922
+ // createAt: '',
76923
+ // code: '10001',
76924
+ // msg: 'The number of contracts exceeds maximum limit allowed: too large'
76925
+ // }
76550
76926
  //
76927
+ const code = this.safeString(order, 'code');
76928
+ if (code !== undefined) {
76929
+ if (code !== '0') {
76930
+ const category = this.safeString(order, 'category');
76931
+ const inferedMarketType = (category === 'spot') ? 'spot' : 'contract';
76932
+ return this.safeOrder({
76933
+ 'info': order,
76934
+ 'status': 'rejected',
76935
+ 'id': this.safeString(order, 'orderId'),
76936
+ 'clientOrderId': this.safeString(order, 'orderLinkId'),
76937
+ 'symbol': this.safeSymbol(this.safeString(order, 'symbol'), undefined, undefined, inferedMarketType),
76938
+ });
76939
+ }
76940
+ }
76551
76941
  const marketId = this.safeString(order, 'symbol');
76552
76942
  const isContract = ('tpslMode' in order);
76553
76943
  let marketType = undefined;
@@ -76707,13 +77097,32 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76707
77097
  */
76708
77098
  await this.loadMarkets();
76709
77099
  const market = this.market(symbol);
76710
- symbol = market['symbol'];
76711
77100
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
76712
77101
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
76713
77102
  const isUsdcSettled = market['settle'] === 'USDC';
76714
77103
  if (isUsdcSettled && !isUnifiedAccount) {
76715
77104
  return await this.createUsdcOrder(symbol, type, side, amount, price, params);
76716
77105
  }
77106
+ const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
77107
+ const response = await this.privatePostV5OrderCreate(orderRequest); // already extended inside createOrderRequest
77108
+ //
77109
+ // {
77110
+ // "retCode": 0,
77111
+ // "retMsg": "OK",
77112
+ // "result": {
77113
+ // "orderId": "1321003749386327552",
77114
+ // "orderLinkId": "spot-test-postonly"
77115
+ // },
77116
+ // "retExtInfo": {},
77117
+ // "time": 1672211918471
77118
+ // }
77119
+ //
77120
+ const order = this.safeValue(response, 'result', {});
77121
+ return this.parseOrder(order, market);
77122
+ }
77123
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
77124
+ const market = this.market(symbol);
77125
+ symbol = market['symbol'];
76717
77126
  const lowerCaseType = type.toLowerCase();
76718
77127
  if ((price === undefined) && (lowerCaseType === 'limit')) {
76719
77128
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder requires a price argument for limit orders');
@@ -76855,21 +77264,94 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76855
77264
  request['orderLinkId'] = this.uuid16();
76856
77265
  }
76857
77266
  params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit']);
76858
- const response = await this.privatePostV5OrderCreate(this.extend(request, params));
77267
+ return this.extend(request, params);
77268
+ }
77269
+ async createOrders(orders, params = {}) {
77270
+ /**
77271
+ * @method
77272
+ * @name bybit#createOrders
77273
+ * @description create a list of trade orders
77274
+ * @see https://bybit-exchange.github.io/docs/v5/order/batch-place
77275
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
77276
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
77277
+ */
77278
+ await this.loadMarkets();
77279
+ const ordersRequests = [];
77280
+ const orderSymbols = [];
77281
+ for (let i = 0; i < orders.length; i++) {
77282
+ const rawOrder = orders[i];
77283
+ const marketId = this.safeString(rawOrder, 'symbol');
77284
+ orderSymbols.push(marketId);
77285
+ const type = this.safeString(rawOrder, 'type');
77286
+ const side = this.safeString(rawOrder, 'side');
77287
+ const amount = this.safeValue(rawOrder, 'amount');
77288
+ const price = this.safeValue(rawOrder, 'price');
77289
+ const orderParams = this.safeValue(rawOrder, 'params', {});
77290
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
77291
+ ordersRequests.push(orderRequest);
77292
+ }
77293
+ const symbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
77294
+ const market = this.market(symbols[0]);
77295
+ let category = undefined;
77296
+ [category, params] = this.getBybitType('createOrders', market, params);
77297
+ if ((category === 'spot') || (category === 'inverse')) {
77298
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' createOrders does not allow spot or inverse orders');
77299
+ }
77300
+ const request = {
77301
+ 'category': category,
77302
+ 'request': ordersRequests,
77303
+ };
77304
+ const response = await this.privatePostV5OrderCreateBatch(this.extend(request, params));
77305
+ const result = this.safeValue(response, 'result', {});
77306
+ const data = this.safeValue(result, 'list', []);
77307
+ const retInfo = this.safeValue(response, 'retExtInfo', {});
77308
+ const codes = this.safeValue(retInfo, 'list', []);
77309
+ // extend the error with the unsuccessful orders
77310
+ for (let i = 0; i < codes.length; i++) {
77311
+ const code = codes[i];
77312
+ const retCode = this.safeInteger(code, 'code');
77313
+ if (retCode !== 0) {
77314
+ data[i] = this.extend(data[i], code);
77315
+ }
77316
+ }
76859
77317
  //
76860
- // {
76861
- // "retCode": 0,
76862
- // "retMsg": "OK",
76863
- // "result": {
76864
- // "orderId": "1321003749386327552",
76865
- // "orderLinkId": "spot-test-postonly"
76866
- // },
76867
- // "retExtInfo": {},
76868
- // "time": 1672211918471
76869
- // }
77318
+ // {
77319
+ // "retCode":0,
77320
+ // "retMsg":"OK",
77321
+ // "result":{
77322
+ // "list":[
77323
+ // {
77324
+ // "category":"linear",
77325
+ // "symbol":"LTCUSDT",
77326
+ // "orderId":"",
77327
+ // "orderLinkId":"",
77328
+ // "createAt":""
77329
+ // },
77330
+ // {
77331
+ // "category":"linear",
77332
+ // "symbol":"LTCUSDT",
77333
+ // "orderId":"3c9f65b6-01ad-4ac0-9741-df17e02a4223",
77334
+ // "orderLinkId":"",
77335
+ // "createAt":"1698075516029"
77336
+ // }
77337
+ // ]
77338
+ // },
77339
+ // "retExtInfo":{
77340
+ // "list":[
77341
+ // {
77342
+ // "code":10001,
77343
+ // "msg":"The number of contracts exceeds maximum limit allowed: too large"
77344
+ // },
77345
+ // {
77346
+ // "code":0,
77347
+ // "msg":"OK"
77348
+ // }
77349
+ // ]
77350
+ // },
77351
+ // "time":1698075516029
77352
+ // }
76870
77353
  //
76871
- const order = this.safeValue(response, 'result', {});
76872
- return this.parseOrder(order, market);
77354
+ return this.parseOrders(data);
76873
77355
  }
76874
77356
  async createUsdcOrder(symbol, type, side, amount, price = undefined, params = {}) {
76875
77357
  await this.loadMarkets();
@@ -98385,6 +98867,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
98385
98867
  'cancelAllOrders': true,
98386
98868
  'cancelOrder': true,
98387
98869
  'createOrder': true,
98870
+ 'createOrders': true,
98388
98871
  'fetchAccounts': true,
98389
98872
  'fetchBalance': true,
98390
98873
  'fetchBidsAsks': false,
@@ -99519,6 +100002,210 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
99519
100002
  const result = this.safeValue(response, 'result', {});
99520
100003
  return this.parseOrder(result, market);
99521
100004
  }
100005
+ async createOrders(orders, params = {}) {
100006
+ /**
100007
+ * @method
100008
+ * @name cryptocom#createOrders
100009
+ * @description create a list of trade orders
100010
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-list
100011
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-oco
100012
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
100013
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
100014
+ */
100015
+ await this.loadMarkets();
100016
+ const ordersRequests = [];
100017
+ for (let i = 0; i < orders.length; i++) {
100018
+ const rawOrder = orders[i];
100019
+ const marketId = this.safeString(rawOrder, 'symbol');
100020
+ const type = this.safeString(rawOrder, 'type');
100021
+ const side = this.safeString(rawOrder, 'side');
100022
+ const amount = this.safeValue(rawOrder, 'amount');
100023
+ const price = this.safeValue(rawOrder, 'price');
100024
+ const orderParams = this.safeValue(rawOrder, 'params', {});
100025
+ const orderRequest = this.createAdvancedOrderRequest(marketId, type, side, amount, price, orderParams);
100026
+ ordersRequests.push(orderRequest);
100027
+ }
100028
+ const contigency = this.safeString(params, 'contingency_type', 'LIST');
100029
+ const request = {
100030
+ 'contingency_type': contigency,
100031
+ 'order_list': ordersRequests,
100032
+ };
100033
+ const response = await this.v1PrivatePostPrivateCreateOrderList(this.extend(request, params));
100034
+ //
100035
+ // {
100036
+ // "id": 12,
100037
+ // "method": "private/create-order-list",
100038
+ // "code": 10001,
100039
+ // "result": {
100040
+ // "result_list": [
100041
+ // {
100042
+ // "index": 0,
100043
+ // "code": 0,
100044
+ // "order_id": "2015106383706015873",
100045
+ // "client_oid": "my_order_0001"
100046
+ // },
100047
+ // {
100048
+ // "index": 1,
100049
+ // "code": 20007,
100050
+ // "message": "INVALID_REQUEST",
100051
+ // "client_oid": "my_order_0002"
100052
+ // }
100053
+ // ]
100054
+ // }
100055
+ // }
100056
+ //
100057
+ // {
100058
+ // "id" : 1698068111133,
100059
+ // "method" : "private/create-order-list",
100060
+ // "code" : 0,
100061
+ // "result" : [ {
100062
+ // "code" : 0,
100063
+ // "index" : 0,
100064
+ // "client_oid" : "1698068111133_0",
100065
+ // "order_id" : "6142909896519488206"
100066
+ // }, {
100067
+ // "code" : 306,
100068
+ // "index" : 1,
100069
+ // "client_oid" : "1698068111133_1",
100070
+ // "message" : "INSUFFICIENT_AVAILABLE_BALANCE",
100071
+ // "order_id" : "6142909896519488207"
100072
+ // } ]
100073
+ // }
100074
+ //
100075
+ const result = this.safeValue(response, 'result', []);
100076
+ const listId = this.safeString(result, 'list_id');
100077
+ if (listId !== undefined) {
100078
+ const ocoOrders = [{ 'order_id': listId }];
100079
+ return this.parseOrders(ocoOrders);
100080
+ }
100081
+ return this.parseOrders(result);
100082
+ }
100083
+ createAdvancedOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
100084
+ // differs slightly from createOrderRequest
100085
+ // since the advanced order endpoint requires a different set of parameters
100086
+ // namely here we don't support ref_price or spot_margin
100087
+ // and market-buy orders need to send notional instead of quantity
100088
+ const market = this.market(symbol);
100089
+ const uppercaseType = type.toUpperCase();
100090
+ const request = {
100091
+ 'instrument_name': market['id'],
100092
+ 'side': side.toUpperCase(),
100093
+ };
100094
+ if ((uppercaseType === 'LIMIT') || (uppercaseType === 'STOP_LIMIT') || (uppercaseType === 'TAKE_PROFIT_LIMIT')) {
100095
+ request['price'] = this.priceToPrecision(symbol, price);
100096
+ }
100097
+ const broker = this.safeString(this.options, 'broker', 'CCXT');
100098
+ request['broker_id'] = broker;
100099
+ const timeInForce = this.safeStringUpper2(params, 'timeInForce', 'time_in_force');
100100
+ if (timeInForce !== undefined) {
100101
+ if (timeInForce === 'GTC') {
100102
+ request['time_in_force'] = 'GOOD_TILL_CANCEL';
100103
+ }
100104
+ else if (timeInForce === 'IOC') {
100105
+ request['time_in_force'] = 'IMMEDIATE_OR_CANCEL';
100106
+ }
100107
+ else if (timeInForce === 'FOK') {
100108
+ request['time_in_force'] = 'FILL_OR_KILL';
100109
+ }
100110
+ else {
100111
+ request['time_in_force'] = timeInForce;
100112
+ }
100113
+ }
100114
+ const postOnly = this.safeValue(params, 'postOnly', false);
100115
+ if ((postOnly) || (timeInForce === 'PO')) {
100116
+ request['exec_inst'] = ['POST_ONLY'];
100117
+ request['time_in_force'] = 'GOOD_TILL_CANCEL';
100118
+ }
100119
+ const triggerPrice = this.safeStringN(params, ['stopPrice', 'triggerPrice', 'ref_price']);
100120
+ const stopLossPrice = this.safeNumber(params, 'stopLossPrice');
100121
+ const takeProfitPrice = this.safeNumber(params, 'takeProfitPrice');
100122
+ const isTrigger = (triggerPrice !== undefined);
100123
+ const isStopLossTrigger = (stopLossPrice !== undefined);
100124
+ const isTakeProfitTrigger = (takeProfitPrice !== undefined);
100125
+ if (isTrigger) {
100126
+ price = price.toString();
100127
+ if ((uppercaseType === 'LIMIT') || (uppercaseType === 'STOP_LIMIT') || (uppercaseType === 'TAKE_PROFIT_LIMIT')) {
100128
+ if (side === 'buy') {
100129
+ if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
100130
+ request['type'] = 'TAKE_PROFIT_LIMIT';
100131
+ }
100132
+ else {
100133
+ request['type'] = 'STOP_LIMIT';
100134
+ }
100135
+ }
100136
+ else {
100137
+ if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
100138
+ request['type'] = 'STOP_LIMIT';
100139
+ }
100140
+ else {
100141
+ request['type'] = 'TAKE_PROFIT_LIMIT';
100142
+ }
100143
+ }
100144
+ }
100145
+ else {
100146
+ if (side === 'buy') {
100147
+ if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
100148
+ request['type'] = 'TAKE_PROFIT';
100149
+ }
100150
+ else {
100151
+ request['type'] = 'STOP_LOSS';
100152
+ }
100153
+ }
100154
+ else {
100155
+ if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
100156
+ request['type'] = 'STOP_LOSS';
100157
+ }
100158
+ else {
100159
+ request['type'] = 'TAKE_PROFIT';
100160
+ }
100161
+ }
100162
+ }
100163
+ }
100164
+ else if (isStopLossTrigger) {
100165
+ if ((uppercaseType === 'LIMIT') || (uppercaseType === 'STOP_LIMIT')) {
100166
+ request['type'] = 'STOP_LIMIT';
100167
+ }
100168
+ else {
100169
+ request['type'] = 'STOP_LOSS';
100170
+ }
100171
+ }
100172
+ else if (isTakeProfitTrigger) {
100173
+ if ((uppercaseType === 'LIMIT') || (uppercaseType === 'TAKE_PROFIT_LIMIT')) {
100174
+ request['type'] = 'TAKE_PROFIT_LIMIT';
100175
+ }
100176
+ else {
100177
+ request['type'] = 'TAKE_PROFIT';
100178
+ }
100179
+ }
100180
+ else {
100181
+ request['type'] = uppercaseType;
100182
+ }
100183
+ if ((side === 'buy') && ((uppercaseType === 'MARKET') || (uppercaseType === 'STOP_LOSS') || (uppercaseType === 'TAKE_PROFIT'))) {
100184
+ // use createmarketBuy logic here
100185
+ if (this.options['createMarketBuyOrderRequiresPrice']) {
100186
+ const cost = this.safeNumber2(params, 'cost', 'notional');
100187
+ params = this.omit(params, 'cost');
100188
+ if (price === undefined && cost === undefined) {
100189
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false to supply the cost in the amount argument (the exchange-specific behaviour)');
100190
+ }
100191
+ else {
100192
+ const amountString = this.numberToString(amount);
100193
+ const priceString = this.numberToString(price);
100194
+ const quoteAmount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(amountString, priceString);
100195
+ amount = (cost !== undefined) ? cost : this.parseNumber(quoteAmount);
100196
+ request['notional'] = this.costToPrecision(symbol, amount);
100197
+ }
100198
+ }
100199
+ else {
100200
+ request['notional'] = this.costToPrecision(symbol, amount);
100201
+ }
100202
+ }
100203
+ else {
100204
+ request['quantity'] = this.amountToPrecision(symbol, amount);
100205
+ }
100206
+ params = this.omit(params, ['postOnly', 'clientOrderId', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
100207
+ return this.extend(request, params);
100208
+ }
99522
100209
  async cancelAllOrders(symbol = undefined, params = {}) {
99523
100210
  /**
99524
100211
  * @method
@@ -100359,12 +101046,31 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
100359
101046
  // "update_time": 1686806053993
100360
101047
  // }
100361
101048
  //
101049
+ // createOrders
101050
+ // {
101051
+ // "code" : 306,
101052
+ // "index" : 1,
101053
+ // "client_oid" : "1698068111133_1",
101054
+ // "message" : "INSUFFICIENT_AVAILABLE_BALANCE",
101055
+ // "order_id" : "6142909896519488207"
101056
+ // }
101057
+ //
101058
+ const code = this.safeInteger(order, 'code');
101059
+ if ((code !== undefined) && (code !== 0)) {
101060
+ return this.safeOrder({
101061
+ 'id': this.safeString(order, 'order_id'),
101062
+ 'clientOrderId': this.safeString(order, 'client_oid'),
101063
+ 'info': order,
101064
+ 'status': 'rejected',
101065
+ });
101066
+ }
100362
101067
  const created = this.safeInteger(order, 'create_time');
100363
101068
  const marketId = this.safeString(order, 'instrument_name');
100364
101069
  const symbol = this.safeSymbol(marketId, market);
100365
101070
  const execInst = this.safeValue(order, 'exec_inst');
100366
- let postOnly = false;
101071
+ let postOnly = undefined;
100367
101072
  if (execInst !== undefined) {
101073
+ postOnly = false;
100368
101074
  for (let i = 0; i < execInst.length; i++) {
100369
101075
  const inst = execInst[i];
100370
101076
  if (inst === 'POST_ONLY') {
@@ -101286,6 +101992,41 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
101286
101992
  nonce() {
101287
101993
  return this.milliseconds();
101288
101994
  }
101995
+ paramsToString(object, level) {
101996
+ const maxLevel = 3;
101997
+ if (level >= maxLevel) {
101998
+ return object.toString();
101999
+ }
102000
+ if (typeof object === 'string') {
102001
+ return object;
102002
+ }
102003
+ let returnString = '';
102004
+ let paramsKeys = undefined;
102005
+ if (Array.isArray(object)) {
102006
+ paramsKeys = object;
102007
+ }
102008
+ else {
102009
+ const sorted = this.keysort(object);
102010
+ paramsKeys = Object.keys(sorted);
102011
+ }
102012
+ for (let i = 0; i < paramsKeys.length; i++) {
102013
+ const key = paramsKeys[i];
102014
+ returnString += key;
102015
+ const value = object[key];
102016
+ if (value === 'undefined') {
102017
+ returnString += 'null';
102018
+ }
102019
+ else if (Array.isArray(value)) {
102020
+ for (let j = 0; j < value.length; j++) {
102021
+ returnString += this.paramsToString(value[j], level + 1);
102022
+ }
102023
+ }
102024
+ else {
102025
+ returnString += value.toString();
102026
+ }
102027
+ }
102028
+ return returnString;
102029
+ }
101289
102030
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
101290
102031
  const type = this.safeString(api, 0);
101291
102032
  const access = this.safeString(api, 1);
@@ -101300,20 +102041,8 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
101300
102041
  this.checkRequiredCredentials();
101301
102042
  const nonce = this.nonce().toString();
101302
102043
  const requestParams = this.extend({}, params);
101303
- const keysorted = this.keysort(requestParams);
101304
- const paramsKeys = Object.keys(keysorted);
101305
- let strSortKey = '';
101306
- for (let i = 0; i < paramsKeys.length; i++) {
101307
- const key = paramsKeys[i].toString();
101308
- let value = requestParams[paramsKeys[i]];
101309
- if (Array.isArray(value)) {
101310
- value = value.join(',');
101311
- }
101312
- else {
101313
- value = value.toString();
101314
- }
101315
- strSortKey = strSortKey + key + value;
101316
- }
102044
+ const paramsKeys = Object.keys(requestParams);
102045
+ const strSortKey = this.paramsToString(requestParams, 0);
101317
102046
  const payload = path + nonce + this.apiKey + strSortKey + nonce;
101318
102047
  const signature = this.hmac(this.encode(payload), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
101319
102048
  const paramsKeysLength = paramsKeys.length;
@@ -116276,6 +117005,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
116276
117005
  'cancelOrder': true,
116277
117006
  'createMarketOrder': true,
116278
117007
  'createOrder': true,
117008
+ 'createOrders': true,
116279
117009
  'createPostOnlyOrder': true,
116280
117010
  'createReduceOnlyOrder': true,
116281
117011
  'createStopLimitOrder': true,
@@ -116481,8 +117211,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
116481
117211
  },
116482
117212
  'portfolio': {
116483
117213
  'get': {
116484
- 'spot/currency_pairs': 20 / 15,
116485
- 'spot/currency_pairs/{currency_pair}': 20 / 15,
116486
117214
  'accounts': 20 / 15,
116487
117215
  'account_mode': 20 / 15,
116488
117216
  'borrowable': 20 / 15,
@@ -116490,19 +117218,10 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
116490
117218
  'loans': 20 / 15,
116491
117219
  'loan_records': 20 / 15,
116492
117220
  'interest_records': 20 / 15,
116493
- 'spot/orders': 20 / 15,
116494
- 'spot/orders/{order_id}': 20 / 15,
116495
117221
  },
116496
117222
  'post': {
116497
117223
  'account_mode': 20 / 15,
116498
- 'loans': 200 / 15,
116499
- 'spot/orders': 20 / 15,
116500
- },
116501
- 'delete': {
116502
- 'spot/orders/{order_id}': 20 / 15,
116503
- },
116504
- 'patch': {
116505
- 'spot/orders/{order_id}': 20 / 15,
117224
+ 'loans': 200 / 15, // 15r/10s cost = 20 / 1.5 = 13.33
116506
117225
  },
116507
117226
  },
116508
117227
  'spot': {
@@ -116525,6 +117244,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
116525
117244
  'orders': 0.4,
116526
117245
  'cancel_batch_orders': 20 / 75,
116527
117246
  'countdown_cancel_all': 20 / 75,
117247
+ 'amend_batch_orders': 0.4,
116528
117248
  'price_orders': 0.4,
116529
117249
  },
116530
117250
  'delete': {
@@ -116695,6 +117415,9 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
116695
117415
  'post': {
116696
117416
  'uni/lends': 20 / 15,
116697
117417
  },
117418
+ 'put': {
117419
+ 'uni/interest_reinvest': 20 / 15,
117420
+ },
116698
117421
  'patch': {
116699
117422
  'uni/lends': 20 / 15,
116700
117423
  },
@@ -119859,6 +120582,156 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
119859
120582
  * @returns {object|undefined} [An order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
119860
120583
  */
119861
120584
  await this.loadMarkets();
120585
+ const market = this.market(symbol);
120586
+ const trigger = this.safeValue(params, 'trigger');
120587
+ const triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
120588
+ const stopLossPrice = this.safeValue(params, 'stopLossPrice', triggerPrice);
120589
+ const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
120590
+ const isStopLossOrder = stopLossPrice !== undefined;
120591
+ const isTakeProfitOrder = takeProfitPrice !== undefined;
120592
+ const isStopOrder = isStopLossOrder || isTakeProfitOrder;
120593
+ const nonTriggerOrder = !isStopOrder && (trigger === undefined);
120594
+ const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
120595
+ let response = undefined;
120596
+ if (market['spot'] || market['margin']) {
120597
+ if (nonTriggerOrder) {
120598
+ response = await this.privateSpotPostOrders(orderRequest);
120599
+ }
120600
+ else {
120601
+ response = await this.privateSpotPostPriceOrders(orderRequest);
120602
+ }
120603
+ }
120604
+ else if (market['swap']) {
120605
+ if (nonTriggerOrder) {
120606
+ response = await this.privateFuturesPostSettleOrders(orderRequest);
120607
+ }
120608
+ else {
120609
+ response = await this.privateFuturesPostSettlePriceOrders(orderRequest);
120610
+ }
120611
+ }
120612
+ else if (market['future']) {
120613
+ if (nonTriggerOrder) {
120614
+ response = await this.privateDeliveryPostSettleOrders(orderRequest);
120615
+ }
120616
+ else {
120617
+ response = await this.privateDeliveryPostSettlePriceOrders(orderRequest);
120618
+ }
120619
+ }
120620
+ else {
120621
+ response = await this.privateOptionsPostOrders(orderRequest);
120622
+ }
120623
+ // const response = await this[method] (this.deepExtend (request, params));
120624
+ //
120625
+ // spot
120626
+ //
120627
+ // {
120628
+ // "id": "95282841887",
120629
+ // "text": "apiv4",
120630
+ // "create_time": "1637383156",
120631
+ // "update_time": "1637383156",
120632
+ // "create_time_ms": 1637383156017,
120633
+ // "update_time_ms": 1637383156017,
120634
+ // "status": "open",
120635
+ // "currency_pair": "ETH_USDT",
120636
+ // "type": "limit",
120637
+ // "account": "spot",
120638
+ // "side": "buy",
120639
+ // "amount": "0.01",
120640
+ // "price": "3500",
120641
+ // "time_in_force": "gtc",
120642
+ // "iceberg": "0",
120643
+ // "left": "0.01",
120644
+ // "fill_price": "0",
120645
+ // "filled_total": "0",
120646
+ // "fee": "0",
120647
+ // "fee_currency": "ETH",
120648
+ // "point_fee": "0",
120649
+ // "gt_fee": "0",
120650
+ // "gt_discount": false,
120651
+ // "rebated_fee": "0",
120652
+ // "rebated_fee_currency": "USDT"
120653
+ // }
120654
+ //
120655
+ // spot conditional
120656
+ //
120657
+ // {"id": 5891843}
120658
+ //
120659
+ // futures, perpetual swaps and options
120660
+ //
120661
+ // {
120662
+ // "id": 95938572327,
120663
+ // "contract": "ETH_USDT",
120664
+ // "mkfr": "0",
120665
+ // "tkfr": "0.0005",
120666
+ // "tif": "gtc",
120667
+ // "is_reduce_only": false,
120668
+ // "create_time": 1637384600.08,
120669
+ // "price": "3000",
120670
+ // "size": 1,
120671
+ // "refr": "0",
120672
+ // "left": 1,
120673
+ // "text": "api",
120674
+ // "fill_price": "0",
120675
+ // "user": 2436035,
120676
+ // "status": "open",
120677
+ // "is_liq": false,
120678
+ // "refu": 0,
120679
+ // "is_close": false,
120680
+ // "iceberg": 0
120681
+ // }
120682
+ //
120683
+ // futures and perpetual swaps conditionals
120684
+ //
120685
+ // {"id": 7615567}
120686
+ //
120687
+ return this.parseOrder(response, market);
120688
+ }
120689
+ async createOrders(orders, params = {}) {
120690
+ /**
120691
+ * @method
120692
+ * @name gate#createOrders
120693
+ * @description create a list of trade orders
120694
+ * @see https://www.gate.io/docs/developers/apiv4/en/#get-a-single-order-2
120695
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-batch-of-orders
120696
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
120697
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
120698
+ */
120699
+ await this.loadMarkets();
120700
+ const ordersRequests = [];
120701
+ const orderSymbols = [];
120702
+ for (let i = 0; i < orders.length; i++) {
120703
+ const rawOrder = orders[i];
120704
+ const marketId = this.safeString(rawOrder, 'symbol');
120705
+ orderSymbols.push(marketId);
120706
+ const type = this.safeString(rawOrder, 'type');
120707
+ const side = this.safeString(rawOrder, 'side');
120708
+ const amount = this.safeValue(rawOrder, 'amount');
120709
+ const price = this.safeValue(rawOrder, 'price');
120710
+ const orderParams = this.safeValue(rawOrder, 'params', {});
120711
+ const extendedParams = this.extend(orderParams, params); // the request does not accept extra params since it's a list, so we're extending each order with the common params
120712
+ const triggerValue = this.safeValueN(orderParams, ['triggerPrice', 'stopPrice', 'takeProfitPrice', 'stopLossPrice']);
120713
+ if (triggerValue !== undefined) {
120714
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support advanced order properties (stopPrice, takeProfitPrice, stopLossPrice)');
120715
+ }
120716
+ extendedParams['textIsRequired'] = true; // Gate.io requires a text parameter for each order here
120717
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
120718
+ ordersRequests.push(orderRequest);
120719
+ }
120720
+ const symbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
120721
+ const market = this.market(symbols[0]);
120722
+ if (market['future'] || market['option']) {
120723
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support futures or options markets');
120724
+ }
120725
+ let response = undefined;
120726
+ if (market['spot']) {
120727
+ response = await this.privateSpotPostBatchOrders(ordersRequests);
120728
+ }
120729
+ else if (market['swap']) {
120730
+ response = await this.privateFuturesPostSettleBatchOrders(ordersRequests);
120731
+ }
120732
+ return this.parseOrders(response);
120733
+ }
120734
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
119862
120735
  const market = this.market(symbol);
119863
120736
  const contract = market['contract'];
119864
120737
  const trigger = this.safeValue(params, 'trigger');
@@ -119871,7 +120744,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
119871
120744
  if (isStopLossOrder && isTakeProfitOrder) {
119872
120745
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' createOrder() stopLossPrice and takeProfitPrice cannot both be defined');
119873
120746
  }
119874
- let methodTail = 'Orders';
119875
120747
  const reduceOnly = this.safeValue(params, 'reduceOnly');
119876
120748
  const exchangeSpecificTimeInForce = this.safeStringLowerN(params, ['timeInForce', 'tif', 'time_in_force']);
119877
120749
  let postOnly = undefined;
@@ -119984,6 +120856,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
119984
120856
  }
119985
120857
  }
119986
120858
  let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
120859
+ const textIsRequired = this.safeValue(params, 'textIsRequired', false);
119987
120860
  if (clientOrderId !== undefined) {
119988
120861
  // user-defined, must follow the rules if not empty
119989
120862
  // prefixed with t-
@@ -119992,12 +120865,18 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
119992
120865
  if (clientOrderId.length > 28) {
119993
120866
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder () clientOrderId or text param must be up to 28 characters');
119994
120867
  }
119995
- params = this.omit(params, ['text', 'clientOrderId']);
120868
+ params = this.omit(params, ['text', 'clientOrderId', 'textIsRequired']);
119996
120869
  if (clientOrderId[0] !== 't') {
119997
120870
  clientOrderId = 't-' + clientOrderId;
119998
120871
  }
119999
120872
  request['text'] = clientOrderId;
120000
120873
  }
120874
+ else {
120875
+ if (textIsRequired) {
120876
+ // batchOrders requires text in the request
120877
+ request['text'] = 't-' + this.uuid16();
120878
+ }
120879
+ }
120001
120880
  }
120002
120881
  else {
120003
120882
  if (market['option']) {
@@ -120091,80 +120970,8 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
120091
120970
  };
120092
120971
  }
120093
120972
  }
120094
- methodTail = 'PriceOrders';
120095
120973
  }
120096
- const method = this.getSupportedMapping(market['type'], {
120097
- 'spot': 'privateSpotPost' + methodTail,
120098
- 'margin': 'privateSpotPost' + methodTail,
120099
- 'swap': 'privateFuturesPostSettle' + methodTail,
120100
- 'future': 'privateDeliveryPostSettle' + methodTail,
120101
- 'option': 'privateOptionsPostOrders',
120102
- });
120103
- const response = await this[method](this.deepExtend(request, params));
120104
- //
120105
- // spot
120106
- //
120107
- // {
120108
- // "id": "95282841887",
120109
- // "text": "apiv4",
120110
- // "create_time": "1637383156",
120111
- // "update_time": "1637383156",
120112
- // "create_time_ms": 1637383156017,
120113
- // "update_time_ms": 1637383156017,
120114
- // "status": "open",
120115
- // "currency_pair": "ETH_USDT",
120116
- // "type": "limit",
120117
- // "account": "spot",
120118
- // "side": "buy",
120119
- // "amount": "0.01",
120120
- // "price": "3500",
120121
- // "time_in_force": "gtc",
120122
- // "iceberg": "0",
120123
- // "left": "0.01",
120124
- // "fill_price": "0",
120125
- // "filled_total": "0",
120126
- // "fee": "0",
120127
- // "fee_currency": "ETH",
120128
- // "point_fee": "0",
120129
- // "gt_fee": "0",
120130
- // "gt_discount": false,
120131
- // "rebated_fee": "0",
120132
- // "rebated_fee_currency": "USDT"
120133
- // }
120134
- //
120135
- // spot conditional
120136
- //
120137
- // {"id": 5891843}
120138
- //
120139
- // futures, perpetual swaps and options
120140
- //
120141
- // {
120142
- // "id": 95938572327,
120143
- // "contract": "ETH_USDT",
120144
- // "mkfr": "0",
120145
- // "tkfr": "0.0005",
120146
- // "tif": "gtc",
120147
- // "is_reduce_only": false,
120148
- // "create_time": 1637384600.08,
120149
- // "price": "3000",
120150
- // "size": 1,
120151
- // "refr": "0",
120152
- // "left": 1,
120153
- // "text": "api",
120154
- // "fill_price": "0",
120155
- // "user": 2436035,
120156
- // "status": "open",
120157
- // "is_liq": false,
120158
- // "refu": 0,
120159
- // "is_close": false,
120160
- // "iceberg": 0
120161
- // }
120162
- //
120163
- // futures and perpetual swaps conditionals
120164
- //
120165
- // {"id": 7615567}
120166
- //
120167
- return this.parseOrder(response, market);
120974
+ return this.extend(request, params);
120168
120975
  }
120169
120976
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
120170
120977
  /**
@@ -120390,6 +121197,22 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
120390
121197
  // "order_type": ""
120391
121198
  // }
120392
121199
  //
121200
+ // {
121201
+ // "text": "t-d18baf9ac44d82e2",
121202
+ // "succeeded": false,
121203
+ // "label": "BALANCE_NOT_ENOUGH",
121204
+ // "message": "Not enough balance"
121205
+ // }
121206
+ //
121207
+ const succeeded = this.safeValue(order, 'succeeded', true);
121208
+ if (!succeeded) {
121209
+ // cancelOrders response
121210
+ return this.safeOrder({
121211
+ 'clientOrderId': this.safeString(order, 'text'),
121212
+ 'info': order,
121213
+ 'status': 'rejected',
121214
+ });
121215
+ }
120393
121216
  const put = this.safeValue2(order, 'put', 'initial', {});
120394
121217
  const trigger = this.safeValue(order, 'trigger', {});
120395
121218
  let contract = this.safeString(put, 'contract');
@@ -121829,7 +122652,16 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
121829
122652
  const authentication = api[0]; // public, private
121830
122653
  const type = api[1]; // spot, margin, future, delivery
121831
122654
  let query = this.omit(params, this.extractParams(path));
121832
- path = this.implodeParams(path, params);
122655
+ if (Array.isArray(params)) {
122656
+ // endpoints like createOrders use an array instead of an object
122657
+ // so we infer the settle from one of the elements
122658
+ // they have to be all the same so relying on the first one is fine
122659
+ const first = this.safeValue(params, 0, {});
122660
+ path = this.implodeParams(path, first);
122661
+ }
122662
+ else {
122663
+ path = this.implodeParams(path, params);
122664
+ }
121833
122665
  const endPart = (path === '') ? '' : ('/' + path);
121834
122666
  let entirePath = '/' + type + endPart;
121835
122667
  if ((type === 'subAccounts') || (type === 'withdrawals')) {
@@ -146241,6 +147073,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
146241
147073
  'option': false,
146242
147074
  'cancelAllOrders': true,
146243
147075
  'cancelOrder': true,
147076
+ 'cancelOrders': true,
146244
147077
  'createMarketOrder': false,
146245
147078
  'createOrder': true,
146246
147079
  'editOrder': true,
@@ -147032,24 +147865,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
147032
147865
  'fee': undefined,
147033
147866
  });
147034
147867
  }
147035
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
147036
- /**
147037
- * @method
147038
- * @name krakenfutures#createOrder
147039
- * @description Create an order on the exchange
147040
- * @param {string} symbol market symbol
147041
- * @param {string} type One of 'limit', 'market', 'take_profit'
147042
- * @param {string} side buy or sell
147043
- * @param {int} amount Contract quantity
147044
- * @param {float} [price] Limit order price
147045
- * @param {float} [params.stopPrice] The stop price associated with a stop or take profit order, Required if orderType is stp or take_profit, Must not have more than 2 decimal places, Note that for stop orders, limitPrice denotes the worst price at which the stop or take_profit order can get filled at. If no limitPrice is provided the stop or take_profit order will trigger a market order,
147046
- * @param {bool} [params.reduceOnly] Set as true if you wish the order to only reduce an existing position, Any order which increases an existing position will be rejected, Default false,
147047
- * @param {bool} [params.postOnly] Set as true if you wish to make a postOnly order, Default false
147048
- * @param {string} [params.triggerSignal] If placing a stp or take_profit, the signal used for trigger, One of: 'mark', 'index', 'last', last is market price
147049
- * @param {string} [params.cliOrdId] UUID The order identity that is specified from the user, It must be globally unique
147050
- * @param {string} [params.clientOrderId] UUID The order identity that is specified from the user, It must be globally unique
147051
- */
147052
- await this.loadMarkets();
147868
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
147053
147869
  type = this.safeString(params, 'orderType', type);
147054
147870
  const timeInForce = this.safeString(params, 'timeInForce');
147055
147871
  const stopPrice = this.safeString(params, 'stopPrice');
@@ -147087,7 +147903,28 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
147087
147903
  if (clientOrderId !== undefined) {
147088
147904
  request['cliOrdId'] = clientOrderId;
147089
147905
  }
147090
- const response = await this.privatePostSendorder(this.extend(request, params));
147906
+ return this.extend(request, params);
147907
+ }
147908
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
147909
+ /**
147910
+ * @method
147911
+ * @name krakenfutures#createOrder
147912
+ * @description Create an order on the exchange
147913
+ * @param {string} symbol market symbol
147914
+ * @param {string} type One of 'limit', 'market', 'take_profit'
147915
+ * @param {string} side buy or sell
147916
+ * @param {int} amount Contract quantity
147917
+ * @param {float} [price] Limit order price
147918
+ * @param {float} [params.stopPrice] The stop price associated with a stop or take profit order, Required if orderType is stp or take_profit, Must not have more than 2 decimal places, Note that for stop orders, limitPrice denotes the worst price at which the stop or take_profit order can get filled at. If no limitPrice is provided the stop or take_profit order will trigger a market order,
147919
+ * @param {bool} [params.reduceOnly] Set as true if you wish the order to only reduce an existing position, Any order which increases an existing position will be rejected, Default false,
147920
+ * @param {bool} [params.postOnly] Set as true if you wish to make a postOnly order, Default false
147921
+ * @param {string} [params.triggerSignal] If placing a stp or take_profit, the signal used for trigger, One of: 'mark', 'index', 'last', last is market price
147922
+ * @param {string} [params.cliOrdId] UUID The order identity that is specified from the user, It must be globally unique
147923
+ * @param {string} [params.clientOrderId] UUID The order identity that is specified from the user, It must be globally unique
147924
+ */
147925
+ await this.loadMarkets();
147926
+ const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
147927
+ const response = await this.privatePostSendorder(orderRequest);
147091
147928
  //
147092
147929
  // {
147093
147930
  // "result": "success",
@@ -147123,6 +147960,57 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
147123
147960
  this.verifyOrderActionSuccess(status, 'createOrder', ['filled']);
147124
147961
  return this.parseOrder(sendStatus);
147125
147962
  }
147963
+ async createOrders(orders, params = {}) {
147964
+ /**
147965
+ * @method
147966
+ * @name krakenfutures#createOrders
147967
+ * @description create a list of trade orders
147968
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-batch-order-management
147969
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
147970
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
147971
+ */
147972
+ await this.loadMarkets();
147973
+ const ordersRequests = [];
147974
+ for (let i = 0; i < orders.length; i++) {
147975
+ const rawOrder = orders[i];
147976
+ const marketId = this.safeString(rawOrder, 'symbol');
147977
+ const type = this.safeString(rawOrder, 'type');
147978
+ const side = this.safeString(rawOrder, 'side');
147979
+ const amount = this.safeValue(rawOrder, 'amount');
147980
+ const price = this.safeValue(rawOrder, 'price');
147981
+ const orderParams = this.safeValue(rawOrder, 'params', {});
147982
+ const extendedParams = this.extend(orderParams, params); // the request does not accept extra params since it's a list, so we're extending each order with the common params
147983
+ if (!('order_tag' in extendedParams)) {
147984
+ // order tag is mandatory so we will generate one if not provided
147985
+ extendedParams['order_tag'] = this.sum(i, 1).toString(); // sequential counter
147986
+ }
147987
+ extendedParams['order'] = 'send';
147988
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
147989
+ ordersRequests.push(orderRequest);
147990
+ }
147991
+ const request = {
147992
+ 'batchOrder': ordersRequests,
147993
+ };
147994
+ const response = await this.privatePostBatchorder(this.extend(request, params));
147995
+ //
147996
+ // {
147997
+ // "result": "success",
147998
+ // "serverTime": "2023-10-24T08:40:57.339Z",
147999
+ // "batchStatus": [
148000
+ // {
148001
+ // "status": "requiredArgumentMissing",
148002
+ // "orderEvents": []
148003
+ // },
148004
+ // {
148005
+ // "status": "requiredArgumentMissing",
148006
+ // "orderEvents": []
148007
+ // }
148008
+ // ]
148009
+ // }
148010
+ //
148011
+ const data = this.safeValue(response, 'batchStatus', []);
148012
+ return this.parseOrders(data);
148013
+ }
147126
148014
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
147127
148015
  /**
147128
148016
  * @method
@@ -147171,6 +148059,70 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
147171
148059
  }
147172
148060
  return this.extend({ 'info': response }, order);
147173
148061
  }
148062
+ async cancelOrders(ids, symbol = undefined, params = {}) {
148063
+ /**
148064
+ * @method
148065
+ * @name krakenfutures#cancelOrders
148066
+ * @description cancel multiple orders
148067
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-batch-order-management
148068
+ * @param {[string]} ids order ids
148069
+ * @param {string} [symbol] unified market symbol
148070
+ * @param {object} [params] extra parameters specific to the bingx api endpoint
148071
+ *
148072
+ * EXCHANGE SPECIFIC PARAMETERS
148073
+ * @param {[string]} [params.clientOrderIds] max length 10 e.g. ["my_id_1","my_id_2"]
148074
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
148075
+ */
148076
+ await this.loadMarkets();
148077
+ const orders = [];
148078
+ const clientOrderIds = this.safeValue(params, 'clientOrderIds', []);
148079
+ const clientOrderIdsLength = clientOrderIds.length;
148080
+ if (clientOrderIdsLength > 0) {
148081
+ for (let i = 0; i < clientOrderIds.length; i++) {
148082
+ orders.push({ 'order': 'cancel', 'cliOrdId': clientOrderIds[i] });
148083
+ }
148084
+ }
148085
+ else {
148086
+ for (let i = 0; i < ids.length; i++) {
148087
+ orders.push({ 'order': 'cancel', 'order_id': ids[i] });
148088
+ }
148089
+ }
148090
+ const request = {
148091
+ 'batchOrder': orders,
148092
+ };
148093
+ const response = await this.privatePostBatchorder(this.extend(request, params));
148094
+ // {
148095
+ // result: 'success',
148096
+ // serverTime: '2023-10-23T16:36:51.327Z',
148097
+ // batchStatus: [
148098
+ // {
148099
+ // status: 'cancelled',
148100
+ // order_id: '101c2327-f12e-45f2-8445-7502b87afc0b',
148101
+ // orderEvents: [
148102
+ // {
148103
+ // uid: '101c2327-f12e-45f2-8445-7502b87afc0b',
148104
+ // order: {
148105
+ // orderId: '101c2327-f12e-45f2-8445-7502b87afc0b',
148106
+ // cliOrdId: null,
148107
+ // type: 'lmt',
148108
+ // symbol: 'PF_LTCUSD',
148109
+ // side: 'buy',
148110
+ // quantity: '0.10000000000',
148111
+ // filled: '0E-11',
148112
+ // limitPrice: '50.00000000000',
148113
+ // reduceOnly: false,
148114
+ // timestamp: '2023-10-20T10:29:13.005Z',
148115
+ // lastUpdateTimestamp: '2023-10-20T10:29:13.005Z'
148116
+ // },
148117
+ // type: 'CANCEL'
148118
+ // }
148119
+ // ]
148120
+ // }
148121
+ // ]
148122
+ // }
148123
+ const batchStatus = this.safeValue(response, 'batchStatus', []);
148124
+ return this.parseOrders(batchStatus);
148125
+ }
147174
148126
  async cancelAllOrders(symbol = undefined, params = {}) {
147175
148127
  /**
147176
148128
  * @method
@@ -147445,14 +148397,25 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
147445
148397
  // "lastUpdateTime": "2019-09-05T17:01:17.410Z"
147446
148398
  // }
147447
148399
  //
148400
+ // createOrders error
148401
+ // {
148402
+ // "status": "requiredArgumentMissing",
148403
+ // "orderEvents": []
148404
+ // }
148405
+ //
147448
148406
  const orderEvents = this.safeValue(order, 'orderEvents', []);
148407
+ const errorStatus = this.safeString(order, 'status');
148408
+ const orderEventsLength = orderEvents.length;
148409
+ if (('orderEvents' in order) && (errorStatus !== undefined) && (orderEventsLength === 0)) {
148410
+ // creteOrders error response
148411
+ return this.safeOrder({ 'info': order, 'status': 'rejected' });
148412
+ }
147449
148413
  let details = undefined;
147450
148414
  let isPrior = false;
147451
148415
  let fixed = false;
147452
148416
  let statusId = undefined;
147453
148417
  let price = undefined;
147454
148418
  let trades = [];
147455
- const orderEventsLength = orderEvents.length;
147456
148419
  if (orderEventsLength) {
147457
148420
  const executions = [];
147458
148421
  for (let i = 0; i < orderEvents.length; i++) {
@@ -148357,7 +149320,11 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
148357
149320
  params = this.omit(params, this.extractParams(path));
148358
149321
  let query = endpoint;
148359
149322
  let postData = '';
148360
- if (Object.keys(params).length) {
149323
+ if (path === 'batchorder') {
149324
+ postData = 'json=' + this.json(params);
149325
+ body = postData;
149326
+ }
149327
+ else if (Object.keys(params).length) {
148361
149328
  postData = this.urlencode(params);
148362
149329
  query += '?' + postData;
148363
149330
  }
@@ -148372,7 +149339,8 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
148372
149339
  const secret = this.base64ToBinary(this.secret); // 3
148373
149340
  const signature = this.hmac(hash, secret, _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_5__/* .sha512 */ .o, 'base64'); // 4-5
148374
149341
  headers = {
148375
- 'Content-Type': 'application/json',
149342
+ 'Content-Type': 'application/x-www-form-urlencoded',
149343
+ 'Accept': 'application/json',
148376
149344
  'APIKey': this.apiKey,
148377
149345
  'Authent': signature,
148378
149346
  };
@@ -174962,18 +175930,6 @@ class oceanex extends _abstract_oceanex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
174962
175930
  };
174963
175931
  return this.safeString(statuses, status, status);
174964
175932
  }
174965
- async createOrders(symbol, orders, params = {}) {
174966
- await this.loadMarkets();
174967
- const market = this.market(symbol);
174968
- const request = {
174969
- 'market': market['id'],
174970
- 'orders': orders,
174971
- };
174972
- // orders: [{"side":"buy", "volume":.2, "price":1001}, {"side":"sell", "volume":0.2, "price":1002}]
174973
- const response = await this.privatePostOrdersMulti(this.extend(request, params));
174974
- const data = response['data'];
174975
- return this.parseOrders(data);
174976
- }
174977
175933
  async cancelOrder(id, symbol = undefined, params = {}) {
174978
175934
  /**
174979
175935
  * @method
@@ -178231,6 +179187,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178231
179187
  'cancelOrders': true,
178232
179188
  'createDepositAddress': false,
178233
179189
  'createOrder': true,
179190
+ 'createOrders': true,
178234
179191
  'createPostOnlyOrder': true,
178235
179192
  'createReduceOnlyOrder': true,
178236
179193
  'createStopLimitOrder': true,
@@ -180964,6 +181921,55 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
180964
181921
  order['side'] = side;
180965
181922
  return order;
180966
181923
  }
181924
+ async createOrders(orders, params = {}) {
181925
+ /**
181926
+ * @method
181927
+ * @name okx#createOrders
181928
+ * @description create a list of trade orders
181929
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-multiple-orders
181930
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
181931
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
181932
+ */
181933
+ await this.loadMarkets();
181934
+ const ordersRequests = [];
181935
+ for (let i = 0; i < orders.length; i++) {
181936
+ const rawOrder = orders[i];
181937
+ const marketId = this.safeString(rawOrder, 'symbol');
181938
+ const type = this.safeString(rawOrder, 'type');
181939
+ const side = this.safeString(rawOrder, 'side');
181940
+ const amount = this.safeValue(rawOrder, 'amount');
181941
+ const price = this.safeValue(rawOrder, 'price');
181942
+ const orderParams = this.safeValue(rawOrder, 'params', {});
181943
+ const extendedParams = this.extend(orderParams, params); // the request does not accept extra params since it's a list, so we're extending each order with the common params
181944
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
181945
+ ordersRequests.push(orderRequest);
181946
+ }
181947
+ const response = await this.privatePostTradeBatchOrders(ordersRequests);
181948
+ // {
181949
+ // "code": "0",
181950
+ // "data": [
181951
+ // {
181952
+ // "clOrdId": "e847386590ce4dBCc7f2a1b4c4509f82",
181953
+ // "ordId": "636305438765568000",
181954
+ // "sCode": "0",
181955
+ // "sMsg": "Order placed",
181956
+ // "tag": "e847386590ce4dBC"
181957
+ // },
181958
+ // {
181959
+ // "clOrdId": "e847386590ce4dBC0b9993fe642d8f62",
181960
+ // "ordId": "636305438765568001",
181961
+ // "sCode": "0",
181962
+ // "sMsg": "Order placed",
181963
+ // "tag": "e847386590ce4dBC"
181964
+ // }
181965
+ // ],
181966
+ // "inTime": "1697979038584486",
181967
+ // "msg": "",
181968
+ // "outTime": "1697979038586493"
181969
+ // }
181970
+ const data = this.safeValue(response, 'data', []);
181971
+ return this.parseOrders(data);
181972
+ }
180967
181973
  editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
180968
181974
  const market = this.market(symbol);
180969
181975
  const request = {
@@ -181342,6 +182348,15 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181342
182348
  // "uly": "BTC-USDT"
181343
182349
  // }
181344
182350
  //
182351
+ const scode = this.safeString(order, 'sCode');
182352
+ if ((scode !== undefined) && (scode !== '0')) {
182353
+ return this.safeOrder({
182354
+ 'id': this.safeString(order, 'ordId'),
182355
+ 'clientOrderId': this.safeString(order, 'clOrdId'),
182356
+ 'status': 'rejected',
182357
+ 'info': order,
182358
+ });
182359
+ }
181345
182360
  const id = this.safeString2(order, 'algoId', 'ordId');
181346
182361
  const timestamp = this.safeInteger(order, 'cTime');
181347
182362
  const lastUpdateTimestamp = this.safeInteger(order, 'uTime');
@@ -185084,7 +186099,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
185084
186099
  // }
185085
186100
  //
185086
186101
  const code = this.safeString(response, 'code');
185087
- if (code !== '0') {
186102
+ if ((code !== '0') && (code !== '2')) { // 2 means that bulk operation partially succeeded
185088
186103
  const feedback = this.id + ' ' + body;
185089
186104
  const data = this.safeValue(response, 'data', []);
185090
186105
  for (let i = 0; i < data.length; i++) {
@@ -210535,7 +211550,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
210535
211550
  const topic = this.safeString(message, 'topic', '');
210536
211551
  const updateType = this.safeString(message, 'type', '');
210537
211552
  const data = this.safeValue(message, 'data', {});
210538
- const isSpot = this.safeString(data, 'openInterestValue') === undefined;
211553
+ const isSpot = this.safeString(data, 'fundingRate') === undefined;
210539
211554
  const type = isSpot ? 'spot' : 'contract';
210540
211555
  let symbol = undefined;
210541
211556
  let parsed = undefined;
@@ -248052,18 +249067,19 @@ function twistedEdwards(curveDef) {
248052
249067
  }
248053
249068
  /** Signs message with privateKey. RFC8032 5.1.6 */
248054
249069
  function sign(msg, privKey, context) {
248055
- /*
248056
- msg = ensureBytes('message', msg);
248057
- if (preHash) msg = preHash(msg); // for ed25519ph etc.
249070
+ msg = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('message', msg);
249071
+ if (preHash)
249072
+ msg = preHash(msg); // for ed25519ph etc.
248058
249073
  const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey);
248059
249074
  const r = hashDomainToScalar(context, prefix, msg); // r = dom2(F, C) || prefix || PH(M)
248060
249075
  const R = G.multiply(r).toRawBytes(); // R = rG
248061
249076
  const k = hashDomainToScalar(context, R, pointBytes, msg); // R || A || PH(M)
248062
249077
  const s = modN(r + k * scalar); // S = (r + k * s) mod L
248063
249078
  assertGE0(s); // 0 <= s < l
248064
- const res = ut.concatBytes(R, ut.numberToBytesLE(s, Fp.BYTES));
248065
- return ensureBytes('result', res, nByteLength * 2); // 64-byte signature
248066
- */
249079
+ const res = _utils_js__WEBPACK_IMPORTED_MODULE_1__.concatBytes(R, _utils_js__WEBPACK_IMPORTED_MODULE_1__.numberToBytesLE(s, Fp.BYTES));
249080
+ return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('result', res, nByteLength * 2); // 64-byte signature
249081
+ }
249082
+ function signModified(msg, privKey, context) {
248067
249083
  msg = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('message', msg);
248068
249084
  const privKeyBytes = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('privKey', privKey);
248069
249085
  const privKeyNumber = _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToNumberLE(privKeyBytes);
@@ -248116,6 +249132,7 @@ function twistedEdwards(curveDef) {
248116
249132
  CURVE,
248117
249133
  getPublicKey,
248118
249134
  sign,
249135
+ signModified,
248119
249136
  verify,
248120
249137
  ExtendedPoint: Point,
248121
249138
  utils,
@@ -260466,7 +261483,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
260466
261483
  const messageHex = this.binaryToBase16(this.encode(message));
260467
261484
  const payload = prefix + messageHex;
260468
261485
  const hexKey = this.binaryToBase16(this.base58ToBinary(this.secret));
260469
- const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .eddsa */ .UZ)(payload, hexKey, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
261486
+ const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(payload, hexKey, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
260470
261487
  const request = {
260471
261488
  'grant_type': 'password',
260472
261489
  'scope': 'general',
@@ -261135,7 +262152,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
261135
262152
  if ((serializedOrder[0] === '"') && (serializedOrder[(serializedOrder.length - 1)] === '"')) {
261136
262153
  serializedOrder = serializedOrder.slice(1, serializedOrder.length - 1);
261137
262154
  }
261138
- const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .eddsa */ .UZ)(this.binaryToBase16(this.base58ToBinary(serializedOrder)), this.binaryToBase16(this.base58ToBinary(this.secret)), _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
262155
+ const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(this.base58ToBinary(serializedOrder)), this.binaryToBase16(this.base58ToBinary(this.secret)), _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
261139
262156
  body['signature'] = signature;
261140
262157
  //
261141
262158
  // {
@@ -261250,7 +262267,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
261250
262267
  ];
261251
262268
  const binary = this.binaryConcatArray(byteArray);
261252
262269
  const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
261253
- const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .eddsa */ .UZ)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
262270
+ const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
261254
262271
  const request = {
261255
262272
  'Timestamp': timestamp.toString(),
261256
262273
  'Signature': signature,
@@ -261285,7 +262302,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
261285
262302
  ];
261286
262303
  const binary = this.binaryConcatArray(byteArray);
261287
262304
  const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
261288
- const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .eddsa */ .UZ)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
262305
+ const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
261289
262306
  const request = {
261290
262307
  'Accept': 'application/json',
261291
262308
  'Timestamp': timestamp.toString(),
@@ -261649,7 +262666,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
261649
262666
  ];
261650
262667
  const binary = this.binaryConcatArray(byteArray);
261651
262668
  const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
261652
- const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .eddsa */ .UZ)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
262669
+ const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
261653
262670
  const matcherRequest = {
261654
262671
  'publicKey': this.apiKey,
261655
262672
  'signature': signature,
@@ -262247,7 +263264,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
262247
263264
  ];
262248
263265
  const binary = this.binaryConcatArray(byteArray);
262249
263266
  const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
262250
- const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .eddsa */ .UZ)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
263267
+ const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
262251
263268
  const request = {
262252
263269
  'senderPublicKey': this.apiKey,
262253
263270
  'amount': amountInteger,
@@ -277701,7 +278718,7 @@ SOFTWARE.
277701
278718
 
277702
278719
  //-----------------------------------------------------------------------------
277703
278720
  // this is updated by vss.js when building
277704
- const version = '4.1.23';
278721
+ const version = '4.1.25';
277705
278722
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
277706
278723
  //-----------------------------------------------------------------------------
277707
278724