ccxt 4.1.97 → 4.1.99

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 (46) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +524 -230
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +29 -0
  7. package/dist/cjs/src/binance.js +113 -91
  8. package/dist/cjs/src/bingx.js +58 -9
  9. package/dist/cjs/src/bitget.js +108 -51
  10. package/dist/cjs/src/bitmart.js +71 -17
  11. package/dist/cjs/src/bitvavo.js +52 -14
  12. package/dist/cjs/src/coinex.js +58 -21
  13. package/dist/cjs/src/kraken.js +21 -16
  14. package/dist/cjs/src/phemex.js +3 -3
  15. package/dist/cjs/src/pro/binance.js +1 -1
  16. package/dist/cjs/src/pro/bingx.js +6 -3
  17. package/dist/cjs/src/pro/bitget.js +1 -1
  18. package/dist/cjs/src/pro/bitmart.js +1 -1
  19. package/dist/cjs/src/pro/bybit.js +1 -1
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/binance.d.ts +16 -0
  23. package/js/src/abstract/binancecoinm.d.ts +16 -0
  24. package/js/src/abstract/binanceus.d.ts +16 -0
  25. package/js/src/abstract/binanceusdm.d.ts +16 -0
  26. package/js/src/abstract/coinex.d.ts +14 -1
  27. package/js/src/base/Exchange.d.ts +4 -0
  28. package/js/src/base/Exchange.js +29 -0
  29. package/js/src/binance.js +113 -91
  30. package/js/src/bingx.d.ts +1 -0
  31. package/js/src/bingx.js +58 -9
  32. package/js/src/bitget.js +108 -51
  33. package/js/src/bitmart.js +71 -17
  34. package/js/src/bitvavo.js +52 -14
  35. package/js/src/coinex.js +58 -21
  36. package/js/src/kraken.js +21 -16
  37. package/js/src/phemex.js +3 -3
  38. package/js/src/pro/binance.js +1 -1
  39. package/js/src/pro/bingx.js +6 -3
  40. package/js/src/pro/bitget.js +1 -1
  41. package/js/src/pro/bitmart.js +1 -1
  42. package/js/src/pro/bybit.js +1 -1
  43. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  44. package/package.json +13 -13
  45. package/skip-tests.json +119 -71
  46. package/run-tests-ws.js +0 -290
@@ -7322,7 +7322,9 @@ class Exchange {
7322
7322
  'createOrderWs': undefined,
7323
7323
  'editOrderWs': undefined,
7324
7324
  'fetchOpenOrdersWs': undefined,
7325
+ 'fetchClosedOrdersWs': undefined,
7325
7326
  'fetchOrderWs': undefined,
7327
+ 'fetchOrdersWs': undefined,
7326
7328
  'cancelOrderWs': undefined,
7327
7329
  'cancelOrdersWs': undefined,
7328
7330
  'cancelAllOrdersWs': undefined,
@@ -9238,6 +9240,11 @@ class Exchange {
9238
9240
  if ('rate' in tradeFee) {
9239
9241
  tradeFee['rate'] = this.safeNumber(tradeFee, 'rate');
9240
9242
  }
9243
+ const entryFees = this.safeValue(entry, 'fees', []);
9244
+ for (let j = 0; j < entryFees.length; j++) {
9245
+ entryFees[j]['cost'] = this.safeNumber(entryFees[j], 'cost');
9246
+ }
9247
+ entry['fees'] = entryFees;
9241
9248
  entry['fee'] = tradeFee;
9242
9249
  }
9243
9250
  let timeInForce = this.safeString(order, 'timeInForce');
@@ -10711,6 +10718,9 @@ class Exchange {
10711
10718
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10712
10719
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOrders() is not supported yet');
10713
10720
  }
10721
+ async fetchOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10722
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOrdersWs() is not supported yet');
10723
+ }
10714
10724
  async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
10715
10725
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOrderTrades() is not supported yet');
10716
10726
  }
@@ -10718,14 +10728,33 @@ class Exchange {
10718
10728
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' watchOrders() is not supported yet');
10719
10729
  }
10720
10730
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10731
+ if (this.has['fetchOrders']) {
10732
+ const orders = await this.fetchOrders(symbol, since, limit, params);
10733
+ return this.filterBy(orders, 'status', 'open');
10734
+ }
10721
10735
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOpenOrders() is not supported yet');
10722
10736
  }
10723
10737
  async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10738
+ if (this.has['fetchOrdersWs']) {
10739
+ const orders = await this.fetchOrdersWs(symbol, since, limit, params);
10740
+ return this.filterBy(orders, 'status', 'open');
10741
+ }
10724
10742
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOpenOrdersWs() is not supported yet');
10725
10743
  }
10726
10744
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10745
+ if (this.has['fetchOrders']) {
10746
+ const orders = await this.fetchOrders(symbol, since, limit, params);
10747
+ return this.filterBy(orders, 'status', 'closed');
10748
+ }
10727
10749
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchClosedOrders() is not supported yet');
10728
10750
  }
10751
+ async fetchClosedOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10752
+ if (this.has['fetchOrdersWs']) {
10753
+ const orders = await this.fetchOrdersWs(symbol, since, limit, params);
10754
+ return this.filterBy(orders, 'status', 'closed');
10755
+ }
10756
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchClosedOrdersWs() is not supported yet');
10757
+ }
10729
10758
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10730
10759
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMyTrades() is not supported yet');
10731
10760
  }
@@ -17414,6 +17443,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17414
17443
  'lending/union/interestHistory': 0.1,
17415
17444
  'lending/project/list': 0.1,
17416
17445
  'lending/project/position/list': 0.1,
17446
+ // eth-staking
17447
+ 'eth-staking/eth/history/stakingHistory': 15,
17448
+ 'eth-staking/eth/history/redemptionHistory': 15,
17449
+ 'eth-staking/eth/history/rewardsHistory': 15,
17450
+ 'eth-staking/eth/quota': 15,
17451
+ 'eth-staking/eth/history/rateHistory': 15,
17452
+ 'eth-staking/account': 15,
17453
+ 'eth-staking/wbeth/history/wrapHistory': 15,
17454
+ 'eth-staking/wbeth/history/unwrapHistory': 15,
17455
+ 'eth-staking/eth/history/wbethRewardsHistory': 15,
17417
17456
  // mining endpoints
17418
17457
  'mining/pub/algoList': 0.1,
17419
17458
  'mining/pub/coinList': 0.1,
@@ -17615,6 +17654,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17615
17654
  'staking/purchase': 0.1,
17616
17655
  'staking/redeem': 0.1,
17617
17656
  'staking/setAutoStaking': 0.1,
17657
+ // eth-staking
17658
+ 'eth-staking/eth/stake': 15,
17659
+ 'eth-staking/eth/redeem': 15,
17660
+ 'eth-staking/wbeth/wrap': 15,
17661
+ // mining endpoints
17662
+ 'mining/hash-transfer/config': 0.5,
17663
+ 'mining/hash-transfer/config/cancel': 0.5,
17618
17664
  'portfolio/repay': 20.001,
17619
17665
  'loan/vip/renew': 40.002,
17620
17666
  'loan/vip/borrow': 40.002,
@@ -17668,11 +17714,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17668
17714
  },
17669
17715
  'sapiV2': {
17670
17716
  'get': {
17717
+ 'eth-staking/account': 15,
17671
17718
  'sub-account/futures/account': 0.1,
17672
17719
  'sub-account/futures/accountSummary': 1,
17673
17720
  'sub-account/futures/positionRisk': 0.1,
17674
17721
  },
17675
17722
  'post': {
17723
+ 'eth-staking/eth/stake': 15,
17676
17724
  'sub-account/subAccountApi/ipRestriction': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
17677
17725
  },
17678
17726
  },
@@ -20694,22 +20742,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20694
20742
  // 'endTime': 789, // Timestamp in ms to get aggregate trades until INCLUSIVE.
20695
20743
  // 'limit': 500, // default = 500, maximum = 1000
20696
20744
  };
20697
- let method = this.safeString(this.options, 'fetchTradesMethod');
20698
- method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
20699
- if (method === undefined) {
20700
- if (market['option']) {
20701
- method = 'eapiPublicGetTrades';
20702
- }
20703
- else if (market['linear']) {
20704
- method = 'fapiPublicGetAggTrades';
20705
- }
20706
- else if (market['inverse']) {
20707
- method = 'dapiPublicGetAggTrades';
20708
- }
20709
- else {
20710
- method = 'publicGetAggTrades';
20711
- }
20712
- }
20713
20745
  if (!market['option']) {
20714
20746
  if (since !== undefined) {
20715
20747
  request['startTime'] = since;
@@ -20726,7 +20758,22 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20726
20758
  const isFutureOrSwap = (market['swap'] || market['future']);
20727
20759
  request['limit'] = isFutureOrSwap ? Math.min(limit, 1000) : limit; // default = 500, maximum = 1000
20728
20760
  }
20761
+ let method = this.safeString(this.options, 'fetchTradesMethod');
20762
+ method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
20729
20763
  params = this.omit(params, ['until', 'fetchTradesMethod']);
20764
+ let response = undefined;
20765
+ if (market['option'] || method === 'eapiPublicGetTrades') {
20766
+ response = await this.eapiPublicGetTrades(this.extend(request, params));
20767
+ }
20768
+ else if (market['linear'] || method === 'fapiPublicGetAggTrades') {
20769
+ response = await this.fapiPublicGetAggTrades(this.extend(request, params));
20770
+ }
20771
+ else if (market['inverse'] || method === 'dapiPublicGetAggTrades') {
20772
+ response = await this.dapiPublicGetAggTrades(this.extend(request, params));
20773
+ }
20774
+ else {
20775
+ response = await this.publicGetAggTrades(this.extend(request, params));
20776
+ }
20730
20777
  //
20731
20778
  // Caveats:
20732
20779
  // - default limit (500) applies only if no other parameters set, trades up
@@ -20736,7 +20783,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20736
20783
  // - "tradeId" accepted and returned by this method is "aggregate" trade id
20737
20784
  // which is different from actual trade id
20738
20785
  // - setting both fromId and time window results in error
20739
- const response = await this[method](this.extend(request, params));
20740
20786
  //
20741
20787
  // aggregate trades
20742
20788
  //
@@ -21335,6 +21381,15 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21335
21381
  }
21336
21382
  const stopPriceString = this.safeString(order, 'stopPrice');
21337
21383
  const stopPrice = this.parseNumber(this.omitZero(stopPriceString));
