ccxt 4.2.37 → 4.2.39

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 (113) hide show
  1. package/README.md +6 -5
  2. package/dist/ccxt.browser.js +3015 -509
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +4 -1
  5. package/dist/cjs/src/abstract/blofin.js +9 -0
  6. package/dist/cjs/src/base/Exchange.js +14 -2
  7. package/dist/cjs/src/binance.js +156 -35
  8. package/dist/cjs/src/bitget.js +1 -1
  9. package/dist/cjs/src/bitso.js +18 -2
  10. package/dist/cjs/src/bitstamp.js +24 -2
  11. package/dist/cjs/src/bl3p.js +6 -0
  12. package/dist/cjs/src/blockchaincom.js +21 -0
  13. package/dist/cjs/src/blofin.js +2103 -0
  14. package/dist/cjs/src/btcalpha.js +9 -0
  15. package/dist/cjs/src/btcbox.js +9 -0
  16. package/dist/cjs/src/btcmarkets.js +19 -0
  17. package/dist/cjs/src/coinbase.js +13 -2
  18. package/dist/cjs/src/krakenfutures.js +7 -14
  19. package/dist/cjs/src/luno.js +1 -1
  20. package/dist/cjs/src/okx.js +2 -2
  21. package/dist/cjs/src/poloniexfutures.js +11 -5
  22. package/dist/cjs/src/pro/bitmart.js +110 -35
  23. package/dist/cjs/src/pro/kucoin.js +93 -40
  24. package/dist/cjs/src/pro/mexc.js +1 -1
  25. package/dist/cjs/src/wavesexchange.js +1 -1
  26. package/dist/cjs/src/woo.js +1 -1
  27. package/js/ccxt.d.ts +5 -2
  28. package/js/ccxt.js +4 -2
  29. package/js/src/abstract/blofin.d.ts +36 -0
  30. package/js/src/abstract/blofin.js +11 -0
  31. package/js/src/abstract/coinbase.d.ts +1 -0
  32. package/js/src/abstract/okx.d.ts +1 -0
  33. package/js/src/ascendex.d.ts +2 -2
  34. package/js/src/base/Exchange.d.ts +4 -0
  35. package/js/src/base/Exchange.js +14 -2
  36. package/js/src/base/types.d.ts +2 -0
  37. package/js/src/bigone.d.ts +2 -2
  38. package/js/src/binance.d.ts +8 -8
  39. package/js/src/binance.js +156 -35
  40. package/js/src/bingx.d.ts +5 -5
  41. package/js/src/bitfinex.d.ts +3 -3
  42. package/js/src/bitfinex2.d.ts +2 -2
  43. package/js/src/bitget.d.ts +5 -5
  44. package/js/src/bitget.js +1 -1
  45. package/js/src/bitmart.d.ts +2 -2
  46. package/js/src/bitmex.d.ts +2 -2
  47. package/js/src/bitrue.d.ts +2 -2
  48. package/js/src/bitso.d.ts +1 -1
  49. package/js/src/bitso.js +18 -2
  50. package/js/src/bitstamp.d.ts +1 -1
  51. package/js/src/bitstamp.js +24 -2
  52. package/js/src/bitvavo.d.ts +1 -1
  53. package/js/src/bl3p.js +6 -0
  54. package/js/src/blockchaincom.js +21 -0
  55. package/js/src/blofin.d.ts +124 -0
  56. package/js/src/blofin.js +2104 -0
  57. package/js/src/btcalpha.js +9 -0
  58. package/js/src/btcbox.js +9 -0
  59. package/js/src/btcmarkets.js +19 -0
  60. package/js/src/bybit.d.ts +7 -7
  61. package/js/src/cex.d.ts +1 -1
  62. package/js/src/coinbase.d.ts +2 -2
  63. package/js/src/coinbase.js +13 -2
  64. package/js/src/coinex.d.ts +4 -4
  65. package/js/src/coinlist.d.ts +2 -2
  66. package/js/src/coinone.d.ts +1 -1
  67. package/js/src/delta.d.ts +2 -2
  68. package/js/src/deribit.d.ts +3 -3
  69. package/js/src/digifinex.d.ts +3 -3
  70. package/js/src/exmo.d.ts +2 -2
  71. package/js/src/gate.d.ts +6 -6
  72. package/js/src/hitbtc.d.ts +2 -2
  73. package/js/src/hollaex.d.ts +1 -1
  74. package/js/src/htx.d.ts +3 -3
  75. package/js/src/huobijp.d.ts +1 -1
  76. package/js/src/kraken.d.ts +2 -2
  77. package/js/src/krakenfutures.d.ts +2 -2
  78. package/js/src/krakenfutures.js +7 -14
  79. package/js/src/kucoin.d.ts +5 -5
  80. package/js/src/kucoinfutures.d.ts +2 -2
  81. package/js/src/latoken.d.ts +1 -1
  82. package/js/src/lbank.d.ts +2 -2
  83. package/js/src/luno.d.ts +1 -1
  84. package/js/src/luno.js +1 -1
  85. package/js/src/mexc.d.ts +4 -4
  86. package/js/src/ndax.d.ts +1 -1
  87. package/js/src/novadax.d.ts +1 -1
  88. package/js/src/okcoin.d.ts +2 -2
  89. package/js/src/okx.d.ts +7 -7
  90. package/js/src/okx.js +2 -2
  91. package/js/src/paymium.d.ts +2 -2
  92. package/js/src/phemex.d.ts +4 -4
  93. package/js/src/poloniex.d.ts +2 -2
  94. package/js/src/poloniexfutures.d.ts +2 -2
  95. package/js/src/poloniexfutures.js +11 -5
  96. package/js/src/pro/bitmart.d.ts +2 -0
  97. package/js/src/pro/bitmart.js +110 -35
  98. package/js/src/pro/bitvavo.d.ts +1 -1
  99. package/js/src/pro/cex.d.ts +2 -2
  100. package/js/src/pro/coinbase.d.ts +2 -2
  101. package/js/src/pro/coinex.d.ts +1 -1
  102. package/js/src/pro/kucoin.js +93 -40
  103. package/js/src/pro/lbank.d.ts +1 -1
  104. package/js/src/pro/mexc.js +1 -1
  105. package/js/src/probit.d.ts +1 -1
  106. package/js/src/timex.d.ts +1 -1
  107. package/js/src/upbit.d.ts +1 -1
  108. package/js/src/wavesexchange.js +1 -1
  109. package/js/src/whitebit.d.ts +2 -2
  110. package/js/src/woo.d.ts +3 -3
  111. package/js/src/woo.js +1 -1
  112. package/js/src/zonda.d.ts +3 -3
  113. package/package.json +2 -2