21384
+ const feeCost = this.safeNumber(order, 'fee');
21385
+ let fee = undefined;
21386
+ if (feeCost !== undefined) {
21387
+ fee = {
21388
+ 'currency': this.safeString(order, 'quoteAsset'),
21389
+ 'cost': feeCost,
21390
+ 'rate': undefined,
21391
+ };
21392
+ }
21338
21393
  return this.safeOrder({
21339
21394
  'info': order,
21340
21395
  'id': id,
@@ -21357,11 +21412,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21357
21412
  'filled': filled,
21358
21413
  'remaining': undefined,
21359
21414
  'status': status,
21360
- 'fee': {
21361
- 'currency': this.safeString(order, 'quoteAsset'),
21362
- 'cost': this.safeNumber(order, 'fee'),
21363
- 'rate': undefined,
21364
- },
21415
+ 'fee': fee,
21365
21416
  'trades': fills,
21366
21417
  }, market);
21367
21418
  }
@@ -23150,7 +23201,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23150
23201
  'amount': this.currencyToPrecision(code, amount),
23151
23202
  };
23152
23203
  request['type'] = this.safeString(params, 'type');
23153
- let method = 'sapiPostAssetTransfer';
23204
+ params = this.omit(params, 'type');
23205
+ let response = undefined;
23154
23206
  if (request['type'] === undefined) {
23155
23207
  const symbol = this.safeString(params, 'symbol');
23156
23208
  if (symbol !== undefined) {
@@ -23190,16 +23242,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23190
23242
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' transfer () does not allow transfers between ' + fromAccount + ' and ' + toAccount);
23191
23243
  }
23192
23244
  else if (toSpot && fromIsolated) {
23193
- method = 'sapiPostMarginIsolatedTransfer';
23194
23245
  request['transFrom'] = 'ISOLATED_MARGIN';
23195
23246
  request['transTo'] = 'SPOT';
23196
23247
  request['symbol'] = fromId;
23248
+ response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
23197
23249
  }
23198
23250
  else if (fromSpot && toIsolated) {
23199
- method = 'sapiPostMarginIsolatedTransfer';
23200
23251
  request['transFrom'] = 'SPOT';
23201
23252
  request['transTo'] = 'ISOLATED_MARGIN';
23202
23253
  request['symbol'] = toId;
23254
+ response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
23203
23255
  }
23204
23256
  else {
23205
23257
  if (fromIsolated) {
@@ -23217,8 +23269,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23217
23269
  request['type'] = fromId + '_' + toId;
23218
23270
  }
23219
23271
  }
23220
- params = this.omit(params, 'type');
23221
- const response = await this[method](this.extend(request, params));
23272
+ if (response === undefined) {
23273
+ response = await this.sapiPostAssetTransfer(this.extend(request, params));
23274
+ }
23222
23275
  //
23223
23276
  // {
23224
23277
  // "tranId":13526853623
@@ -24011,7 +24064,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24011
24064
  */
24012
24065
  await this.loadMarkets();
24013
24066
  const request = {};
24014
- let method = undefined;
24015
24067
  let paginate = false;