package/dist/cjs/ccxt.js CHANGED
@@ -44,6 +44,7 @@ var bitteam = require('./src/bitteam.js');
44
44
  var bitvavo = require('./src/bitvavo.js');
45
45
  var bl3p = require('./src/bl3p.js');
46
46
  var blockchaincom = require('./src/blockchaincom.js');
47
+ var blofin = require('./src/blofin.js');
47
48
  var btcalpha = require('./src/btcalpha.js');
48
49
  var btcbox = require('./src/btcbox.js');
49
50
  var btcmarkets = require('./src/btcmarkets.js');
@@ -176,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
176
177
 
177
178
  //-----------------------------------------------------------------------------
178
179
  // this is updated by vss.js when building
179
- const version = '4.2.37';
180
+ const version = '4.2.39';
180
181
  Exchange["default"].ccxtVersion = version;
181
182
  const exchanges = {
182
183
  'ace': ace,
@@ -211,6 +212,7 @@ const exchanges = {
211
212
  'bitvavo': bitvavo,
212
213
  'bl3p': bl3p,
213
214
  'blockchaincom': blockchaincom,
215
+ 'blofin': blofin,
214
216
  'btcalpha': btcalpha,
215
217
  'btcbox': btcbox,
216
218
  'btcmarkets': btcmarkets,
@@ -416,6 +418,7 @@ exports.bitteam = bitteam;
416
418
  exports.bitvavo = bitvavo;
417
419
  exports.bl3p = bl3p;
418
420
  exports.blockchaincom = blockchaincom;
421
+ exports.blofin = blofin;
419
422
  exports.btcalpha = btcalpha;
420
423
  exports.btcbox = btcbox;
421
424
  exports.btcmarkets = btcmarkets;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var Exchange$1 = require('../base/Exchange.js');
4
+
5
+ // -------------------------------------------------------------------------------
6
+ class Exchange extends Exchange$1["default"] {
7
+ }
8
+
9
+ module.exports = Exchange;
@@ -1936,6 +1936,18 @@ class Exchange {
1936
1936
  async setLeverage(leverage, symbol = undefined, params = {}) {
1937
1937
  throw new errors.NotSupported(this.id + ' setLeverage() is not supported yet');
1938
1938
  }
1939
+ async fetchLeverage(symbol, params = {}) {
1940
+ throw new errors.NotSupported(this.id + ' fetchLeverage() is not supported yet');
1941
+ }
1942
+ async setPositionMode(hedged, symbol = undefined, params = {}) {
1943
+ throw new errors.NotSupported(this.id + ' setPositionMode() is not supported yet');
1944
+ }
1945
+ async setMarginMode(marginMode, symbol = undefined, params = {}) {
1946
+ throw new errors.NotSupported(this.id + ' setMarginMode() is not supported yet');
1947
+ }
1948
+ async fetchDepositAddressesByNetwork(code, params = {}) {
1949
+ throw new errors.NotSupported(this.id + ' fetchDepositAddressesByNetwork() is not supported yet');
1950
+ }
1939
1951
  async fetchOpenInterestHistory(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
1940
1952
  throw new errors.NotSupported(this.id + ' fetchOpenInterestHistory() is not supported yet');
1941
1953
  }
@@ -3162,11 +3174,11 @@ class Exchange {
3162
3174
  * @param {string|undefined} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
3163
3175
  * @returns {string|undefined} unified network code
3164
3176
  */
3165
- const networkCodesByIds = this.safeValue(this.options, 'networksById', {});
3177
+ const networkCodesByIds = this.safeDict(this.options, 'networksById', {});
3166
3178
  let networkCode = this.safeString(networkCodesByIds, networkId, networkId);
3167
3179
  // replace mainnet network-codes (i.e. ERC20->ETH)
3168
3180
  if (currencyCode !== undefined) {
3169
- const defaultNetworkCodeReplacements = this.safeValue(this.options, 'defaultNetworkCodeReplacements', {});
3181
+ const defaultNetworkCodeReplacements = this.safeDict(this.options, 'defaultNetworkCodeReplacements', {});
3170
3182
  if (currencyCode in defaultNetworkCodeReplacements) {
3171
3183
  const replacementObject = this.safeDict(defaultNetworkCodeReplacements, currencyCode, {});
3172
3184
  networkCode = this.safeString(replacementObject, networkCode, networkCode);
@@ -5048,7 +5048,7 @@ class binance extends binance$1 {
5048
5048
  // "msg": "Quantity greater than max quantity."
5049
5049
  // }
5050
5050
  //
5051
- // createOrder, fetchOpenOrders: portfolio margin linear swap and future
5051
+ // createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin linear swap and future
5052
5052
  //
5053
5053
  // {
5054
5054
  // "symbol": "BTCUSDT",
@@ -5071,7 +5071,7 @@ class binance extends binance$1 {
5071
5071
  // "status": "NEW"
5072
5072
  // }
5073
5073
  //
5074
- // createOrder, fetchOpenOrders: portfolio margin inverse swap and future
5074
+ // createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin inverse swap and future
5075
5075
  //
5076
5076
  // {
5077
5077
  // "symbol": "ETHUSD_PERP",
@@ -5137,7 +5137,7 @@ class binance extends binance$1 {
5137
5137
  // "priceProtect": false
5138
5138
  // }
5139
5139
  //
5140
- // createOrder, cancelAllOrders: portfolio margin spot margin
5140
+ // createOrder, cancelAllOrders, cancelOrder: portfolio margin spot margin
5141
5141
  //
5142
5142
  // {
5143
5143
  // "clientOrderId": "x-R4BD3S82e9ef29d8346440f0b28b86",
@@ -5156,7 +5156,7 @@ class binance extends binance$1 {
5156
5156
  // "type": "LIMIT"
5157
5157
  // }
5158
5158
  //
5159
- // fetchOpenOrders: portfolio margin spot margin
5159
+ // fetchOpenOrders, fetchOrder: portfolio margin spot margin
5160
5160
  //
5161
5161
  // {
5162
5162
  // "symbol": "BTCUSDT",
@@ -5181,6 +5181,31 @@ class binance extends binance$1 {
5181
5181
  // "preventedQuantity": null
5182
5182
  // }
5183
5183
  //
5184
+ // cancelOrder: portfolio margin linear and inverse swap conditional
5185
+ //
5186
+ // {
5187
+ // "strategyId": 3733211,
5188
+ // "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
5189
+ // "strategyType": "STOP",
5190
+ // "strategyStatus": "CANCELED",
5191
+ // "origQty": "0.010",
5192
+ // "price": "35000.00",
5193
+ // "reduceOnly": false,
5194
+ // "side": "BUY",
5195
+ // "positionSide": "BOTH",
5196
+ // "stopPrice": "50000.00", // ignored with trailing orders
5197
+ // "symbol": "BTCUSDT",
5198
+ // "timeInForce": "GTC",
5199
+ // "activatePrice": null, // only return with trailing orders
5200
+ // "priceRate": null, // only return with trailing orders
5201
+ // "bookTime": 1707270098774,
5202
+ // "updateTime": 1707270119261,
5203
+ // "workingType": "CONTRACT_PRICE",
5204
+ // "priceProtect": false,
5205
+ // "goodTillDate": 0,
5206
+ // "selfTradePreventionMode": "NONE"
5207
+ // }
5208
+ //
5184
5209
  const code = this.safeString(order, 'code');
5185
5210
  if (code !== undefined) {
5186
5211
  // cancelOrders/createOrders might have a partial success
@@ -5791,9 +5816,14 @@ class binance extends binance$1 {
5791
5816
  * @see https://binance-docs.github.io/apidocs/delivery/en/#query-order-user_data
5792
5817
  * @see https://binance-docs.github.io/apidocs/voptions/en/#query-single-order-trade
5793
5818
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-order-user_data
5819
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-um-order-user_data
5820
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-cm-order-user_data
5821
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-margin-account-order-user_data
5822
+ * @param {string} id the order id
5794
5823
  * @param {string} symbol unified symbol of the market the order was made in
5795
5824
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5796
5825
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
5826
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch an order in a portfolio margin account
5797
5827
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5798
5828
  */
5799
5829
  if (symbol === undefined) {
@@ -5803,11 +5833,14 @@ class binance extends binance$1 {
5803
5833
  const market = this.market(symbol);
5804
5834
  const defaultType = this.safeString2(this.options, 'fetchOrder', 'defaultType', 'spot');
5805
5835
  const type = this.safeString(params, 'type', defaultType);
5806
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOrder', params);
5836
+ let marginMode = undefined;
5837
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrder', params);
5838
+ let isPortfolioMargin = undefined;
5839
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOrder', 'papi', 'portfolioMargin', false);
5807
5840
  const request = {
5808
5841
  'symbol': market['id'],
5809
5842
  };
5810
- const clientOrderId = this.safeValue2(params, 'origClientOrderId', 'clientOrderId');
5843
+ const clientOrderId = this.safeString2(params, 'origClientOrderId', 'clientOrderId');
5811
5844
  if (clientOrderId !== undefined) {
5812
5845
  if (market['option']) {
5813
5846
  request['clientOrderId'] = clientOrderId;
@@ -5819,25 +5852,40 @@ class binance extends binance$1 {
5819
5852
  else {
5820
5853
  request['orderId'] = id;
5821
5854
  }
5822
- const requestParams = this.omit(query, ['type', 'clientOrderId', 'origClientOrderId']);
5855
+ params = this.omit(params, ['type', 'clientOrderId', 'origClientOrderId']);
5823
5856
  let response = undefined;
5824
5857
  if (market['option']) {
5825
- response = await this.eapiPrivateGetOrder(this.extend(request, requestParams));
5858
+ response = await this.eapiPrivateGetOrder(this.extend(request, params));
5826
5859
  }
5827
5860
  else if (market['linear']) {
5828
- response = await this.fapiPrivateGetOrder(this.extend(request, requestParams));
5861
+ if (isPortfolioMargin) {
5862
+ response = await this.papiGetUmOrder(this.extend(request, params));
5863
+ }
5864
+ else {
5865
+ response = await this.fapiPrivateGetOrder(this.extend(request, params));
5866
+ }
5829
5867
  }
5830
5868
  else if (market['inverse']) {
5831
- response = await this.dapiPrivateGetOrder(this.extend(request, requestParams));
5869
+ if (isPortfolioMargin) {
5870
+ response = await this.papiGetCmOrder(this.extend(request, params));
5871
+ }
5872
+ else {
5873
+ response = await this.dapiPrivateGetOrder(this.extend(request, params));
5874
+ }
5832
5875
  }
5833
- else if (type === 'margin' || marginMode !== undefined) {
5834
- if (marginMode === 'isolated') {
5835
- request['isIsolated'] = true;
5876
+ else if ((type === 'margin') || (marginMode !== undefined) || isPortfolioMargin) {
5877
+ if (isPortfolioMargin) {
5878
+ response = await this.papiGetMarginOrder(this.extend(request, params));
5879
+ }
5880
+ else {
5881
+ if (marginMode === 'isolated') {
5882
+ request['isIsolated'] = true;
5883
+ }
5884
+ response = await this.sapiGetMarginOrder(this.extend(request, params));
5836
5885
  }
5837
- response = await this.sapiGetMarginOrder(this.extend(request, requestParams));
5838
5886
  }
5839
5887
  else {
5840
- response = await this.privateGetOrder(this.extend(request, requestParams));
5888
+ response = await this.privateGetOrder(this.extend(request, params));
5841
5889
  }
5842
5890
  return this.parseOrder(response, market);
5843
5891
  }
@@ -6152,9 +6200,16 @@ class binance extends binance$1 {
6152
6200
  * @see https://binance-docs.github.io/apidocs/delivery/en/#cancel-order-trade
6153
6201
  * @see https://binance-docs.github.io/apidocs/voptions/en/#cancel-option-order-trade
6154
6202
  * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-cancel-order-trade
6203
+ * @see https://binance-docs.github.io/apidocs/pm/en/#cancel-um-order-trade
6204
+ * @see https://binance-docs.github.io/apidocs/pm/en/#cancel-cm-order-trade
6205
+ * @see https://binance-docs.github.io/apidocs/pm/en/#cancel-um-conditional-order-trade
6206
+ * @see https://binance-docs.github.io/apidocs/pm/en/#cancel-cm-conditional-order-trade
6207
+ * @see https://binance-docs.github.io/apidocs/pm/en/#cancel-margin-account-order-trade
6155
6208
  * @param {string} id order id
6156
6209
  * @param {string} symbol unified symbol of the market the order was made in
6157
6210
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6211
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to cancel an order in a portfolio margin account
6212
+ * @param {boolean} [params.stop] set to true if you would like to cancel a portfolio margin account conditional order
6158
6213
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
6159
6214
  */
6160
6215
  if (symbol === undefined) {
@@ -6164,43 +6219,80 @@ class binance extends binance$1 {
6164
6219
  const market = this.market(symbol);
6165
6220
  const defaultType = this.safeString2(this.options, 'cancelOrder', 'defaultType', 'spot');
6166
6221
  const type = this.safeString(params, 'type', defaultType);
6167
- const [marginMode, query] = this.handleMarginModeAndParams('cancelOrder', params);
6222
+ let marginMode = undefined;
6223
+ [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
6224
+ let isPortfolioMargin = undefined;
6225
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'cancelOrder', 'papi', 'portfolioMargin', false);
6226
+ const isConditional = this.safeBool2(params, 'stop', 'conditional');
6168
6227
  const request = {
6169
6228
  'symbol': market['id'],
6170
- // 'orderId': id,
6171
- // 'origClientOrderId': id,
6172
6229
  };
6173
- const clientOrderId = this.safeValue2(params, 'origClientOrderId', 'clientOrderId');
6230
+ const clientOrderId = this.safeStringN(params, ['origClientOrderId', 'clientOrderId', 'newClientStrategyId']);
6174
6231
  if (clientOrderId !== undefined) {
6175
6232
  if (market['option']) {
6176
6233
  request['clientOrderId'] = clientOrderId;
6177
6234
  }
6178
6235
  else {
6179
- request['origClientOrderId'] = clientOrderId;
6236
+ if (isPortfolioMargin && isConditional) {
6237
+ request['newClientStrategyId'] = clientOrderId;
6238
+ }
6239
+ else {
6240
+ request['origClientOrderId'] = clientOrderId;
6241
+ }
6180
6242
  }
6181
6243
  }
6182
6244
  else {
6183
- request['orderId'] = id;
6245
+ if (isPortfolioMargin && isConditional) {
6246
+ request['strategyId'] = id;
6247
+ }
6248
+ else {
6249
+ request['orderId'] = id;
6250
+ }
6184
6251
  }
6185
- const requestParams = this.omit(query, ['type', 'origClientOrderId', 'clientOrderId']);
6252
+ params = this.omit(params, ['type', 'origClientOrderId', 'clientOrderId', 'newClientStrategyId', 'stop', 'conditional']);
6186
6253
  let response = undefined;
6187
6254
  if (market['option']) {
6188
- response = await this.eapiPrivateDeleteOrder(this.extend(request, requestParams));
6255
+ response = await this.eapiPrivateDeleteOrder(this.extend(request, params));
6189
6256
  }
6190
6257
  else if (market['linear']) {
6191
- response = await this.fapiPrivateDeleteOrder(this.extend(request, requestParams));
6258
+ if (isPortfolioMargin) {
6259
+ if (isConditional) {
6260
+ response = await this.papiDeleteUmConditionalOrder(this.extend(request, params));
6261
+ }
6262
+ else {
6263
+ response = await this.papiDeleteUmOrder(this.extend(request, params));
6264
+ }
6265
+ }
6266
+ else {
6267
+ response = await this.fapiPrivateDeleteOrder(this.extend(request, params));
6268
+ }
6192
6269
  }
6193
6270
  else if (market['inverse']) {
6194
- response = await this.dapiPrivateDeleteOrder(this.extend(request, requestParams));
6271
+ if (isPortfolioMargin) {
6272
+ if (isConditional) {
6273
+ response = await this.papiDeleteCmConditionalOrder(this.extend(request, params));
6274
+ }
6275
+ else {
6276
+ response = await this.papiDeleteCmOrder(this.extend(request, params));
6277
+ }
6278
+ }
6279
+ else {
6280
+ response = await this.dapiPrivateDeleteOrder(this.extend(request, params));
6281
+ }
6195
6282
  }
6196
- else if (type === 'margin' || marginMode !== undefined) {
6197
- if (marginMode === 'isolated') {
6198
- request['isIsolated'] = true;
6283
+ else if ((type === 'margin') || (marginMode !== undefined) || isPortfolioMargin) {
6284
+ if (isPortfolioMargin) {
6285
+ response = await this.papiDeleteMarginOrder(this.extend(request, params));
6286
+ }
6287
+ else {
6288
+ if (marginMode === 'isolated') {
6289
+ request['isIsolated'] = true;
6290
+ }
6291
+ response = await this.sapiDeleteMarginOrder(this.extend(request, params));
6199
6292
  }
6200
- response = await this.sapiDeleteMarginOrder(this.extend(request, requestParams));
6201
6293
  }
6202
6294
  else {
6203
- response = await this.privateDeleteOrder(this.extend(request, requestParams));
6295
+ response = await this.privateDeleteOrder(this.extend(request, params));
6204
6296
  }
6205
6297
  return this.parseOrder(response, market);
6206
6298
  }
@@ -9160,9 +9252,12 @@ class binance extends binance$1 {
9160
9252
  * @description set the level of leverage for a market
9161
9253
  * @see https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade
9162
9254
  * @see https://binance-docs.github.io/apidocs/delivery/en/#change-initial-leverage-trade
9255
+ * @see https://binance-docs.github.io/apidocs/pm/en/#change-um-initial-leverage-trade
9256
+ * @see https://binance-docs.github.io/apidocs/pm/en/#change-cm-initial-leverage-trade
9163
9257
  * @param {float} leverage the rate of leverage
9164
9258
  * @param {string} symbol unified market symbol
9165
9259
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9260
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to set the leverage for a trading pair in a portfolio margin account
9166
9261
  * @returns {object} response from the exchange
9167
9262
  */
9168
9263
  if (symbol === undefined) {
@@ -9179,12 +9274,24 @@ class binance extends binance$1 {
9179
9274
  'symbol': market['id'],
9180
9275
  'leverage': leverage,
9181
9276
  };
9277
+ let isPortfolioMargin = undefined;
9278
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'setLeverage', 'papi', 'portfolioMargin', false);
9182
9279
  let response = undefined;
9183
9280
  if (market['linear']) {
9184
- response = await this.fapiPrivatePostLeverage(this.extend(request, params));
9281
+ if (isPortfolioMargin) {
9282
+ response = await this.papiPostUmLeverage(this.extend(request, params));
9283
+ }
9284
+ else {
9285
+ response = await this.fapiPrivatePostLeverage(this.extend(request, params));
9286
+ }
9185
9287
  }
9186
9288
  else if (market['inverse']) {
9187
- response = await this.dapiPrivatePostLeverage(this.extend(request, params));
9289
+ if (isPortfolioMargin) {
9290
+ response = await this.papiPostCmLeverage(this.extend(request, params));
9291
+ }
9292
+ else {
9293
+ response = await this.dapiPrivatePostLeverage(this.extend(request, params));
9294
+ }
9188
9295
  }
9189
9296
  else {
9190
9297
  throw new errors.NotSupported(this.id + ' setLeverage() supports linear and inverse contracts only');
@@ -9266,9 +9373,12 @@ class binance extends binance$1 {
9266
9373
  * @description set hedged to true or false for a market
9267
9374
  * @see https://binance-docs.github.io/apidocs/futures/en/#change-position-mode-trade
9268
9375
  * @see https://binance-docs.github.io/apidocs/delivery/en/#change-position-mode-trade
9376
+ * @see https://binance-docs.github.io/apidocs/pm/en/#change-um-position-mode-trade
9377
+ * @see https://binance-docs.github.io/apidocs/pm/en/#change-cm-position-mode-trade
9269
9378
  * @param {bool} hedged set to true to use dualSidePosition
9270
9379
  * @param {string} symbol not used by binance setPositionMode ()
9271
9380
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9381
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to set the position mode for a portfolio margin account
9272
9382
  * @returns {object} response from the exchange
9273
9383
  */
9274
9384
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
@@ -9276,6 +9386,8 @@ class binance extends binance$1 {
9276
9386
  params = this.omit(params, ['type']);
9277
9387
  let subType = undefined;
9278
9388
  [subType, params] = this.handleSubTypeAndParams('setPositionMode', undefined, params);
9389
+ let isPortfolioMargin = undefined;
9390
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'setPositionMode', 'papi', 'portfolioMargin', false);
9279
9391
  let dualSidePosition = undefined;
9280
9392
  if (hedged) {
9281
9393
  dualSidePosition = 'true';
@@ -9288,11 +9400,20 @@ class binance extends binance$1 {
9288
9400
  };
9289
9401
  let response = undefined;
9290
9402
  if (this.isInverse(type, subType)) {
9291
- response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
9403
+ if (isPortfolioMargin) {
9404
+ response = await this.papiPostCmPositionSideDual(this.extend(request, params));
9405
+ }
9406
+ else {
9407
+ response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
9408
+ }
9292
9409
  }
9293
9410
  else {
9294
- // default to future
9295
- response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
9411
+ if (isPortfolioMargin) {
9412
+ response = await this.papiPostUmPositionSideDual(this.extend(request, params));
9413
+ }
9414
+ else {
9415
+ response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
9416
+ }
9296
9417
  }
9297
9418
  //
9298
9419
  // {
@@ -4485,7 +4485,7 @@ class bitget extends bitget$1 {
4485
4485
  const takeProfit = this.safeValue(params, 'takeProfit');
4486
4486
  const isStopLoss = stopLoss !== undefined;
4487
4487
  const isTakeProfit = takeProfit !== undefined;
4488
- const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', price);
4488
+ const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', this.numberToString(price));
4489
4489
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'newCallbackRatio');
4490
4490
  const isTrailingPercentOrder = trailingPercent !== undefined;
4491
4491
  if (this.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder, isTrailingPercentOrder) > 1) {
@@ -343,6 +343,7 @@ class bitso extends bitso$1 {
343
343
  * @method
344
344
  * @name bitso#fetchMarkets
345
345
  * @description retrieves data on all markets for bitso
346
+ * @see https://docs.bitso.com/bitso-api/docs/list-available-books
346
347
  * @param {object} [params] extra parameters specific to the exchange API endpoint
347
348
  * @returns {object[]} an array of objects representing market data
348
349
  */
@@ -502,6 +503,7 @@ class bitso extends bitso$1 {
502
503
  * @method
503
504
  * @name bitso#fetchBalance
504
505
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
506
+ * @see https://docs.bitso.com/bitso-api/docs/get-account-balance
505
507
  * @param {object} [params] extra parameters specific to the exchange API endpoint
506
508
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
507
509
  */
@@ -539,6 +541,7 @@ class bitso extends bitso$1 {
539
541
  * @method
540
542
  * @name bitso#fetchOrderBook
541
543
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
544
+ * @see https://docs.bitso.com/bitso-api/docs/list-order-book
542
545
  * @param {string} symbol unified symbol of the market to fetch the order book for
543
546
  * @param {int} [limit] the maximum amount of order book entries to return
544
547
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -603,6 +606,7 @@ class bitso extends bitso$1 {
603
606
  * @method
604
607
  * @name bitso#fetchTicker
605
608
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
609
+ * @see https://docs.bitso.com/bitso-api/docs/ticker
606
610
  * @param {string} symbol unified symbol of the market to fetch the ticker for
607
611
  * @param {object} [params] extra parameters specific to the exchange API endpoint
608
612
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -823,6 +827,7 @@ class bitso extends bitso$1 {
823
827
  * @method
824
828
  * @name bitso#fetchTrades
825
829
  * @description get the list of most recent trades for a particular symbol
830
+ * @see https://docs.bitso.com/bitso-api/docs/list-trades
826
831
  * @param {string} symbol unified symbol of the market to fetch trades for
827
832
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
828
833
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -842,6 +847,7 @@ class bitso extends bitso$1 {
842
847
  * @method
843
848
  * @name bitso#fetchTradingFees
844
849
  * @description fetch the trading fees for multiple markets
850
+ * @see https://docs.bitso.com/bitso-api/docs/list-fees
845
851
  * @param {object} [params] extra parameters specific to the exchange API endpoint
846
852
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
847
853
  */
@@ -913,6 +919,7 @@ class bitso extends bitso$1 {
913
919
  * @method
914
920
  * @name bitso#fetchMyTrades
915
921
  * @description fetch all trades made by the user
922
+ * @see https://docs.bitso.com/bitso-api/docs/user-trades
916
923
  * @param {string} symbol unified market symbol
917
924
  * @param {int} [since] the earliest time in ms to fetch trades for
918
925
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -950,6 +957,7 @@ class bitso extends bitso$1 {
950
957
  * @method
951
958
  * @name bitso#createOrder
952
959
  * @description create a trade order
960
+ * @see https://docs.bitso.com/bitso-api/docs/place-an-order
953
961
  * @param {string} symbol unified symbol of the market to create an order in
954
962
  * @param {string} type 'market' or 'limit'
955
963
  * @param {string} side 'buy' or 'sell'
@@ -981,6 +989,7 @@ class bitso extends bitso$1 {
981
989
  * @method
982
990
  * @name bitso#cancelOrder
983
991
  * @description cancels an open order
992
+ * @see https://docs.bitso.com/bitso-api/docs/cancel-an-order
984
993
  * @param {string} id order id
985
994
  * @param {string} symbol not used by bitso cancelOrder ()
986
995
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -997,6 +1006,7 @@ class bitso extends bitso$1 {
997
1006
  * @method
998
1007
  * @name bitso#cancelOrders
999
1008
  * @description cancel multiple orders
1009
+ * @see https://docs.bitso.com/bitso-api/docs/cancel-an-order
1000
1010
  * @param {string[]} ids order ids
1001
1011
  * @param {string} symbol unified market symbol
1002
1012
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1033,6 +1043,7 @@ class bitso extends bitso$1 {
1033
1043
  * @method
1034
1044
  * @name bitso#cancelAllOrders
1035
1045
  * @description cancel all open orders
1046
+ * @see https://docs.bitso.com/bitso-api/docs/cancel-an-order
1036
1047
  * @param {undefined} symbol bitso does not support canceling orders for only a specific market
1037
1048
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1038
1049
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1117,6 +1128,7 @@ class bitso extends bitso$1 {
1117
1128
  * @method
1118
1129
  * @name bitso#fetchOpenOrders
1119
1130
  * @description fetch all unfilled currently open orders
1131
+ * @see https://docs.bitso.com/bitso-api/docs/list-open-orders
1120
1132
  * @param {string} symbol unified market symbol
1121
1133
  * @param {int} [since] the earliest time in ms to fetch open orders for
1122
1134
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -1155,6 +1167,7 @@ class bitso extends bitso$1 {
1155
1167
  * @method
1156
1168
  * @name bitso#fetchOrder
1157
1169
  * @description fetches information on an order made by the user
1170
+ * @see https://docs.bitso.com/bitso-api/docs/look-up-orders
1158
1171
  * @param {string} symbol not used by bitso fetchOrder
1159
1172
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1160
1173
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1177,6 +1190,7 @@ class bitso extends bitso$1 {
1177
1190
  * @method
1178
1191
  * @name bitso#fetchOrderTrades
1179
1192
  * @description fetch all the trades made from a single order
1193
+ * @see https://docs.bitso.com/bitso-api/docs/list-user-trades
1180
1194
  * @param {string} id order id
1181
1195
  * @param {string} symbol unified market symbol
1182
1196
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -1197,6 +1211,7 @@ class bitso extends bitso$1 {
1197
1211
  * @method
1198
1212
  * @name bitso#fetchDeposit
1199
1213
  * @description fetch information on a deposit
1214
+ * @see https://docs.bitso.com/bitso-payouts-funding/docs/fundings
1200
1215
  * @param {string} id deposit id
1201
1216
  * @param {string} code bitso does not support filtering by currency code and will ignore this argument
1202
1217
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1239,6 +1254,7 @@ class bitso extends bitso$1 {
1239
1254
  * @method
1240
1255
  * @name bitso#fetchDeposits
1241
1256
  * @description fetch all deposits made to an account
1257
+ * @see https://docs.bitso.com/bitso-payouts-funding/docs/fundings
1242
1258
  * @param {string} code unified currency code
1243
1259
  * @param {int} [since] the earliest time in ms to fetch deposits for
1244
1260
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -1314,7 +1330,7 @@ class bitso extends bitso$1 {
1314
1330
  * @name bitso#fetchTransactionFees
1315
1331
  * @deprecated
1316
1332
  * @description please use fetchDepositWithdrawFees instead
1317
- * @see https://bitso.com/api_info#fees
1333
+ * @see https://docs.bitso.com/bitso-api/docs/list-fees
1318
1334
  * @param {string[]|undefined} codes list of unified currency codes
1319
1335
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1320
1336
  * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
@@ -1407,7 +1423,7 @@ class bitso extends bitso$1 {
1407
1423
  * @method
1408
1424
  * @name bitso#fetchDepositWithdrawFees
1409
1425
  * @description fetch deposit and withdraw fees
1410
- * @see https://bitso.com/api_info#fees
1426
+ * @see https://docs.bitso.com/bitso-api/docs/list-fees
1411
1427
  * @param {string[]|undefined} codes list of unified currency codes
1412
1428
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1413
1429
  * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}