24016
24068
  [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
24017
24069
  if (paginate) {
@@ -24028,15 +24080,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24028
24080
  let subType = undefined;
24029
24081
  [subType, params] = this.handleSubTypeAndParams('fetchFundingRateHistory', market, params, 'linear');
24030
24082
  params = this.omit(params, 'type');
24031
- if (this.isLinear(type, subType)) {
24032
- method = 'fapiPublicGetFundingRate';
24033
- }
24034
- else if (this.isInverse(type, subType)) {
24035
- method = 'dapiPublicGetFundingRate';
24036
- }
24037
- if (method === undefined) {
24038
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
24039
- }
24040
24083
  if (since !== undefined) {
24041
24084
  request['startTime'] = since;
24042
24085
  }
@@ -24049,7 +24092,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24049
24092
  if (limit !== undefined) {
24050
24093
  request['limit'] = limit;
24051
24094
  }
24052
- const response = await this[method](this.extend(request, params));
24095
+ let response = undefined;
24096
+ if (this.isLinear(type, subType)) {
24097
+ response = await this.fapiPublicGetFundingRate(this.extend(request, params));
24098
+ }
24099
+ else if (this.isInverse(type, subType)) {
24100
+ response = await this.dapiPublicGetFundingRate(this.extend(request, params));
24101
+ }
24102
+ else {
24103
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
24104
+ }
24053
24105
  //
24054
24106
  // {
24055
24107
  // "symbol": "BTCUSDT",
@@ -24085,22 +24137,21 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24085
24137
  */
24086
24138
  await this.loadMarkets();
24087
24139
  symbols = this.marketSymbols(symbols);
24088
- let method = undefined;
24089
24140
  const defaultType = this.safeString2(this.options, 'fetchFundingRates', 'defaultType', 'future');
24090
24141
  const type = this.safeString(params, 'type', defaultType);
24091
24142
  let subType = undefined;
24092
24143
  [subType, params] = this.handleSubTypeAndParams('fetchFundingRates', undefined, params, 'linear');
24093
24144
  const query = this.omit(params, 'type');
24145
+ let response = undefined;
24094
24146
  if (this.isLinear(type, subType)) {
24095
- method = 'fapiPublicGetPremiumIndex';
24147
+ response = await this.fapiPublicGetPremiumIndex(query);
24096
24148
  }
24097
24149
  else if (this.isInverse(type, subType)) {
24098
- method = 'dapiPublicGetPremiumIndex';
24150
+ response = await this.dapiPublicGetPremiumIndex(query);
24099
24151
  }
24100
24152
  else {
24101
24153
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingRates() supports linear and inverse contracts only');
24102
24154
  }
24103
- const response = await this[method](query);
24104
24155
  const result = [];
24105
24156
  for (let i = 0; i < response.length; i++) {
24106
24157
  const entry = response[i];
@@ -24568,22 +24619,21 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24568
24619
  // it contains useful stuff like the maintenance margin and initial margin for positions
24569
24620
  const leverageBrackets = this.safeValue(this.options, 'leverageBrackets');
24570
24621
  if ((leverageBrackets === undefined) || (reload)) {
24571
- let method = undefined;
24572
24622
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
24573
24623
  const type = this.safeString(params, 'type', defaultType);
24574
24624
  const query = this.omit(params, 'type');
24575
24625
  let subType = undefined;
24576
24626
  [subType, params] = this.handleSubTypeAndParams('loadLeverageBrackets', undefined, params, 'linear');
24627
+ let response = undefined;
24577
24628
  if (this.isLinear(type, subType)) {
24578
- method = 'fapiPrivateGetLeverageBracket';
24629
+ response = await this.fapiPrivateGetLeverageBracket(query);
24579
24630
  }
24580
24631
  else if (this.isInverse(type, subType)) {
24581
- method = 'dapiPrivateV2GetLeverageBracket';
24632
+ response = await this.dapiPrivateV2GetLeverageBracket(query);
24582
24633
  }
24583
24634
  else {
24584
24635
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' loadLeverageBrackets() supports linear and inverse contracts only');
24585
24636
  }
24586
- const response = await this[method](query);
24587
24637
  this.options['leverageBrackets'] = {};
24588
24638
  for (let i = 0; i < response.length; i++) {
24589
24639
  const entry = response[i];
@@ -24911,23 +24961,22 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24911
24961
  }
24912
24962
  await this.loadMarkets();
24913
24963
  await this.loadLeverageBrackets(false, params);
24914
- let method = undefined;
24915
24964
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
24916
24965
  const type = this.safeString(params, 'type', defaultType);
24917
24966
  let query = this.omit(params, 'type');
24918
24967
  let subType = undefined;
24919
24968
  [subType, query] = this.handleSubTypeAndParams('fetchAccountPositions', undefined, params, 'linear');
24969
+ let response = undefined;
24920
24970
  if (this.isLinear(type, subType)) {
24921
- method = 'fapiPrivateV2GetAccount';
24971
+ response = await this.fapiPrivateV2GetAccount(query);
24922
24972
  }
24923
24973
  else if (this.isInverse(type, subType)) {
24924
- method = 'dapiPrivateGetAccount';
24974
+ response = await this.dapiPrivateGetAccount(query);
24925
24975
  }
24926
24976
  else {
24927
24977
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
24928
24978
  }
24929
- const account = await this[method](query);
24930
- const result = this.parseAccountPositions(account);
24979
+ const result = this.parseAccountPositions(response);
24931
24980
  symbols = this.marketSymbols(symbols);
24932
24981
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
24933
24982
  }
@@ -24951,15 +25000,15 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24951
25000
  await this.loadMarkets();
24952
25001
  await this.loadLeverageBrackets(false, params);
24953
25002
  const request = {};
24954
- let method = undefined;
24955
25003
  let defaultType = 'future';
24956
25004
  defaultType = this.safeString(this.options, 'defaultType', defaultType);
24957
25005
  const type = this.safeString(params, 'type', defaultType);
24958
25006
  let subType = undefined;
24959
25007
  [subType, params] = this.handleSubTypeAndParams('fetchPositionsRisk', undefined, params, 'linear');
24960
25008
  params = this.omit(params, 'type');
25009
+ let response = undefined;
24961
25010
  if (this.isLinear(type, subType)) {
24962
- method = 'fapiPrivateV2GetPositionRisk';
25011
+ response = await this.fapiPrivateV2GetPositionRisk(this.extend(request, params));
24963
25012
  // ### Response examples ###
24964
25013
  //
24965
25014
  // For One-way position mode:
@@ -25016,12 +25065,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25016
25065
  // ]
25017
25066
  }
25018
25067
  else if (this.isInverse(type, subType)) {
25019
- method = 'dapiPrivateGetPositionRisk';
25068
+ response = await this.dapiPrivateGetPositionRisk(this.extend(request, params));
25020
25069
  }
25021
25070
  else {
25022
25071
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositionsRisk() supports linear and inverse contracts only');
25023
25072
  }
25024
- const response = await this[method](this.extend(request, params));
25025
25073
  const result = [];
25026
25074
  for (let i = 0; i < response.length; i++) {
25027
25075
  const parsed = this.parsePositionRisk(response[i]);
@@ -25045,7 +25093,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25045
25093
  */
25046
25094
  await this.loadMarkets();
25047
25095
  let market = undefined;
25048
- let method = undefined;
25049
25096
  const request = {
25050
25097
  'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION" and "INSURANCE_CLEAR"
25051
25098
  };
@@ -25067,16 +25114,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25067
25114
  const defaultType = this.safeString2(this.options, 'fetchFundingHistory', 'defaultType', 'future');
25068
25115
  const type = this.safeString(params, 'type', defaultType);
25069
25116
  params = this.omit(params, 'type');
25117
+ let response = undefined;
25070
25118
  if (this.isLinear(type, subType)) {
25071
- method = 'fapiPrivateGetIncome';
25119
+ response = await this.fapiPrivateGetIncome(this.extend(request, params));
25072
25120
  }
25073
25121
  else if (this.isInverse(type, subType)) {
25074
- method = 'dapiPrivateGetIncome';
25122
+ response = await this.dapiPrivateGetIncome(this.extend(request, params));
25075
25123
  }
25076
25124
  else {
25077
25125
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingHistory() supports linear and inverse contracts only');
25078
25126
  }
25079
- const response = await this[method](this.extend(request, params));
25080
25127
  return this.parseIncomes(response, market, since, limit);
25081
25128
  }
25082
25129
  async setLeverage(leverage, symbol = undefined, params = {}) {
@@ -25200,6 +25247,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25200
25247
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
25201
25248
  const type = this.safeString(params, 'type', defaultType);
25202
25249
  params = this.omit(params, ['type']);
25250
+ let subType = undefined;
25251
+ [subType, params] = this.handleSubTypeAndParams('setPositionMode', undefined, params);
25203
25252
  let dualSidePosition = undefined;
25204
25253
  if (hedged) {
25205
25254
  dualSidePosition = 'true';
@@ -25210,13 +25259,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25210
25259
  const request = {
25211
25260
  'dualSidePosition': dualSidePosition,
25212
25261
  };
25213
- let method = undefined;
25214
- if (this.isInverse(type)) {
25215
- method = 'dapiPrivatePostPositionSideDual';
25262
+ let response = undefined;
25263
+ if (this.isInverse(type, subType)) {
25264
+ response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
25216
25265
  }
25217
25266
  else {
25218
25267
  // default to future
25219
- method = 'fapiPrivatePostPositionSideDual';
25268
+ response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
25220
25269
  }
25221
25270
  //
25222
25271
  // {
@@ -25224,7 +25273,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25224
25273
  // "msg": "success"
25225
25274
  // }
25226
25275
  //
25227
- return await this[method](this.extend(request, params));
25276
+ return response;
25228
25277
  }
25229
25278
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
25230
25279
  /**
@@ -25436,24 +25485,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25436
25485
  if (code !== undefined) {
25437
25486
  currency = this.currency(code);
25438
25487
  }
25439
- let method = undefined;
25440
25488
  const request = {};
25441
25489
  [type, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
25442
25490
  [subType, params] = this.handleSubTypeAndParams('fetchLedger', undefined, params);
25443
- if (type === 'option') {
25444
- this.checkRequiredArgument('fetchLedger', code, 'code');
25445
- request['currency'] = currency['id'];
25446
- method = 'eapiPrivateGetBill';
25447
- }
25448
- else if (this.isLinear(type, subType)) {
25449
- method = 'fapiPrivateGetIncome';
25450
- }
25451
- else if (this.isInverse(type, subType)) {
25452
- method = 'dapiPrivateGetIncome';
25453
- }
25454
- else {
25455
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLedger() supports contract wallets only');
25456
- }
25457
25491
  if (since !== undefined) {
25458
25492
  request['startTime'] = since;
25459
25493
  }
@@ -25465,7 +25499,21 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25465
25499
  params = this.omit(params, 'until');
25466
25500
  request['endTime'] = until;
25467
25501
  }
25468
- const response = await this[method](this.extend(request, params));
25502
+ let response = undefined;
25503
+ if (type === 'option') {
25504
+ this.checkRequiredArgument('fetchLedger', code, 'code');
25505
+ request['currency'] = currency['id'];
25506
+ response = await this.eapiPrivateGetBill(this.extend(request, params));
25507
+ }
25508
+ else if (this.isLinear(type, subType)) {
25509
+ response = await this.fapiPrivateGetIncome(this.extend(request, params));
25510
+ }
25511
+ else if (this.isInverse(type, subType)) {
25512
+ response = await this.dapiPrivateGetIncome(this.extend(request, params));
25513
+ }
25514
+ else {
25515
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLedger() supports contract wallets only');
25516
+ }
25469
25517
  //
25470
25518
  // options (eapi)
25471
25519
  //
@@ -25830,17 +25878,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25830
25878
  'symbol': market['id'],
25831
25879
  'amount': amount,
25832
25880
  };
25833
- let method = undefined;
25881
+ let response = undefined;
25834
25882
  let code = undefined;
25835
25883
  if (market['linear']) {
25836
- method = 'fapiPrivatePostPositionMargin';
25837
25884
  code = market['quote'];
25885
+ response = await this.fapiPrivatePostPositionMargin(this.extend(request, params));
25838
25886
  }
25839
25887
  else {
25840
- method = 'dapiPrivatePostPositionMargin';
25841
25888
  code = market['base'];
25889
+ response = await this.dapiPrivatePostPositionMargin(this.extend(request, params));
25842
25890
  }
25843
- const response = await this[method](this.extend(request, params));
25844
25891
  //
25845
25892
  // {
25846
25893
  // "code": 200,
@@ -26340,11 +26387,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26340
26387
  const duration = this.parseTimeframe(timeframe);
26341
26388
  request['endTime'] = this.sum(since, duration * limit * 1000);
26342
26389
  }
26343
- let method = 'fapiDataGetOpenInterestHist';
26390
+ let response = undefined;
26344
26391
  if (market['inverse']) {
26345
- method = 'dapiDataGetOpenInterestHist';
26392
+ response = await this.dapiDataGetOpenInterestHist(this.extend(request, params));
26393
+ }
26394
+ else {
26395
+ response = await this.fapiDataGetOpenInterestHist(this.extend(request, params));
26346
26396
  }
26347
- const response = await this[method](this.extend(request, params));
26348
26397
  //
26349
26398
  // [
26350
26399
  // {
@@ -26380,14 +26429,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26380
26429
  else {
26381
26430
  request['symbol'] = market['id'];
26382
26431
  }
26383
- let method = 'fapiPublicGetOpenInterest';
26432
+ let response = undefined;
26384
26433
  if (market['option']) {
26385
- method = 'eapiPublicGetOpenInterest';
26434
+ response = await this.eapiPublicGetOpenInterest(this.extend(request, params));
26386
26435
  }
26387
26436
  else if (market['inverse']) {
26388
- method = 'dapiPublicGetOpenInterest';
26437
+ response = await this.dapiPublicGetOpenInterest(this.extend(request, params));
26438
+ }
26439
+ else {
26440
+ response = await this.fapiPublicGetOpenInterest(this.extend(request, params));
26389
26441
  }
26390
- const response = await this[method](this.extend(request, params));
26391
26442
  //
26392
26443
  // futures (fapi)
26393
26444
  //
@@ -27001,7 +27052,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27001
27052
  'cancelOrder': true,
27002
27053
  'cancelOrders': true,
27003
27054
  'closeAllPositions': true,
27004
- 'closePosition': false,
27055
+ 'closePosition': true,
27005
27056
  'createMarketBuyOrderWithCost': true,
27006
27057
  'createMarketOrderWithCost': true,
27007
27058
  'createMarketSellOrderWithCost': true,
@@ -28668,15 +28719,20 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28668
28719
  else if (timeInForce === 'FOK') {
28669
28720
  request['timeInForce'] = 'FOK';
28670
28721
  }
28671
- if ((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) {
28672
- request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
28673
- }
28674
- const triggerPrice = this.safeNumber2(params, 'stopPrice', 'triggerPrice');
28675
- const stopLossPrice = this.safeNumber(params, 'stopLossPrice');
28676
- const takeProfitPrice = this.safeNumber(params, 'takeProfitPrice');
28722
+ const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
28723
+ const stopLossPrice = this.safeString(params, 'stopLossPrice');
28724
+ const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
28725
+ const trailingAmount = this.safeString(params, 'trailingAmount');
28726
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'priceRate');
28677
28727
  const isTriggerOrder = triggerPrice !== undefined;
28678
28728
  const isStopLossPriceOrder = stopLossPrice !== undefined;
28679
28729
  const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
28730
+ const isTrailingAmountOrder = trailingAmount !== undefined;
28731
+ const isTrailingPercentOrder = trailingPercent !== undefined;
28732
+ const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
28733
+ if (((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) && !isTrailing) {
28734
+ request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
28735
+ }
28680
28736
  let reduceOnly = this.safeValue(params, 'reduceOnly', false);
28681
28737
  if (isTriggerOrder) {
28682
28738
  request['stopPrice'] = this.parseToNumeric(this.priceToPrecision(symbol, triggerPrice));
@@ -28709,6 +28765,16 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28709
28765
  }
28710
28766
  }
28711
28767
  }
28768
+ else if (isTrailing) {
28769
+ request['type'] = 'TRAILING_STOP_MARKET';
28770
+ if (isTrailingAmountOrder) {
28771
+ request['price'] = this.parseToNumeric(trailingAmount);
28772
+ }
28773
+ else if (isTrailingPercentOrder) {
28774
+ const requestTrailingPercent = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
28775
+ request['priceRate'] = this.parseToNumeric(requestTrailingPercent);
28776
+ }
28777
+ }
28712
28778
  let positionSide = undefined;
28713
28779
  if (reduceOnly) {
28714
28780
  positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
@@ -28718,7 +28784,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28718
28784
  }
28719
28785
  request['positionSide'] = positionSide;
28720
28786
  request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
28721
- params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
28787
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent']);
28722
28788
  }
28723
28789
  return this.extend(request, params);
28724
28790
  }
@@ -28741,6 +28807,8 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28741
28807
  * @param {float} [params.stopLossPrice] *swap only* stop loss trigger price
28742
28808
  * @param {float} [params.takeProfitPrice] *swap only* take profit trigger price
28743
28809
  * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
28810
+ * @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
28811
+ * @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
28744
28812
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
28745
28813
  */
28746
28814
  await this.loadMarkets();
@@ -30350,12 +30418,44 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
30350
30418
  'datetime': this.iso8601(timestamp),
30351
30419
  });
30352
30420
  }
30421
+ async closePosition(symbol, side = undefined, params = {}) {
30422
+ /**
30423
+ * @method
30424
+ * @name bingx#closePosition
30425
+ * @description closes open positions for a market
30426
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
30427
+ * @param {string} symbol Unified CCXT market symbol
30428
+ * @param {string} [side] not used by bingx
30429
+ * @param {object} [params] extra parameters specific to the bingx api endpoint
30430
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
30431
+ */
30432
+ await this.loadMarkets();
30433
+ const market = this.market(symbol);
30434
+ const request = {
30435
+ 'symbol': market['id'],
30436
+ };
30437
+ const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
30438
+ //
30439
+ // {
30440
+ // "code": 0,
30441
+ // "msg": "",
30442
+ // "data": {
30443
+ // "success": [
30444
+ // 1727686766700486656,
30445
+ // ],
30446
+ // "failed": null
30447
+ // }
30448
+ // }
30449
+ //
30450
+ const data = this.safeValue(response, 'data');
30451
+ return this.parseOrder(data);
30452
+ }
30353
30453
  async closeAllPositions(params = {}) {
30354
30454
  /**
30355
30455
  * @method
30356
30456
  * @name bitget#closePositions
30357
30457
  * @description closes open positions for a market
30358
- * @see https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
30458
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
30359
30459
  * @param {object} [params] extra parameters specific to the okx api endpoint
30360
30460
  * @param {string} [params.recvWindow] request valid time window value
30361
30461
  * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -41595,12 +41695,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41595
41695
  '30m': '30min',
41596
41696
  '1h': '1h',
41597
41697
  '4h': '4h',
41598
- '6h': '6h',
41599
- '12h': '12h',
41600
- '1d': '1day',
41601
- '3d': '3day',
41602
- '1w': '1week',
41603
- '1M': '1M',
41698
+ '6h': '6Hutc',
41699
+ '12h': '12Hutc',
41700
+ '1d': '1Dutc',
41701
+ '3d': '3Dutc',
41702
+ '1w': '1Wutc',
41703
+ '1M': '1Mutc',
41604
41704
  },
41605
41705
  'swap': {
41606
41706
  '1m': '1m',
@@ -41611,12 +41711,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41611
41711
  '1h': '1H',
41612
41712
  '2h': '2H',
41613
41713
  '4h': '4H',
41614
- '6h': '6H',
41615
- '12h': '12H',
41616
- '1d': '1D',
41617
- '3d': '3D',
41618
- '1w': '1W',
41619
- '1M': '1M',
41714
+ '6h': '6Hutc',
41715
+ '12h': '12Hutc',
41716
+ '1d': '1Dutc',
41717
+ '3d': '3Dutc',
41718
+ '1w': '1Wutc',
41719
+ '1M': '1Mutc',
41620
41720
  },
41621
41721
  },
41622
41722
  'fetchMarkets': [
@@ -43218,7 +43318,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43218
43318
  const currencyCode = this.safeCurrencyCode(this.safeString(feeStructure, 'feeCoin'));
43219
43319
  fee = {
43220
43320
  'currency': currencyCode,
43221
- 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringNeg(this.safeString(feeStructure, 'totalFee')),
43321
+ 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(this.safeString(feeStructure, 'totalFee')),
43222
43322
  };
43223
43323
  }
43224
43324
  return this.safeTrade({
@@ -44317,6 +44417,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44317
44417
  * @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
44318
44418
  * @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
44319
44419
  * @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
44420
+ * @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
44421
+ * @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
44422
+ * @param {string} [params.triggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
44320
44423
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
44321
44424
  */
44322
44425
  await this.loadMarkets();
@@ -44326,6 +44429,8 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44326
44429
  const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
44327
44430
  const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
44328
44431
  const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
44432
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
44433
+ const isTrailingPercentOrder = trailingPercent !== undefined;
44329
44434
  const isTriggerOrder = triggerPrice !== undefined;
44330
44435
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
44331
44436
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
@@ -44347,7 +44452,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44347
44452
  }
44348
44453
  }
44349
44454
  else {
44350
- if (isTriggerOrder) {
44455
+ if (isTriggerOrder || isTrailingPercentOrder) {
44351
44456
  response = await this.privateMixPostV2MixOrderPlacePlanOrder(request);
44352
44457
  }
44353
44458
  else if (isStopLossOrTakeProfitTrigger) {
@@ -44402,8 +44507,11 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44402
44507
  const isTakeProfit = takeProfit !== undefined;
44403
44508
  const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
44404
44509
  const isStopLossOrTakeProfit = isStopLoss || isTakeProfit;
44405
- if (this.sum(isTriggerOrder, isStopLossTriggerOrder, isTakeProfitTriggerOrder) > 1) {
44406
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice');
44510
+ const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', price);
44511
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
44512
+ const isTrailingPercentOrder = trailingPercent !== undefined;
44513
+ if (this.sum(isTriggerOrder, isStopLossTriggerOrder, isTakeProfitTriggerOrder, isTrailingPercentOrder) > 1) {
44514
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent');
44407
44515
  }
44408
44516
  if (type === 'limit') {
44409
44517
  request['price'] = this.priceToPrecision(symbol, price);
@@ -44428,7 +44536,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44428
44536
  else if (timeInForce === 'IOC') {
44429
44537
  request['force'] = 'IOC';
44430
44538
  }
44431
- params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'postOnly', 'reduceOnly', 'clientOrderId']);
44539
+ params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'postOnly', 'reduceOnly', 'clientOrderId', 'trailingPercent', 'trailingTriggerPrice']);
44432
44540
  if ((marketType === 'swap') || (marketType === 'future')) {
44433
44541
  request['marginCoin'] = market['settleId'];
44434
44542
  request['size'] = this.amountToPrecision(symbol, amount);
@@ -44438,34 +44546,21 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44438
44546
  if (clientOrderId !== undefined) {
44439
44547
  request['clientOid'] = clientOrderId;
44440
44548
  }
44441
- if (isTriggerOrder || isStopLossOrTakeProfitTrigger) {
44549
+ if (isTriggerOrder || isStopLossOrTakeProfitTrigger || isTrailingPercentOrder) {
44442
44550
  request['triggerType'] = triggerType;
44443
44551
  }
44444
- if (isStopLossOrTakeProfitTrigger) {
44552
+ if (isTrailingPercentOrder) {
44445
44553
  if (!isMarketOrder) {
44446
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' createOrder() bitget stopLoss or takeProfit orders must be market orders');
44447
- }
44448
- request['holdSide'] = (side === 'buy') ? 'long' : 'short';
44449
- }
44450
- else {
44451
- if (marginMode === undefined) {
44452
- marginMode = 'cross';
44453
- }
44454
- const marginModeRequest = (marginMode === 'cross') ? 'crossed' : 'isolated';
44455
- request['marginMode'] = marginModeRequest;
44456
- let requestSide = side;
44457
- if (reduceOnly) {
44458
- request['reduceOnly'] = 'YES';
44459
- request['tradeSide'] = 'Close';
44460
- // on bitget if the position is long the side is always buy, and if the position is short the side is always sell
44461
- requestSide = (side === 'buy') ? 'sell' : 'buy';
44554
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' createOrder() bitget trailing orders must be market orders');
44462
44555
  }
44463
- else {
44464
- request['tradeSide'] = 'Open';
44556
+ if (trailingTriggerPrice === undefined) {
44557
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder() bitget trailing orders must have a trailingTriggerPrice param');
44465
44558
  }
44466
- request['side'] = requestSide;
44559
+ request['planType'] = 'track_plan';
44560
+ request['triggerPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
44561
+ request['callbackRatio'] = trailingPercent;
44467
44562
  }
44468
- if (isTriggerOrder) {
44563
+ else if (isTriggerOrder) {
44469
44564
  request['planType'] = 'normal_plan';
44470
44565
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
44471
44566
  if (price !== undefined) {
@@ -44489,6 +44584,10 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44489
44584
  }
44490
44585
  }
44491
44586
  else if (isStopLossOrTakeProfitTrigger) {
44587
+ if (!isMarketOrder) {
44588
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' createOrder() bitget stopLoss or takeProfit orders must be market orders');
44589
+ }
44590
+ request['holdSide'] = (side === 'buy') ? 'long' : 'short';
44492
44591
  if (isStopLossTriggerOrder) {
44493
44592
  request['triggerPrice'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
44494
44593
  request['planType'] = 'pos_loss';
@@ -44508,6 +44607,24 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44508
44607
  request['presetStopSurplusPrice'] = this.priceToPrecision(symbol, tpTriggerPrice);
44509
44608
  }
44510
44609
  }
44610
+ if (!isStopLossOrTakeProfitTrigger) {
44611
+ if (marginMode === undefined) {
44612
+ marginMode = 'cross';
44613
+ }
44614
+ const marginModeRequest = (marginMode === 'cross') ? 'crossed' : 'isolated';
44615
+ request['marginMode'] = marginModeRequest;
44616
+ let requestSide = side;
44617
+ if (reduceOnly) {
44618
+ request['reduceOnly'] = 'YES';
44619
+ request['tradeSide'] = 'Close';
44620
+ // on bitget if the position is long the side is always buy, and if the position is short the side is always sell
44621
+ requestSide = (side === 'buy') ? 'sell' : 'buy';
44622
+ }
44623
+ else {
44624
+ request['tradeSide'] = 'Open';
44625
+ }
44626
+ request['side'] = requestSide;
44627
+ }
44511
44628
  }
44512
44629
  else if (marketType === 'spot') {
44513
44630
  if (isStopLossOrTakeProfitTrigger || isStopLossOrTakeProfit) {
@@ -44714,6 +44831,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44714
44831
  * @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
44715
44832
  * @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
44716
44833
  * @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
44834
+ * @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
44835
+ * @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
44836
+ * @param {string} [params.newTriggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
44717
44837
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
44718
44838
  */
44719
44839
  await this.loadMarkets();
@@ -44740,14 +44860,17 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44740
44860
  const takeProfit = this.safeValue(params, 'takeProfit');
44741
44861
  const isStopLoss = stopLoss !== undefined;
44742
44862
  const isTakeProfit = takeProfit !== undefined;
44743
- if (this.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder) > 1) {
44744
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice');
44863
+ const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', price);
44864
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'newCallbackRatio');
44865
+ const isTrailingPercentOrder = trailingPercent !== undefined;
44866
+ if (this.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder, isTrailingPercentOrder) > 1) {
44867
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent');
44745
44868
  }
44746
44869
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
44747
44870
  if (clientOrderId !== undefined) {
44748
44871
  request['clientOid'] = clientOrderId;
44749
44872
  }
44750
- params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId']);
44873
+ params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId', 'trailingTriggerPrice', 'trailingPercent']);
44751
44874
  let response = undefined;
44752
44875
  if (market['spot']) {
44753
44876
  const editMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'editMarketBuyOrderRequiresPrice', true);
@@ -44780,11 +44903,21 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44780
44903
  request['productType'] = productType;
44781
44904
  if (!isTakeProfitOrder && !isStopLossOrder) {
44782
44905
  request['newSize'] = this.amountToPrecision(symbol, amount);
44783
- if (price !== undefined) {
44906
+ if ((price !== undefined) && !isTrailingPercentOrder) {
44784
44907
  request['newPrice'] = this.priceToPrecision(symbol, price);
44785
44908
  }
44786
44909
  }
44787
- if (isTakeProfitOrder || isStopLossOrder) {
44910
+ if (isTrailingPercentOrder) {
44911
+ if (!isMarketOrder) {
44912
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' editOrder() bitget trailing orders must be market orders');
44913
+ }
44914
+ if (trailingTriggerPrice !== undefined) {
44915
+ request['newTriggerPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
44916
+ }
44917
+ request['newCallbackRatio'] = trailingPercent;
44918
+ response = await this.privateMixPostV2MixOrderModifyPlanOrder(this.extend(request, params));
44919
+ }
44920
+ else if (isTakeProfitOrder || isStopLossOrder) {
44788
44921
  request['marginCoin'] = market['settleId'];
44789
44922
  request['size'] = this.amountToPrecision(symbol, amount);
44790
44923
  request['executePrice'] = this.priceToPrecision(symbol, price);
@@ -44863,6 +44996,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44863
44996
  * @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
44864
44997
  * @param {boolean} [params.stop] set to true for canceling trigger orders
44865
44998
  * @param {string} [params.planType] *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
44999
+ * @param {boolean} [params.trailing] set to true if you want to cancel a trailing order
44866
45000
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
44867
45001
  */
44868
45002
  if (symbol === undefined) {
@@ -44882,8 +45016,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44882
45016
  let response = undefined;
44883
45017
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
44884
45018
  const request = {};
44885
- const stop = this.safeValue(params, 'stop');
44886
- params = this.omit(params, 'stop');
45019
+ const trailing = this.safeValue(params, 'trailing');
45020
+ const stop = this.safeValue2(params, 'stop', 'trigger');
45021
+ params = this.omit(params, ['stop', 'trigger', 'trailing']);
44887
45022
  if (!(market['spot'] && stop)) {
44888
45023
  request['symbol'] = market['id'];
44889
45024
  }
@@ -44894,13 +45029,20 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44894
45029
  let productType = undefined;
44895
45030
  [productType, params] = this.handleProductTypeAndParams(market, params);
44896
45031
  request['productType'] = productType;
44897
- if (stop) {
45032
+ if (stop || trailing) {
44898
45033
  const orderIdList = [];
44899
45034
  const orderId = {
44900
45035
  'orderId': id,
44901
45036
  };
44902
45037
  orderIdList.push(orderId);
44903
45038
  request['orderIdList'] = orderIdList;
45039
+ }
45040
+ if (trailing) {
45041
+ const planType = this.safeString(params, 'planType', 'track_plan');
45042
+ request['planType'] = planType;
45043
+ response = await this.privateMixPostV2MixOrderCancelPlanOrder(this.extend(request, params));
45044
+ }
45045
+ else if (stop) {
44904
45046
  response = await this.privateMixPostV2MixOrderCancelPlanOrder(this.extend(request, params));
44905
45047
  }
44906
45048
  else {
@@ -45316,6 +45458,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45316
45458
  * @param {boolean} [params.stop] set to true for fetching trigger orders
45317
45459
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
45318
45460
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45461
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
45319
45462
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45320
45463
  */
45321
45464
  await this.loadMarkets();
@@ -45357,8 +45500,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45357
45500
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
45358
45501
  }
45359
45502
  let response = undefined;
45503
+ const trailing = this.safeValue(params, 'trailing');
45360
45504
  const stop = this.safeValue2(params, 'stop', 'trigger');
45361
- params = this.omit(params, ['stop', 'trigger']);
45505
+ params = this.omit(params, ['stop', 'trigger', 'trailing']);
45362
45506
  [request, params] = this.handleUntilOption('endTime', request, params);
45363
45507
  if (since !== undefined) {
45364
45508
  request['startTime'] = since;
@@ -45401,7 +45545,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45401
45545
  let productType = undefined;
45402
45546
  [productType, query] = this.handleProductTypeAndParams(market, query);
45403
45547
  request['productType'] = productType;
45404
- if (stop) {
45548
+ if (trailing) {
45549
+ const planType = this.safeString(params, 'planType', 'track_plan');
45550
+ request['planType'] = planType;
45551
+ response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
45552
+ }
45553
+ else if (stop) {
45405
45554
  const planType = this.safeString(query, 'planType', 'normal_plan');
45406
45555
  request['planType'] = planType;
45407
45556
  response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
@@ -45617,6 +45766,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45617
45766
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
45618
45767
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45619
45768
  * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
45769
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
45620
45770
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45621
45771
  */
45622
45772
  await this.loadMarkets();
@@ -45654,6 +45804,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45654
45804
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
45655
45805
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45656
45806
  * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
45807
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
45657
45808
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45658
45809
  */
45659
45810
  await this.loadMarkets();
@@ -45706,8 +45857,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45706
45857
  return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
45707
45858
  }
45708
45859
  let response = undefined;
45860
+ const trailing = this.safeValue(params, 'trailing');
45709
45861
  const stop = this.safeValue2(params, 'stop', 'trigger');
45710
- params = this.omit(params, ['stop', 'trigger']);
45862
+ params = this.omit(params, ['stop', 'trigger', 'trailing']);
45711
45863
  [request, params] = this.handleUntilOption('endTime', request, params);
45712
45864
  if (since !== undefined) {
45713
45865
  request['startTime'] = since;
@@ -45761,7 +45913,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45761
45913
  let productType = undefined;
45762
45914
  [productType, params] = this.handleProductTypeAndParams(market, params);
45763
45915
  request['productType'] = productType;
45764
- if (stop) {
45916
+ if (trailing) {
45917
+ const planType = this.safeString(params, 'planType', 'track_plan');
45918
+ request['planType'] = planType;
45919
+ response = await this.privateMixGetV2MixOrderOrdersPlanHistory(this.extend(request, params));
45920
+ }
45921
+ else if (stop) {
45765
45922
  const planType = this.safeString(params, 'planType', 'normal_plan');
45766
45923
  request['planType'] = planType;
45767
45924
  response = await this.privateMixGetV2MixOrderOrdersPlanHistory(this.extend(request, params));
@@ -51749,7 +51906,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51749
51906
  if (priceString === 'market price') {
51750
51907
  priceString = undefined;
51751
51908
  }
51752
- const trailingStopActivationPrice = this.safeNumber(order, 'activation_price');
51909
+ const trailingActivationPrice = this.safeNumber(order, 'activation_price');
51753
51910
  return this.safeOrder({
51754
51911
  'id': id,
51755
51912
  'clientOrderId': this.safeString(order, 'client_order_id'),
@@ -51763,8 +51920,8 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51763
51920
  'postOnly': postOnly,
51764
51921
  'side': this.parseOrderSide(this.safeString(order, 'side')),
51765
51922
  'price': this.omitZero(priceString),
51766
- 'stopPrice': trailingStopActivationPrice,
51767
- 'triggerPrice': trailingStopActivationPrice,
51923
+ 'stopPrice': trailingActivationPrice,
51924
+ 'triggerPrice': trailingActivationPrice,
51768
51925
  'amount': this.omitZero(this.safeString(order, 'size')),
51769
51926
  'cost': this.safeString2(order, 'filled_notional', 'filledNotional'),
51770
51927
  'average': this.safeStringN(order, ['price_avg', 'priceAvg', 'deal_avg_price']),
@@ -51836,6 +51993,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51836
51993
  * @see https://developer-pro.bitmart.com/en/spot/#new-order-v2-signed
51837
51994
  * @see https://developer-pro.bitmart.com/en/spot/#place-margin-order
51838
51995
  * @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
51996
+ * @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
51839
51997
  * @param {string} symbol unified symbol of the market to create an order in
51840
51998
  * @param {string} type 'market', 'limit' or 'trailing' for swap markets only
51841
51999
  * @param {string} side 'buy' or 'sell'
@@ -51847,12 +52005,20 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51847
52005
  * @param {string} [params.clientOrderId] client order id of the order
51848
52006
  * @param {boolean} [params.reduceOnly] *swap only* reduce only
51849
52007
  * @param {boolean} [params.postOnly] make sure the order is posted to the order book and not matched immediately
52008
+ * @param {string} [params.triggerPrice] *swap only* the price to trigger a stop order
52009
+ * @param {int} [params.price_type] *swap only* 1: last price, 2: fair price, default is 1
52010
+ * @param {int} [params.price_way] *swap only* 1: price way long, 2: price way short
52011
+ * @param {int} [params.activation_price_type] *swap trailing order only* 1: last price, 2: fair price, default is 1
52012
+ * @param {string} [params.trailingPercent] *swap only* the percent to trail away from the current market price, min 0.1 max 5
52013
+ * @param {string} [params.trailingTriggerPrice] *swap only* the price to trigger a trailing order, default uses the price argument
51850
52014
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
51851
52015
  */
51852
52016
  await this.loadMarkets();
51853
52017
  const market = this.market(symbol);
51854
52018
  const result = this.handleMarginModeAndParams('createOrder', params);
51855
52019
  const marginMode = this.safeString(result, 0);
52020
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
52021
+ const isTriggerOrder = triggerPrice !== undefined;
51856
52022
  let response = undefined;
51857
52023
  if (market['spot']) {
51858
52024
  const spotRequest = this.createSpotOrderRequest(symbol, type, side, amount, price, params);
@@ -51865,7 +52031,12 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51865
52031
  }
51866
52032
  else {
51867
52033
  const swapRequest = this.createSwapOrderRequest(symbol, type, side, amount, price, params);
51868
- response = await this.privatePostContractPrivateSubmitOrder(swapRequest);
52034
+ if (isTriggerOrder) {
52035
+ response = await this.privatePostContractPrivateSubmitPlanOrder(swapRequest);
52036
+ }
52037
+ else {
52038
+ response = await this.privatePostContractPrivateSubmitOrder(swapRequest);
52039
+ }
51869
52040
  }
51870
52041
  //
51871
52042
  // spot and margin
@@ -51897,6 +52068,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51897
52068
  * @ignore
51898
52069
  * @description create a trade order
51899
52070
  * @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
52071
+ * @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
51900
52072
  * @param {string} symbol unified symbol of the market to create an order in
51901
52073
  * @param {string} type 'market', 'limit' or 'trailing'
51902
52074
  * @param {string} side 'buy' or 'sell'
@@ -51907,8 +52079,12 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51907
52079
  * @param {boolean} [params.reduceOnly] *swap only* reduce only
51908
52080
  * @param {string} [params.marginMode] 'cross' or 'isolated', default is 'cross'
51909
52081
  * @param {string} [params.clientOrderId] client order id of the order
52082
+ * @param {string} [params.triggerPrice] *swap only* the price to trigger a stop order
52083
+ * @param {int} [params.price_type] *swap only* 1: last price, 2: fair price, default is 1
52084
+ * @param {int} [params.price_way] *swap only* 1: price way long, 2: price way short
51910
52085
  * @param {int} [params.activation_price_type] *swap trailing order only* 1: last price, 2: fair price, default is 1
51911
- * @param {string} [params.callback_rate] *swap trailing order only* min 0.1, max 5 where 1 is 1%, default is "1"
52086
+ * @param {string} [params.trailingPercent] *swap only* the percent to trail away from the current market price, min 0.1 max 5
52087
+ * @param {string} [params.trailingTriggerPrice] *swap only* the price to trigger a trailing order, default uses the price argument
51912
52088
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
51913
52089
  */
51914
52090
  const market = this.market(symbol);
@@ -51921,10 +52097,9 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51921
52097
  const mode = this.safeInteger(params, 'mode'); // only for swap
51922
52098
  const isMarketOrder = type === 'market';
51923
52099
  let postOnly = undefined;
51924
- let reduceOnly = this.safeValue(params, 'reduceOnly');
52100
+ const reduceOnly = this.safeValue(params, 'reduceOnly');
51925
52101
  const isExchangeSpecificPo = (mode === 4);
51926
52102
  [postOnly, params] = this.handlePostOnly(isMarketOrder, isExchangeSpecificPo, params);
51927
- params = this.omit(params, ['timeInForce', 'postOnly', 'reduceOnly']);
51928
52103
  const ioc = ((timeInForce === 'IOC') || (mode === 3));
51929
52104
  const isLimitOrder = (type === 'limit') || postOnly || ioc;
51930
52105
  if (timeInForce === 'GTC') {
@@ -51939,14 +52114,39 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51939
52114
  if (postOnly) {
51940
52115
  request['mode'] = 4;
51941
52116
  }
52117
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
52118
+ const isTriggerOrder = triggerPrice !== undefined;
52119
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activation_price', price);
52120
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
52121
+ const isTrailingPercentOrder = trailingPercent !== undefined;
51942
52122
  if (isLimitOrder) {
51943
52123
  request['price'] = this.priceToPrecision(symbol, price);
51944
52124
  }
51945
- else if (type === 'trailing') {
51946
- reduceOnly = true;
51947
- request['activation_price'] = this.priceToPrecision(symbol, price);
52125
+ else if (type === 'trailing' || isTrailingPercentOrder) {
52126
+ request['callback_rate'] = trailingPercent;
52127
+ request['activation_price'] = this.priceToPrecision(symbol, trailingTriggerPrice);
51948
52128
  request['activation_price_type'] = this.safeInteger(params, 'activation_price_type', 1);
51949
- request['callback_rate'] = this.safeString(params, 'callback_rate', '1');
52129
+ }
52130
+ if (isTriggerOrder) {
52131
+ request['executive_price'] = this.priceToPrecision(symbol, price);
52132
+ request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
52133
+ request['price_type'] = this.safeInteger(params, 'price_type', 1);
52134
+ if (side === 'buy') {
52135
+ if (reduceOnly) {
52136
+ request['price_way'] = 2;
52137
+ }
52138
+ else {
52139
+ request['price_way'] = 1;
52140
+ }
52141
+ }
52142
+ else if (side === 'sell') {
52143
+ if (reduceOnly) {
52144
+ request['price_way'] = 1;
52145
+ }
52146
+ else {
52147
+ request['price_way'] = 2;
52148
+ }
52149
+ }
51950
52150
  }
51951
52151
  if (side === 'buy') {
51952
52152
  if (reduceOnly) {
@@ -51973,7 +52173,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
51973
52173
  request['client_order_id'] = clientOrderId;
51974
52174
  }
51975
52175
  const leverage = this.safeInteger(params, 'leverage', 1);
51976
- params = this.omit(params, 'leverage');
52176
+ params = this.omit(params, ['timeInForce', 'postOnly', 'reduceOnly', 'leverage', 'trailingTriggerPrice', 'trailingPercent', 'triggerPrice', 'stopPrice']);
51977
52177
  request['leverage'] = this.numberToString(leverage);
51978
52178
  return this.extend(request, params);
51979
52179
  }
@@ -52055,10 +52255,11 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52055
52255
  /**
52056
52256
  * @method
52057
52257
  * @name bitmart#cancelOrder
52258
+ * @description cancels an open order
52058
52259
  * @see https://developer-pro.bitmart.com/en/futures/#cancel-order-signed
52059
52260
  * @see https://developer-pro.bitmart.com/en/spot/#cancel-order-v3-signed
52060
52261
  * @see https://developer-pro.bitmart.com/en/futures/#cancel-plan-order-signed
52061
- * @description cancels an open order
52262
+ * @see https://developer-pro.bitmart.com/en/futures/#cancel-plan-order-signed
52062
52263
  * @param {string} id order id
52063
52264
  * @param {string} symbol unified symbol of the market the order was made in
52064
52265
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -52268,6 +52469,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52268
52469
  * @param {string} [params.type] *swap* order type, 'limit' or 'market'
52269
52470
  * @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
52270
52471
  * @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
52472
+ * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
52271
52473
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
52272
52474
  */
52273
52475
  await this.loadMarkets();
@@ -52300,8 +52502,12 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52300
52502
  response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
52301
52503
  }
52302
52504
  else if (type === 'swap') {
52303
- const orderType = this.safeString(params, 'orderType');
52304
- params = this.omit(params, 'orderType');
52505
+ const trailing = this.safeValue(params, 'trailing', false);
52506
+ let orderType = this.safeString(params, 'orderType');
52507
+ params = this.omit(params, ['orderType', 'trailing']);
52508
+ if (trailing) {
52509
+ orderType = 'trailing';
52510
+ }
52305
52511
  if (orderType !== undefined) {
52306
52512
  request['type'] = orderType;
52307
52513
  }
@@ -52447,6 +52653,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52447
52653
  * @param {object} [params] extra parameters specific to the exchange API endpoint
52448
52654
  * @param {string} [params.clientOrderId] *spot* fetch the order by client order id instead of order id
52449
52655
  * @param {string} [params.orderType] *swap only* 'limit', 'market', 'liquidate', 'bankruptcy', 'adl' or 'trailing'
52656
+ * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch a trailing order
52450
52657
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
52451
52658
  */
52452
52659
  await this.loadMarkets();
@@ -52474,8 +52681,12 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52474
52681
  if (symbol === undefined) {
52475
52682
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
52476
52683
  }
52477
- const orderType = this.safeString(params, 'orderType');
52478
- params = this.omit(params, 'orderType');
52684
+ const trailing = this.safeValue(params, 'trailing', false);
52685
+ let orderType = this.safeString(params, 'orderType');
52686
+ params = this.omit(params, ['orderType', 'trailing']);
52687
+ if (trailing) {
52688
+ orderType = 'trailing';
52689
+ }
52479
52690
  if (orderType !== undefined) {
52480
52691
  request['type'] = orderType;
52481
52692
  }
@@ -68710,7 +68921,7 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68710
68921
  * @method
68711
68922
  * @name bitvavo#createOrder
68712
68923
  * @description create a trade order
68713
- * @see https://docs.bitvavo.com/#tag/Orders/paths/~1order/post
68924
+ * @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/post
68714
68925
  * @param {string} symbol unified symbol of the market to create an order in
68715
68926
  * @param {string} type 'market' or 'limit'
68716
68927
  * @param {string} side 'buy' or 'sell'
@@ -68728,6 +68939,7 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68728
68939
  * @param {string} [params.selfTradePrevention] "decrementAndCancel", "cancelOldest", "cancelNewest", "cancelBoth"
68729
68940
  * @param {bool} [params.disableMarketProtection] don't cancel if the next fill price is 10% worse than the best fill price
68730
68941
  * @param {bool} [params.responseRequired] Set this to 'false' when only an acknowledgement of success or failure is required, this is faster.
68942
+ * @param {string} [params.clientOrderId] An ID supplied by the client that must be unique among all open orders for the same market
68731
68943
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
68732
68944
  */
68733
68945
  await this.loadMarkets();
@@ -68838,25 +69050,54 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68838
69050
  return this.parseOrder(response, market);
68839
69051
  }
68840
69052
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
69053
+ /**
69054
+ * @method
69055
+ * @name bitvavo#editOrder
69056
+ * @description edit a trade order
69057
+ * @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/put
69058
+ * @param {string} symbol unified symbol of the market to create an order in
69059
+ * @param {string} type 'market' or 'limit'
69060
+ * @param {string} side 'buy' or 'sell'
69061
+ * @param {float} amount how much of currency you want to trade in units of base currency
69062
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
69063
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
69064
+ * @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
69065
+ * @param {bool} [params.postOnly] If true, the order will only be posted to the order book and not executed immediately
69066
+ * @param {float} [params.stopPrice] The price at which a trigger order is triggered at
69067
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
69068
+ * @param {string} [params.selfTradePrevention] "decrementAndCancel", "cancelOldest", "cancelNewest", "cancelBoth"
69069
+ * @param {bool} [params.responseRequired] Set this to 'false' when only an acknowledgement of success or failure is required, this is faster.
69070
+ * @param {string} [params.clientOrderId] An ID supplied by the client
69071
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
69072
+ */
68841
69073
  await this.loadMarkets();
68842
69074
  const market = this.market(symbol);
68843
- let request = {};
69075
+ const request = {
69076
+ 'market': market['id'],
69077
+ };
69078
+ const clientOrderId = this.safeString(params, 'clientOrderId');
69079
+ if (clientOrderId === undefined) {
69080
+ request['orderId'] = id;
69081
+ }
68844
69082
  const amountRemaining = this.safeNumber(params, 'amountRemaining');
68845
- params = this.omit(params, 'amountRemaining');
69083
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'triggerAmount']);
69084
+ params = this.omit(params, ['amountRemaining', 'triggerPrice', 'stopPrice', 'triggerAmount']);
69085
+ let updateRequest = {};
68846
69086
  if (price !== undefined) {
68847
- request['price'] = this.priceToPrecision(symbol, price);
69087
+ updateRequest['price'] = this.priceToPrecision(symbol, price);
68848
69088
  }
68849
69089
  if (amount !== undefined) {
68850
- request['amount'] = this.amountToPrecision(symbol, amount);
69090
+ updateRequest['amount'] = this.amountToPrecision(symbol, amount);
68851
69091
  }
68852
69092
  if (amountRemaining !== undefined) {
68853
- request['amountRemaining'] = this.amountToPrecision(symbol, amountRemaining);
69093
+ updateRequest['amountRemaining'] = this.amountToPrecision(symbol, amountRemaining);
68854
69094
  }
68855
- request = this.extend(request, params);
68856
- if (Object.keys(request).length) {
68857
- request['orderId'] = id;
68858
- request['market'] = market['id'];
68859
- const response = await this.privatePutOrder(this.extend(request, params));
69095
+ if (triggerPrice !== undefined) {
69096
+ updateRequest['triggerAmount'] = this.priceToPrecision(symbol, triggerPrice);
69097
+ }
69098
+ updateRequest = this.extend(updateRequest, params);
69099
+ if (Object.keys(updateRequest).length) {
69100
+ const response = await this.privatePutOrder(this.extend(request, updateRequest));
68860
69101
  return this.parseOrder(response, market);
68861
69102
  }
68862
69103
  else {
@@ -68868,6 +69109,7 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68868
69109
  * @method
68869
69110
  * @name bitvavo#cancelOrder
68870
69111
  * @description cancels an open order
69112
+ * @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/delete
68871
69113
  * @param {string} id order id
68872
69114
  * @param {string} symbol unified symbol of the market the order was made in
68873
69115
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -68879,9 +69121,12 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68879
69121
  await this.loadMarkets();
68880
69122
  const market = this.market(symbol);
68881
69123
  const request = {
68882
- 'orderId': id,
68883
69124
  'market': market['id'],
68884
69125
  };
69126
+ const clientOrderId = this.safeString(params, 'clientOrderId');
69127
+ if (clientOrderId === undefined) {
69128
+ request['orderId'] = id;
69129
+ }
68885
69130
  const response = await this.privateDeleteOrder(this.extend(request, params));
68886
69131
  //
68887
69132
  // {
@@ -68921,6 +69166,7 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68921
69166
  * @method
68922
69167
  * @name bitvavo#fetchOrder
68923
69168
  * @description fetches information on an order made by the user
69169
+ * @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/get
68924
69170
  * @param {string} symbol unified symbol of the market the order was made in
68925
69171
  * @param {object} [params] extra parameters specific to the exchange API endpoint
68926
69172
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -68931,9 +69177,12 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68931
69177
  await this.loadMarkets();
68932
69178
  const market = this.market(symbol);
68933
69179
  const request = {
68934
- 'orderId': id,
68935
69180
  'market': market['id'],
68936
69181
  };
69182
+ const clientOrderId = this.safeString(params, 'clientOrderId');
69183
+ if (clientOrderId === undefined) {
69184
+ request['orderId'] = id;
69185
+ }
68937
69186
  const response = await this.privateGetOrder(this.extend(request, params));
68938
69187
  //
68939
69188
  // {
@@ -68975,7 +69224,7 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68975
69224
  /**
68976
69225
  * @method
68977
69226
  * @name bitvavo#fetchOrders
68978
- * @see https://docs.bitvavo.com/#tag/Orders/paths/~1orders/get
69227
+ * @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1orders/get
68979
69228
  * @description fetches information on multiple orders made by the user
68980
69229
  * @param {string} symbol unified market symbol of the market orders were made in
68981
69230
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -90544,6 +90793,8 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90544
90793
  },
90545
90794
  'put': {
90546
90795
  'balance/deposit/address/{coin_type}': 40,
90796
+ 'sub_account/unfrozen': 40,
90797
+ 'sub_account/frozen': 40,
90547
90798
  'sub_account/auth/api/{user_auth_id}': 40,
90548
90799
  'v1/account/settings': 40,
90549
90800
  },
@@ -90553,7 +90804,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90553
90804
  'order/pending': 13.334,
90554
90805
  'order/stop/pending': 40,
90555
90806
  'order/stop/pending/{id}': 13.334,
90807
+ 'order/pending/by_client_id': 40,
90808
+ 'order/stop/pending/by_client_id': 40,
90556
90809
  'sub_account/auth/api/{user_auth_id}': 40,
90810
+ 'sub_account/authorize/{id}': 40,
90557
90811
  },
90558
90812
  },
90559
90813
  'perpetualPublic': {
@@ -90567,12 +90821,12 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90567
90821
  'market/depth': 1,
90568
90822
  'market/deals': 1,
90569
90823
  'market/funding_history': 1,
90570
- 'market/user_deals': 1,
90571
90824
  'market/kline': 1,
90572
90825
  },
90573
90826
  },
90574
90827
  'perpetualPrivate': {
90575
90828
  'get': {
90829
+ 'market/user_deals': 1,
90576
90830
  'asset/query': 40,
90577
90831
  'order/pending': 8,
90578
90832
  'order/finished': 40,
@@ -90580,8 +90834,13 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90580
90834
  'order/stop_pending': 8,
90581
90835
  'order/status': 8,
90582
90836
  'order/stop_status': 8,
90837
+ 'position/finished': 40,
90583
90838
  'position/pending': 40,
90584
90839
  'position/funding': 40,
90840
+ 'position/adl_history': 40,
90841
+ 'market/preference': 40,
90842
+ 'position/margin_history': 40,
90843
+ 'position/settle_history': 40,
90585
90844
  },
90586
90845
  'post': {
90587
90846
  'market/adjust_leverage': 1,
@@ -90603,6 +90862,9 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90603
90862
  'position/stop_loss': 20,
90604
90863
  'position/take_profit': 20,
90605
90864
  'position/market_close': 20,
90865
+ 'order/cancel/by_client_id': 20,
90866
+ 'order/cancel_stop/by_client_id': 20,
90867
+ 'market/preference': 20,
90606
90868
  },
90607
90869
  },
90608
90870
  },
@@ -91423,9 +91685,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91423
91685
  const priceString = this.safeString(trade, 'price');
91424
91686
  const amountString = this.safeString(trade, 'amount');
91425
91687
  const marketId = this.safeString(trade, 'market');
91426
- const defaultType = this.safeString(this.options, 'defaultType');
91688
+ const marketType = this.safeString(trade, 'market_type');
91689
+ const defaultType = (marketType === undefined) ? 'spot' : 'swap';
91427
91690
  market = this.safeMarket(marketId, market, undefined, defaultType);
91428
- const symbol = this.safeSymbol(marketId, market, undefined, defaultType);
91691
+ const symbol = market['symbol'];
91429
91692
  const costString = this.safeString(trade, 'deal_money');
91430
91693
  let fee = undefined;
91431
91694
  const feeCostString = this.safeString2(trade, 'fee', 'deal_fee');
@@ -92923,11 +93186,17 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92923
93186
  * @description cancels an open order
92924
93187
  * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade018_cancle_stop_pending_order
92925
93188
  * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade015_cancel_order
93189
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade024_cancel_order_by_client_id
93190
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade025_cancel_stop_order_by_client_id
92926
93191
  * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http023_cancel_stop_order
92927
93192
  * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021_cancel_order
93193
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http042_cancel_order_by_client_id
93194
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http043_cancel_stop_order_by_client_id
92928
93195
  * @param {string} id order id
92929
93196
  * @param {string} symbol unified symbol of the market the order was made in
92930
93197
  * @param {object} [params] extra parameters specific to the exchange API endpoint
93198
+ * @param {string} [params.clientOrderId] client order id, defaults to id if not passed
93199
+ * @param {boolean} [params.stop] if stop order = true, default = false
92931
93200
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
92932
93201
  */
92933
93202
  if (symbol === undefined) {
@@ -92940,32 +93209,54 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92940
93209
  const request = {
92941
93210
  'market': market['id'],
92942
93211
  };
92943
- const idRequest = swap ? 'order_id' : 'id';
92944
- request[idRequest] = id;
92945
93212
  const accountId = this.safeInteger(params, 'account_id');
92946
93213
  const defaultType = this.safeString(this.options, 'defaultType');
93214
+ const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
92947
93215
  if (defaultType === 'margin') {
92948
93216
  if (accountId === undefined) {
92949
93217
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' cancelOrder() requires an account_id parameter for margin orders');
92950
93218
  }
92951
93219
  request['account_id'] = accountId;
92952
93220
  }
92953
- const query = this.omit(params, ['stop', 'account_id']);
93221
+ const query = this.omit(params, ['stop', 'account_id', 'clientOrderId']);
92954
93222
  let response = undefined;
92955
- if (stop) {
92956
- if (swap) {
92957
- response = await this.perpetualPrivatePostOrderCancelStop(this.extend(request, query));
93223
+ if (clientOrderId !== undefined) {
93224
+ request['client_id'] = clientOrderId;
93225
+ if (stop) {
93226
+ if (swap) {
93227
+ response = await this.perpetualPrivatePostOrderCancelStopByClientId(this.extend(request, query));
93228
+ }
93229
+ else {
93230
+ response = await this.privateDeleteOrderStopPendingByClientId(this.extend(request, query));
93231
+ }
92958
93232
  }
92959
93233
  else {
92960
- response = await this.privateDeleteOrderStopPendingId(this.extend(request, query));
93234
+ if (swap) {
93235
+ response = await this.perpetualPrivatePostOrderCancelByClientId(this.extend(request, query));
93236
+ }
93237
+ else {
93238
+ response = await this.privateDeleteOrderPendingByClientId(this.extend(request, query));
93239
+ }
92961
93240
  }
92962
93241
  }
92963
93242
  else {
92964
- if (swap) {
92965
- response = await this.perpetualPrivatePostOrderCancel(this.extend(request, query));
93243
+ const idRequest = swap ? 'order_id' : 'id';
93244
+ request[idRequest] = id;
93245
+ if (stop) {
93246
+ if (swap) {
93247
+ response = await this.perpetualPrivatePostOrderCancelStop(this.extend(request, query));
93248
+ }
93249
+ else {
93250
+ response = await this.privateDeleteOrderStopPendingId(this.extend(request, query));
93251
+ }
92966
93252
  }
92967
93253
  else {
92968
- response = await this.privateDeleteOrderPending(this.extend(request, query));
93254
+ if (swap) {
93255
+ response = await this.perpetualPrivatePostOrderCancel(this.extend(request, query));
93256
+ }
93257
+ else {
93258
+ response = await this.privateDeleteOrderPending(this.extend(request, query));
93259
+ }
92969
93260
  }
92970
93261
  }
92971
93262
  //
@@ -93707,16 +93998,11 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93707
93998
  }
93708
93999
  let response = undefined;
93709
94000
  if (swap) {
93710
- const side = this.safeInteger(params, 'side');
93711
- if (side === undefined) {
93712
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a side parameter for swap markets');
93713
- }
93714
94001
  if (since !== undefined) {
93715
94002
  request['start_time'] = since;
93716
94003
  }
93717
- request['side'] = side;
93718
- params = this.omit(params, 'side');
93719
- response = await this.perpetualPublicGetMarketUserDeals(this.extend(request, params));
94004
+ request['side'] = 0;
94005
+ response = await this.perpetualPrivateGetMarketUserDeals(this.extend(request, params));
93720
94006
  }
93721
94007
  else {
93722
94008
  request['page'] = 1;
@@ -95645,7 +95931,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
95645
95931
  }
95646
95932
  }
95647
95933
  }
95648
- if (api === 'perpetualPrivate' || url === 'https://api.coinex.com/perpetual/v1/market/user_deals') {
95934
+ if (api === 'perpetualPrivate') {
95649
95935
  this.checkRequiredCredentials();
95650
95936
  query = this.extend({
95651
95937
  'access_id': this.apiKey,
@@ -151595,7 +151881,9 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151595
151881
  * @param {bool} [params.reduceOnly] *margin only* indicates if this order is to reduce the size of a position
151596
151882
  * @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
151597
151883
  * @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
151598
- * @param {string} [params.trailingStopPrice] *margin only* the quote amount to trail away from the current market price
151884
+ * @param {string} [params.trailingAmount] *margin only* the quote amount to trail away from the current market price
151885
+ * @param {string} [params.trailingLimitAmount] *margin only* the quote amount away from the trailingAmount
151886
+ * @param {string} [params.offset] *margin only* '+' or '-' whether you want the trailingLimitAmount value to be positive or negative, default is negative '-'
151599
151887
  * @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
151600
151888
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
151601
151889
  */
@@ -151856,9 +152144,10 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151856
152144
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
151857
152145
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
151858
152146
  const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
151859
- const trailingStopPrice = this.safeString(params, 'trailingStopPrice');
151860
- const isTrailingStopPriceOrder = trailingStopPrice !== undefined;
151861
- if (type === 'limit') {
152147
+ const trailingAmount = this.safeString(params, 'trailingAmount');
152148
+ const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
152149
+ const isTrailingAmountOrder = trailingAmount !== undefined;
152150
+ if ((type === 'limit') && !isTrailingAmountOrder) {
151862
152151
  request['price'] = this.priceToPrecision(symbol, price);
151863
152152
  }
151864
152153
  let reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
@@ -151874,19 +152163,19 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151874
152163
  request['price2'] = this.priceToPrecision(symbol, price);
151875
152164
  reduceOnly = true;
151876
152165
  }
151877
- else if (isTrailingStopPriceOrder) {
151878
- const trailingStopActivationPriceType = this.safeString(params, 'trigger', 'last');
151879
- const trailingStopPriceString = '+' + trailingStopPrice;
151880
- request['trigger'] = trailingStopActivationPriceType;
151881
- reduceOnly = true;
151882
- if (type === 'limit') {
151883
- const trailingStopLimitPriceString = '+' + this.numberToString(price);
151884
- request['price'] = trailingStopPriceString;
151885
- request['price2'] = trailingStopLimitPriceString;
152166
+ else if (isTrailingAmountOrder) {
152167
+ const trailingActivationPriceType = this.safeString(params, 'trigger', 'last');
152168
+ const trailingAmountString = '+' + trailingAmount;
152169
+ request['trigger'] = trailingActivationPriceType;
152170
+ if ((type === 'limit') || (trailingLimitAmount !== undefined)) {
152171
+ const offset = this.safeString(params, 'offset', '-');
152172
+ const trailingLimitAmountString = offset + this.numberToString(trailingLimitAmount);
152173
+ request['price'] = trailingAmountString;
152174
+ request['price2'] = trailingLimitAmountString;
151886
152175
  request['ordertype'] = 'trailing-stop-limit';
151887
152176
  }
151888
152177
  else {
151889
- request['price'] = trailingStopPriceString;
152178
+ request['price'] = trailingAmountString;
151890
152179
  request['ordertype'] = 'trailing-stop';
151891
152180
  }
151892
152181
  }
@@ -151916,7 +152205,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151916
152205
  if (postOnly) {
151917
152206
  request['oflags'] = 'post';
151918
152207
  }
151919
- params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingStopPrice']);
152208
+ params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingLimitAmount', 'offset']);
151920
152209
  return [request, params];
151921
152210
  }
151922
152211
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
@@ -151934,7 +152223,9 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151934
152223
  * @param {object} [params] extra parameters specific to the exchange API endpoint
151935
152224
  * @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
151936
152225
  * @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
151937
- * @param {string} [params.trailingStopPrice] *margin only* the quote price away from the current market price
152226
+ * @param {string} [params.trailingAmount] *margin only* the quote price away from the current market price
152227
+ * @param {string} [params.trailingLimitAmount] *margin only* the quote amount away from the trailingAmount
152228
+ * @param {string} [params.offset] *margin only* '+' or '-' whether you want the trailingLimitAmount value to be positive or negative, default is negative '-'
151938
152229
  * @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
151939
152230
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
151940
152231
  */
@@ -199251,7 +199542,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
199251
199542
  * @name phemex#setLeverage
199252
199543
  * @description set the level of leverage for a market
199253
199544
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#set-leverage
199254
- * @param {float} leverage the rate of leverage
199545
+ * @param {float} leverage the rate of leverage, 100 > leverage > -100 excluding numbers between -1 to 1
199255
199546
  * @param {string} symbol unified market symbol
199256
199547
  * @param {object} [params] extra parameters specific to the exchange API endpoint
199257
199548
  * @param {bool} [params.hedged] set to true if hedged position mode is enabled (by default long and short leverage are set to the same value)
@@ -199264,8 +199555,8 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
199264
199555
  if (symbol === undefined) {
199265
199556
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
199266
199557
  }
199267
- if ((leverage < 1) || (leverage > 100)) {
199268
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setLeverage() leverage should be between 1 and 100');
199558
+ if ((leverage < -100) || (leverage > 100)) {
199559
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setLeverage() leverage should be between -100 and 100');
199269
199560
  }
199270
199561
  await this.loadMarkets();
199271
199562
  const isHedged = this.safeValue(params, 'hedged', false);
@@ -205595,7 +205886,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
205595
205886
  'watchBalance': true,
205596
205887
  'watchMyTrades': true,
205597
205888
  'watchOHLCV': true,
205598
- 'watchOHLCVForSymbols': true,
205889
+ 'watchOHLCVForSymbols': false,
205599
205890
  'watchOrderBook': true,
205600
205891
  'watchOrderBookForSymbols': true,
205601
205892
  'watchOrders': true,
@@ -208620,7 +208911,8 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208620
208911
  const data = this.safeValue(message, 'data', []);
208621
208912
  const messageHash = this.safeString(message, 'dataType');
208622
208913
  const marketId = messageHash.split('@')[0];
208623
- const marketType = client.url.indexOf('swap') >= 0 ? 'swap' : 'spot';
208914
+ const isSwap = client.url.indexOf('swap') >= 0;
208915
+ const marketType = isSwap ? 'swap' : 'spot';
208624
208916
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
208625
208917
  const symbol = market['symbol'];
208626
208918
  let trades = undefined;
@@ -208735,7 +209027,8 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208735
209027
  const data = this.safeValue(message, 'data', []);
208736
209028
  const messageHash = this.safeString(message, 'dataType');
208737
209029
  const marketId = messageHash.split('@')[0];
208738
- const marketType = client.url.indexOf('swap') >= 0 ? 'swap' : 'spot';
209030
+ const isSwap = client.url.indexOf('swap') >= 0;
209031
+ const marketType = isSwap ? 'swap' : 'spot';
208739
209032
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
208740
209033
  const symbol = market['symbol'];
208741
209034
  let orderbook = this.safeValue(this.orderbooks, symbol);
@@ -208827,7 +209120,8 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208827
209120
  const messageHash = this.safeString(message, 'dataType');
208828
209121
  const timeframeId = messageHash.split('_')[1];
208829
209122
  const marketId = messageHash.split('@')[0];
208830
- const marketType = client.url.indexOf('swap') >= 0 ? 'swap' : 'spot';
209123
+ const isSwap = client.url.indexOf('swap') >= 0;
209124
+ const marketType = isSwap ? 'swap' : 'spot';
208831
209125
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
208832
209126
  const symbol = market['symbol'];
208833
209127
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
@@ -211315,7 +211609,7 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
211315
211609
  'watchBalance': true,
211316
211610
  'watchMyTrades': true,
211317
211611
  'watchOHLCV': true,
211318
- 'watchOHLCVForSymbols': true,
211612
+ 'watchOHLCVForSymbols': false,
211319
211613
  'watchOrderBook': true,
211320
211614
  'watchOrderBookForSymbols': true,
211321
211615
  'watchOrders': true,
@@ -213463,7 +213757,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213463
213757
  const symbolKeys = Object.keys(symbols);
213464
213758
  for (let i = 0; i < symbolKeys.length; i++) {
213465
213759
  const symbol = symbolKeys[i];
213466
- const symbolSpecificMessageHash = messageHash + ':' + symbol;
213760
+ const symbolSpecificMessageHash = messageHash + '::' + symbol;
213467
213761
  client.resolve(newOrders, symbolSpecificMessageHash);
213468
213762
  }
213469
213763
  client.resolve(newOrders, messageHash);
@@ -220310,7 +220604,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
220310
220604
  'watchBalance': true,
220311
220605
  'watchMyTrades': true,
220312
220606
  'watchOHLCV': true,
220313
- 'watchOHLCVForSymbols': true,
220607
+ 'watchOHLCVForSymbols': false,
220314
220608
  'watchOrderBook': true,
220315
220609
  'watchOrderBookForSymbols': true,
220316
220610
  'watchOrders': true,
@@ -288604,7 +288898,7 @@ SOFTWARE.
288604
288898
 
288605
288899
  //-----------------------------------------------------------------------------
288606
288900
  // this is updated by vss.js when building
288607
- const version = '4.1.97';
288901
+ const version = '4.1.99';
288608
288902
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
288609
288903
  //-----------------------------------------------------------------------------
288610
288904