ccxt 4.1.96 → 4.1.98

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 (187) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +1275 -1208
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/ace.js +1 -1
  7. package/dist/cjs/src/ascendex.js +1 -1
  8. package/dist/cjs/src/base/Exchange.js +6 -5
  9. package/dist/cjs/src/base/errors.js +8 -1
  10. package/dist/cjs/src/bigone.js +2 -2
  11. package/dist/cjs/src/binance.js +29 -32
  12. package/dist/cjs/src/bingx.js +76 -3
  13. package/dist/cjs/src/bitfinex.js +1 -1
  14. package/dist/cjs/src/bitfinex2.js +1 -1
  15. package/dist/cjs/src/bitflyer.js +2 -2
  16. package/dist/cjs/src/bitget.js +13 -13
  17. package/dist/cjs/src/bitmart.js +1 -1
  18. package/dist/cjs/src/bitmex.js +2 -2
  19. package/dist/cjs/src/bitopro.js +1 -1
  20. package/dist/cjs/src/bitpanda.js +1 -1
  21. package/dist/cjs/src/bitvavo.js +1 -1
  22. package/dist/cjs/src/blockchaincom.js +1 -1
  23. package/dist/cjs/src/btcalpha.js +2 -2
  24. package/dist/cjs/src/btcbox.js +1 -1
  25. package/dist/cjs/src/btcmarkets.js +2 -2
  26. package/dist/cjs/src/btcturk.js +1 -1
  27. package/dist/cjs/src/bybit.js +2 -2
  28. package/dist/cjs/src/cex.js +1 -1
  29. package/dist/cjs/src/coinbasepro.js +2 -2
  30. package/dist/cjs/src/coinex.js +1 -1
  31. package/dist/cjs/src/coinlist.js +1 -1
  32. package/dist/cjs/src/deribit.js +1 -1
  33. package/dist/cjs/src/digifinex.js +1 -1
  34. package/dist/cjs/src/gate.js +1 -1
  35. package/dist/cjs/src/hitbtc.js +1 -1
  36. package/dist/cjs/src/hollaex.js +2 -2
  37. package/dist/cjs/src/htx.js +1 -1
  38. package/dist/cjs/src/huobijp.js +2 -2
  39. package/dist/cjs/src/idex.js +1 -1
  40. package/dist/cjs/src/independentreserve.js +1 -1
  41. package/dist/cjs/src/kraken.js +1 -1
  42. package/dist/cjs/src/kucoin.js +4 -4
  43. package/dist/cjs/src/kucoinfutures.js +1 -1
  44. package/dist/cjs/src/kuna.js +1 -1
  45. package/dist/cjs/src/latoken.js +1 -1
  46. package/dist/cjs/src/luno.js +2 -2
  47. package/dist/cjs/src/lykke.js +1 -1
  48. package/dist/cjs/src/mexc.js +2 -2
  49. package/dist/cjs/src/ndax.js +1 -1
  50. package/dist/cjs/src/novadax.js +2 -2
  51. package/dist/cjs/src/oceanex.js +1 -1
  52. package/dist/cjs/src/okcoin.js +1 -1
  53. package/dist/cjs/src/okx.js +1 -1
  54. package/dist/cjs/src/phemex.js +3 -3
  55. package/dist/cjs/src/poloniexfutures.js +1 -1
  56. package/dist/cjs/src/pro/alpaca.js +1 -1
  57. package/dist/cjs/src/pro/ascendex.js +1 -1
  58. package/dist/cjs/src/pro/binance.js +2 -2
  59. package/dist/cjs/src/pro/bingx.js +12 -6
  60. package/dist/cjs/src/pro/bitfinex.js +1 -1
  61. package/dist/cjs/src/pro/bitfinex2.js +1 -1
  62. package/dist/cjs/src/pro/bitmart.js +1 -1
  63. package/dist/cjs/src/pro/bitmex.js +1 -1
  64. package/dist/cjs/src/pro/bitpanda.js +1 -1
  65. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  66. package/dist/cjs/src/pro/bybit.js +2 -2
  67. package/dist/cjs/src/pro/coinbase.js +1 -1
  68. package/dist/cjs/src/pro/coinbasepro.js +1 -1
  69. package/dist/cjs/src/pro/deribit.js +1 -1
  70. package/dist/cjs/src/pro/gate.js +1 -1
  71. package/dist/cjs/src/pro/gemini.js +1 -1
  72. package/dist/cjs/src/pro/hollaex.js +1 -1
  73. package/dist/cjs/src/pro/htx.js +1 -1
  74. package/dist/cjs/src/pro/idex.js +1 -1
  75. package/dist/cjs/src/pro/kraken.js +1 -1
  76. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  77. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  78. package/dist/cjs/src/pro/mexc.js +1 -1
  79. package/dist/cjs/src/pro/okcoin.js +1 -1
  80. package/dist/cjs/src/pro/okx.js +1 -1
  81. package/dist/cjs/src/pro/phemex.js +1 -1
  82. package/dist/cjs/src/pro/poloniexfutures.js +1 -1
  83. package/dist/cjs/src/probit.js +1 -1
  84. package/dist/cjs/src/timex.js +1 -1
  85. package/dist/cjs/src/tokocrypto.js +1 -1
  86. package/dist/cjs/src/upbit.js +1 -1
  87. package/dist/cjs/src/wavesexchange.js +1 -1
  88. package/dist/cjs/src/whitebit.js +1 -1
  89. package/dist/cjs/src/woo.js +1 -1
  90. package/dist/cjs/src/zaif.js +1 -1
  91. package/js/ccxt.d.ts +1 -1
  92. package/js/ccxt.js +1 -1
  93. package/js/src/abstract/bingx.d.ts +2 -0
  94. package/js/src/ace.js +1 -1
  95. package/js/src/ascendex.js +1 -1
  96. package/js/src/base/Exchange.d.ts +1 -1
  97. package/js/src/base/Exchange.js +7 -6
  98. package/js/src/base/errorHierarchy.d.ts +1 -0
  99. package/js/src/base/errorHierarchy.js +1 -0
  100. package/js/src/base/errors.d.ts +5 -1
  101. package/js/src/base/errors.js +8 -2
  102. package/js/src/bigone.js +2 -2
  103. package/js/src/binance.js +29 -32
  104. package/js/src/bingx.d.ts +2 -0
  105. package/js/src/bingx.js +76 -3
  106. package/js/src/bitfinex.js +1 -1
  107. package/js/src/bitfinex2.js +1 -1
  108. package/js/src/bitflyer.js +2 -2
  109. package/js/src/bitget.js +13 -13
  110. package/js/src/bitmart.js +1 -1
  111. package/js/src/bitmex.js +2 -2
  112. package/js/src/bitopro.js +1 -1
  113. package/js/src/bitpanda.js +1 -1
  114. package/js/src/bitso.d.ts +1 -1
  115. package/js/src/bitvavo.js +1 -1
  116. package/js/src/blockchaincom.js +1 -1
  117. package/js/src/btcalpha.js +2 -2
  118. package/js/src/btcbox.js +1 -1
  119. package/js/src/btcmarkets.js +2 -2
  120. package/js/src/btcturk.js +1 -1
  121. package/js/src/bybit.js +2 -2
  122. package/js/src/cex.js +1 -1
  123. package/js/src/coinbasepro.js +2 -2
  124. package/js/src/coinex.js +1 -1
  125. package/js/src/coinlist.js +1 -1
  126. package/js/src/deribit.js +1 -1
  127. package/js/src/digifinex.js +1 -1
  128. package/js/src/gate.js +1 -1
  129. package/js/src/hitbtc.js +1 -1
  130. package/js/src/hollaex.js +2 -2
  131. package/js/src/htx.js +1 -1
  132. package/js/src/huobijp.js +2 -2
  133. package/js/src/idex.js +1 -1
  134. package/js/src/independentreserve.js +1 -1
  135. package/js/src/kraken.js +1 -1
  136. package/js/src/kucoin.js +4 -4
  137. package/js/src/kucoinfutures.js +1 -1
  138. package/js/src/kuna.js +1 -1
  139. package/js/src/latoken.js +1 -1
  140. package/js/src/luno.js +2 -2
  141. package/js/src/lykke.js +1 -1
  142. package/js/src/mexc.js +2 -2
  143. package/js/src/ndax.js +1 -1
  144. package/js/src/novadax.js +2 -2
  145. package/js/src/oceanex.js +1 -1
  146. package/js/src/okcoin.js +1 -1
  147. package/js/src/okx.js +1 -1
  148. package/js/src/phemex.js +3 -3
  149. package/js/src/poloniexfutures.js +1 -1
  150. package/js/src/pro/alpaca.js +1 -1
  151. package/js/src/pro/ascendex.js +1 -1
  152. package/js/src/pro/binance.js +2 -2
  153. package/js/src/pro/bingx.js +12 -6
  154. package/js/src/pro/bitfinex.js +1 -1
  155. package/js/src/pro/bitfinex2.js +1 -1
  156. package/js/src/pro/bitmart.js +1 -1
  157. package/js/src/pro/bitmex.js +1 -1
  158. package/js/src/pro/bitpanda.js +1 -1
  159. package/js/src/pro/blockchaincom.js +1 -1
  160. package/js/src/pro/bybit.js +2 -2
  161. package/js/src/pro/coinbase.js +1 -1
  162. package/js/src/pro/coinbasepro.js +1 -1
  163. package/js/src/pro/deribit.js +1 -1
  164. package/js/src/pro/gate.js +1 -1
  165. package/js/src/pro/gemini.js +1 -1
  166. package/js/src/pro/hollaex.js +1 -1
  167. package/js/src/pro/htx.js +1 -1
  168. package/js/src/pro/idex.js +1 -1
  169. package/js/src/pro/kraken.js +1 -1
  170. package/js/src/pro/krakenfutures.js +1 -1
  171. package/js/src/pro/kucoinfutures.js +1 -1
  172. package/js/src/pro/mexc.js +1 -1
  173. package/js/src/pro/okcoin.js +1 -1
  174. package/js/src/pro/okx.js +1 -1
  175. package/js/src/pro/phemex.js +1 -1
  176. package/js/src/pro/poloniexfutures.js +1 -1
  177. package/js/src/probit.js +1 -1
  178. package/js/src/timex.js +1 -1
  179. package/js/src/tokocrypto.js +1 -1
  180. package/js/src/upbit.js +1 -1
  181. package/js/src/wavesexchange.js +1 -1
  182. package/js/src/whitebit.js +1 -1
  183. package/js/src/woo.js +1 -1
  184. package/js/src/zaif.js +1 -1
  185. package/package.json +13 -13
  186. package/skip-tests.json +120 -71
  187. package/run-tests-ws.js +0 -290
package/dist/cjs/ccxt.js CHANGED
@@ -168,7 +168,7 @@ var woo$1 = require('./src/pro/woo.js');
168
168
 
169
169
  //-----------------------------------------------------------------------------
170
170
  // this is updated by vss.js when building
171
- const version = '4.1.96';
171
+ const version = '4.1.98';
172
172
  Exchange["default"].ccxtVersion = version;
173
173
  const exchanges = {
174
174
  'ace': ace,
@@ -697,7 +697,7 @@ class ace extends ace$1 {
697
697
  * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---order-list
698
698
  * @param {string} symbol unified market symbol of the market orders were made in
699
699
  * @param {int} [since] the earliest time in ms to fetch orders for
700
- * @param {int} [limit] the maximum number of orde structures to retrieve
700
+ * @param {int} [limit] the maximum number of order structures to retrieve
701
701
  * @param {object} [params] extra parameters specific to the exchange API endpoint
702
702
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
703
703
  */
@@ -1989,7 +1989,7 @@ class ascendex extends ascendex$1 {
1989
1989
  * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
1990
1990
  * @param {string} symbol unified market symbol of the market orders were made in
1991
1991
  * @param {int} [since] the earliest time in ms to fetch orders for
1992
- * @param {int} [limit] the maximum number of orde structures to retrieve
1992
+ * @param {int} [limit] the maximum number of order structures to retrieve
1993
1993
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1994
1994
  * @param {int} [params.until] the latest time in ms to fetch orders for
1995
1995
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1382,7 +1382,7 @@ class Exchange {
1382
1382
  const length = usedProxies.length;
1383
1383
  if (length > 1) {
1384
1384
  const joinedProxyNames = usedProxies.join(',');
1385
- throw new errors.ExchangeError(this.id + ' you have multiple conflicting proxy_url settings (' + joinedProxyNames + '), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback');
1385
+ throw new errors.ProxyError(this.id + ' you have multiple conflicting proxy settings (' + joinedProxyNames + '), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback');
1386
1386
  }
1387
1387
  return proxyUrl;
1388
1388
  }
@@ -1446,7 +1446,7 @@ class Exchange {
1446
1446
  const length = usedProxies.length;
1447
1447
  if (length > 1) {
1448
1448
  const joinedProxyNames = usedProxies.join(',');
1449
- throw new errors.ExchangeError(this.id + ' you have multiple conflicting settings (' + joinedProxyNames + '), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback');
1449
+ throw new errors.ProxyError(this.id + ' you have multiple conflicting proxy settings (' + joinedProxyNames + '), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback');
1450
1450
  }
1451
1451
  return [httpProxy, httpsProxy, socksProxy];
1452
1452
  }
@@ -1486,13 +1486,13 @@ class Exchange {
1486
1486
  const length = usedProxies.length;
1487
1487
  if (length > 1) {
1488
1488
  const joinedProxyNames = usedProxies.join(',');
1489
- throw new errors.ExchangeError(this.id + ' you have multiple conflicting settings (' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy, wsSocksProxy');
1489
+ throw new errors.ProxyError(this.id + ' you have multiple conflicting proxy settings (' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy, wsSocksProxy');
1490
1490
  }
1491
1491
  return [wsProxy, wssProxy, wsSocksProxy];
1492
1492
  }
1493
1493
  checkConflictingProxies(proxyAgentSet, proxyUrlSet) {
1494
1494
  if (proxyAgentSet && proxyUrlSet) {
1495
- throw new errors.ExchangeError(this.id + ' you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy');
1495
+ throw new errors.ProxyError(this.id + ' you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy');
1496
1496
  }
1497
1497
  }
1498
1498
  findMessageHashes(client, element) {
@@ -1809,6 +1809,7 @@ class Exchange {
1809
1809
  fee['cost'] = this.safeNumber(fee, 'cost');
1810
1810
  }
1811
1811
  const timestamp = this.safeInteger(entry, 'timestamp');
1812
+ const info = this.safeValue(entry, 'info', {});
1812
1813
  return {
1813
1814
  'id': this.safeString(entry, 'id'),
1814
1815
  'timestamp': timestamp,
@@ -1824,7 +1825,7 @@ class Exchange {
1824
1825
  'after': this.parseNumber(after),
1825
1826
  'status': this.safeString(entry, 'status'),
1826
1827
  'fee': fee,
1827
- 'info': entry,
1828
+ 'info': info,
1828
1829
  };
1829
1830
  }
1830
1831
  safeCurrencyStructure(currency) {
@@ -196,6 +196,12 @@ class OperationFailed extends BaseError {
196
196
  this.name = 'OperationFailed';
197
197
  }
198
198
  }
199
+ class ProxyError extends ExchangeError {
200
+ constructor(message) {
201
+ super(message);
202
+ this.name = 'OperationFailed';
203
+ }
204
+ }
199
205
  // Network error
200
206
  class NetworkError extends OperationFailed {
201
207
  constructor(message) {
@@ -246,7 +252,7 @@ class RequestTimeout extends NetworkError {
246
252
  // // Derived class hierarchy
247
253
  // errorHierarchy
248
254
  // )
249
- const errors = { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, ContractUnavailable, NoChange, OperationRejected, OperationFailed };
255
+ const errors = { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
250
256
 
251
257
  exports.AccountNotEnabled = AccountNotEnabled;
252
258
  exports.AccountSuspended = AccountSuspended;
@@ -280,6 +286,7 @@ exports.OrderNotCached = OrderNotCached;
280
286
  exports.OrderNotFillable = OrderNotFillable;
281
287
  exports.OrderNotFound = OrderNotFound;
282
288
  exports.PermissionDenied = PermissionDenied;
289
+ exports.ProxyError = ProxyError;
283
290
  exports.RateLimitExceeded = RateLimitExceeded;
284
291
  exports.RequestTimeout = RequestTimeout;
285
292
  exports["default"] = errors;
@@ -1363,7 +1363,7 @@ class bigone extends bigone$1 {
1363
1363
  * @description fetches information on multiple orders made by the user
1364
1364
  * @param {string} symbol unified market symbol of the market orders were made in
1365
1365
  * @param {int} [since] the earliest time in ms to fetch orders for
1366
- * @param {int} [limit] the maximum number of orde structures to retrieve
1366
+ * @param {int} [limit] the maximum number of order structures to retrieve
1367
1367
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1368
1368
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1369
1369
  */
@@ -1498,7 +1498,7 @@ class bigone extends bigone$1 {
1498
1498
  * @description fetches information on multiple closed orders made by the user
1499
1499
  * @param {string} symbol unified market symbol of the market orders were made in
1500
1500
  * @param {int} [since] the earliest time in ms to fetch orders for
1501
- * @param {int} [limit] the maximum number of orde structures to retrieve
1501
+ * @param {int} [limit] the maximum number of order structures to retrieve
1502
1502
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1503
1503
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1504
1504
  */
@@ -6076,7 +6076,8 @@ class binance extends binance$1 {
6076
6076
  'amount': this.currencyToPrecision(code, amount),
6077
6077
  };
6078
6078
  request['type'] = this.safeString(params, 'type');
6079
- let method = 'sapiPostAssetTransfer';
6079
+ params = this.omit(params, 'type');
6080
+ let response = undefined;
6080
6081
  if (request['type'] === undefined) {
6081
6082
  const symbol = this.safeString(params, 'symbol');
6082
6083
  if (symbol !== undefined) {
@@ -6116,16 +6117,16 @@ class binance extends binance$1 {
6116
6117
  throw new errors.BadRequest(this.id + ' transfer () does not allow transfers between ' + fromAccount + ' and ' + toAccount);
6117
6118
  }
6118
6119
  else if (toSpot && fromIsolated) {
6119
- method = 'sapiPostMarginIsolatedTransfer';
6120
6120
  request['transFrom'] = 'ISOLATED_MARGIN';
6121
6121
  request['transTo'] = 'SPOT';
6122
6122
  request['symbol'] = fromId;
6123
+ response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
6123
6124
  }
6124
6125
  else if (fromSpot && toIsolated) {
6125
- method = 'sapiPostMarginIsolatedTransfer';
6126
6126
  request['transFrom'] = 'SPOT';
6127
6127
  request['transTo'] = 'ISOLATED_MARGIN';
6128
6128
  request['symbol'] = toId;
6129
+ response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
6129
6130
  }
6130
6131
  else {
6131
6132
  if (fromIsolated) {
@@ -6143,8 +6144,9 @@ class binance extends binance$1 {
6143
6144
  request['type'] = fromId + '_' + toId;
6144
6145
  }
6145
6146
  }
6146
- params = this.omit(params, 'type');
6147
- const response = await this[method](this.extend(request, params));
6147
+ if (response === undefined) {
6148
+ response = await this.sapiPostAssetTransfer(this.extend(request, params));
6149
+ }
6148
6150
  //
6149
6151
  // {
6150
6152
  // "tranId":13526853623
@@ -6937,7 +6939,6 @@ class binance extends binance$1 {
6937
6939
  */
6938
6940
  await this.loadMarkets();
6939
6941
  const request = {};
6940
- let method = undefined;
6941
6942
  let paginate = false;
6942
6943
  [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
6943
6944
  if (paginate) {
@@ -6954,15 +6955,6 @@ class binance extends binance$1 {
6954
6955
  let subType = undefined;
6955
6956
  [subType, params] = this.handleSubTypeAndParams('fetchFundingRateHistory', market, params, 'linear');
6956
6957
  params = this.omit(params, 'type');
6957
- if (this.isLinear(type, subType)) {
6958
- method = 'fapiPublicGetFundingRate';
6959
- }
6960
- else if (this.isInverse(type, subType)) {
6961
- method = 'dapiPublicGetFundingRate';
6962
- }
6963
- if (method === undefined) {
6964
- throw new errors.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
6965
- }
6966
6958
  if (since !== undefined) {
6967
6959
  request['startTime'] = since;
6968
6960
  }
@@ -6975,7 +6967,16 @@ class binance extends binance$1 {
6975
6967
  if (limit !== undefined) {
6976
6968
  request['limit'] = limit;
6977
6969
  }
6978
- const response = await this[method](this.extend(request, params));
6970
+ let response = undefined;
6971
+ if (this.isLinear(type, subType)) {
6972
+ response = await this.fapiPublicGetFundingRate(this.extend(request, params));
6973
+ }
6974
+ else if (this.isInverse(type, subType)) {
6975
+ response = await this.dapiPublicGetFundingRate(this.extend(request, params));
6976
+ }
6977
+ else {
6978
+ throw new errors.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
6979
+ }
6979
6980
  //
6980
6981
  // {
6981
6982
  // "symbol": "BTCUSDT",
@@ -7011,22 +7012,21 @@ class binance extends binance$1 {
7011
7012
  */
7012
7013
  await this.loadMarkets();
7013
7014
  symbols = this.marketSymbols(symbols);
7014
- let method = undefined;
7015
7015
  const defaultType = this.safeString2(this.options, 'fetchFundingRates', 'defaultType', 'future');
7016
7016
  const type = this.safeString(params, 'type', defaultType);
7017
7017
  let subType = undefined;
7018
7018
  [subType, params] = this.handleSubTypeAndParams('fetchFundingRates', undefined, params, 'linear');
7019
7019
  const query = this.omit(params, 'type');
7020
+ let response = undefined;
7020
7021
  if (this.isLinear(type, subType)) {
7021
- method = 'fapiPublicGetPremiumIndex';
7022
+ response = await this.fapiPublicGetPremiumIndex(query);
7022
7023
  }
7023
7024
  else if (this.isInverse(type, subType)) {
7024
- method = 'dapiPublicGetPremiumIndex';
7025
+ response = await this.dapiPublicGetPremiumIndex(query);
7025
7026
  }
7026
7027
  else {
7027
7028
  throw new errors.NotSupported(this.id + ' fetchFundingRates() supports linear and inverse contracts only');
7028
7029
  }
7029
- const response = await this[method](query);
7030
7030
  const result = [];
7031
7031
  for (let i = 0; i < response.length; i++) {
7032
7032
  const entry = response[i];
@@ -7494,22 +7494,21 @@ class binance extends binance$1 {
7494
7494
  // it contains useful stuff like the maintenance margin and initial margin for positions
7495
7495
  const leverageBrackets = this.safeValue(this.options, 'leverageBrackets');
7496
7496
  if ((leverageBrackets === undefined) || (reload)) {
7497
- let method = undefined;
7498
7497
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
7499
7498
  const type = this.safeString(params, 'type', defaultType);
7500
7499
  const query = this.omit(params, 'type');
7501
7500
  let subType = undefined;
7502
7501
  [subType, params] = this.handleSubTypeAndParams('loadLeverageBrackets', undefined, params, 'linear');
7502
+ let response = undefined;
7503
7503
  if (this.isLinear(type, subType)) {
7504
- method = 'fapiPrivateGetLeverageBracket';
7504
+ response = await this.fapiPrivateGetLeverageBracket(query);
7505
7505
  }
7506
7506
  else if (this.isInverse(type, subType)) {
7507
- method = 'dapiPrivateV2GetLeverageBracket';
7507
+ response = await this.dapiPrivateV2GetLeverageBracket(query);
7508
7508
  }
7509
7509
  else {
7510
7510
  throw new errors.NotSupported(this.id + ' loadLeverageBrackets() supports linear and inverse contracts only');
7511
7511
  }
7512
- const response = await this[method](query);
7513
7512
  this.options['leverageBrackets'] = {};
7514
7513
  for (let i = 0; i < response.length; i++) {
7515
7514
  const entry = response[i];
@@ -7971,7 +7970,6 @@ class binance extends binance$1 {
7971
7970
  */
7972
7971
  await this.loadMarkets();
7973
7972
  let market = undefined;
7974
- let method = undefined;
7975
7973
  const request = {
7976
7974
  'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION" and "INSURANCE_CLEAR"
7977
7975
  };
@@ -7993,16 +7991,16 @@ class binance extends binance$1 {
7993
7991
  const defaultType = this.safeString2(this.options, 'fetchFundingHistory', 'defaultType', 'future');
7994
7992
  const type = this.safeString(params, 'type', defaultType);
7995
7993
  params = this.omit(params, 'type');
7994
+ let response = undefined;
7996
7995
  if (this.isLinear(type, subType)) {
7997
- method = 'fapiPrivateGetIncome';
7996
+ response = await this.fapiPrivateGetIncome(this.extend(request, params));
7998
7997
  }
7999
7998
  else if (this.isInverse(type, subType)) {
8000
- method = 'dapiPrivateGetIncome';
7999
+ response = await this.dapiPrivateGetIncome(this.extend(request, params));
8001
8000
  }
8002
8001
  else {
8003
8002
  throw new errors.NotSupported(this.id + ' fetchFundingHistory() supports linear and inverse contracts only');
8004
8003
  }
8005
- const response = await this[method](this.extend(request, params));
8006
8004
  return this.parseIncomes(response, market, since, limit);
8007
8005
  }
8008
8006
  async setLeverage(leverage, symbol = undefined, params = {}) {
@@ -8756,17 +8754,16 @@ class binance extends binance$1 {
8756
8754
  'symbol': market['id'],
8757
8755
  'amount': amount,
8758
8756
  };
8759
- let method = undefined;
8757
+ let response = undefined;
8760
8758
  let code = undefined;
8761
8759
  if (market['linear']) {
8762
- method = 'fapiPrivatePostPositionMargin';
8763
8760
  code = market['quote'];
8761
+ response = await this.fapiPrivatePostPositionMargin(this.extend(request, params));
8764
8762
  }
8765
8763
  else {
8766
- method = 'dapiPrivatePostPositionMargin';
8767
8764
  code = market['base'];
8765
+ response = await this.dapiPrivatePostPositionMargin(this.extend(request, params));
8768
8766
  }
8769
- const response = await this[method](this.extend(request, params));
8770
8767
  //
8771
8768
  // {
8772
8769
  // "code": 200,
@@ -30,7 +30,7 @@ class bingx extends bingx$1 {
30
30
  'cancelOrder': true,
31
31
  'cancelOrders': true,
32
32
  'closeAllPositions': true,
33
- 'closePosition': false,
33
+ 'closePosition': true,
34
34
  'createMarketBuyOrderWithCost': true,
35
35
  'createMarketOrderWithCost': true,
36
36
  'createMarketSellOrderWithCost': true,
@@ -142,6 +142,16 @@ class bingx extends bingx$1 {
142
142
  },
143
143
  },
144
144
  'swap': {
145
+ 'v1': {
146
+ 'private': {
147
+ 'get': {
148
+ 'positionSide/dual': 1,
149
+ },
150
+ 'post': {
151
+ 'positionSide/dual': 1,
152
+ },
153
+ },
154
+ },
145
155
  'v2': {
146
156
  'public': {
147
157
  'get': {
@@ -2470,7 +2480,7 @@ class bingx extends bingx$1 {
2470
2480
  * @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
2471
2481
  * @param {string} [symbol] unified market symbol of the market orders were made in
2472
2482
  * @param {int} [since] the earliest time in ms to fetch orders for
2473
- * @param {int} [limit] the maximum number of orde structures to retrieve
2483
+ * @param {int} [limit] the maximum number of order structures to retrieve
2474
2484
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2475
2485
  * @param {int} [params.until] the latest time in ms to fetch orders for
2476
2486
  * @param {boolean} [params.standard] whether to fetch standard contract orders
@@ -3369,12 +3379,44 @@ class bingx extends bingx$1 {
3369
3379
  'datetime': this.iso8601(timestamp),
3370
3380
  });
3371
3381
  }
3382
+ async closePosition(symbol, side = undefined, params = {}) {
3383
+ /**
3384
+ * @method
3385
+ * @name bingx#closePosition
3386
+ * @description closes open positions for a market
3387
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
3388
+ * @param {string} symbol Unified CCXT market symbol
3389
+ * @param {string} [side] not used by bingx
3390
+ * @param {object} [params] extra parameters specific to the bingx api endpoint
3391
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3392
+ */
3393
+ await this.loadMarkets();
3394
+ const market = this.market(symbol);
3395
+ const request = {
3396
+ 'symbol': market['id'],
3397
+ };
3398
+ const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
3399
+ //
3400
+ // {
3401
+ // "code": 0,
3402
+ // "msg": "",
3403
+ // "data": {
3404
+ // "success": [
3405
+ // 1727686766700486656,
3406
+ // ],
3407
+ // "failed": null
3408
+ // }
3409
+ // }
3410
+ //
3411
+ const data = this.safeValue(response, 'data');
3412
+ return this.parseOrder(data);
3413
+ }
3372
3414
  async closeAllPositions(params = {}) {
3373
3415
  /**
3374
3416
  * @method
3375
3417
  * @name bitget#closePositions
3376
3418
  * @description closes open positions for a market
3377
- * @see https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
3419
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
3378
3420
  * @param {object} [params] extra parameters specific to the okx api endpoint
3379
3421
  * @param {string} [params.recvWindow] request valid time window value
3380
3422
  * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -3413,6 +3455,37 @@ class bingx extends bingx$1 {
3413
3455
  }
3414
3456
  return positions;
3415
3457
  }
3458
+ async setPositionMode(hedged, symbol = undefined, params = {}) {
3459
+ /**
3460
+ * @method
3461
+ * @name bingx#setPositionMode
3462
+ * @description set hedged to true or false for a market
3463
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set%20Position%20Mode
3464
+ * @param {bool} hedged set to true to use dualSidePosition
3465
+ * @param {string} symbol not used by bingx setPositionMode ()
3466
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3467
+ * @returns {object} response from the exchange
3468
+ */
3469
+ let dualSidePosition = undefined;
3470
+ if (hedged) {
3471
+ dualSidePosition = 'true';
3472
+ }
3473
+ else {
3474
+ dualSidePosition = 'false';
3475
+ }
3476
+ const request = {
3477
+ 'dualSidePosition': dualSidePosition,
3478
+ };
3479
+ //
3480
+ // {
3481
+ // code: '0',
3482
+ // msg: '',
3483
+ // timeStamp: '1703327432734',
3484
+ // data: { dualSidePosition: 'false' }
3485
+ // }
3486
+ //
3487
+ return await this.swapV1PrivatePostPositionSideDual(this.extend(request, params));
3488
+ }
3416
3489
  sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3417
3490
  const type = section[0];
3418
3491
  const version = section[1];
@@ -1238,7 +1238,7 @@ class bitfinex extends bitfinex$1 {
1238
1238
  * @description fetches information on multiple closed orders made by the user
1239
1239
  * @param {string} symbol unified market symbol of the market orders were made in
1240
1240
  * @param {int} [since] the earliest time in ms to fetch orders for
1241
- * @param {int} [limit] the maximum number of orde structures to retrieve
1241
+ * @param {int} [limit] the maximum number of order structures to retrieve
1242
1242
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1243
1243
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1244
1244
  */
@@ -1813,7 +1813,7 @@ class bitfinex2 extends bitfinex2$1 {
1813
1813
  * @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
1814
1814
  * @param {string} symbol unified market symbol of the market orders were made in
1815
1815
  * @param {int} [since] the earliest time in ms to fetch orders for
1816
- * @param {int} [limit] the maximum number of orde structures to retrieve
1816
+ * @param {int} [limit] the maximum number of order structures to retrieve
1817
1817
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1818
1818
  * @param {int} [params.until] the latest time in ms to fetch entries for
1819
1819
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
@@ -651,7 +651,7 @@ class bitflyer extends bitflyer$1 {
651
651
  * @see https://lightning.bitflyer.com/docs?lang=en#list-orders
652
652
  * @param {string} symbol unified market symbol of the market orders were made in
653
653
  * @param {int} [since] the earliest time in ms to fetch orders for
654
- * @param {int} [limit] the maximum number of orde structures to retrieve
654
+ * @param {int} [limit] the maximum number of order structures to retrieve
655
655
  * @param {object} [params] extra parameters specific to the exchange API endpoint
656
656
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
657
657
  */
@@ -696,7 +696,7 @@ class bitflyer extends bitflyer$1 {
696
696
  * @see https://lightning.bitflyer.com/docs?lang=en#list-orders
697
697
  * @param {string} symbol unified market symbol of the market orders were made in
698
698
  * @param {int} [since] the earliest time in ms to fetch orders for
699
- * @param {int} [limit] the maximum number of orde structures to retrieve
699
+ * @param {int} [limit] the maximum number of order structures to retrieve
700
700
  * @param {object} [params] extra parameters specific to the exchange API endpoint
701
701
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
702
702
  */
@@ -1278,12 +1278,12 @@ class bitget extends bitget$1 {
1278
1278
  '30m': '30min',
1279
1279
  '1h': '1h',
1280
1280
  '4h': '4h',
1281
- '6h': '6h',
1282
- '12h': '12h',
1283
- '1d': '1day',
1284
- '3d': '3day',
1285
- '1w': '1week',
1286
- '1M': '1M',
1281
+ '6h': '6Hutc',
1282
+ '12h': '12Hutc',
1283
+ '1d': '1Dutc',
1284
+ '3d': '3Dutc',
1285
+ '1w': '1Wutc',
1286
+ '1M': '1Mutc',
1287
1287
  },
1288
1288
  'swap': {
1289
1289
  '1m': '1m',
@@ -1294,12 +1294,12 @@ class bitget extends bitget$1 {
1294
1294
  '1h': '1H',
1295
1295
  '2h': '2H',
1296
1296
  '4h': '4H',
1297
- '6h': '6H',
1298
- '12h': '12H',
1299
- '1d': '1D',
1300
- '3d': '3D',
1301
- '1w': '1W',
1302
- '1M': '1M',
1297
+ '6h': '6Hutc',
1298
+ '12h': '12Hutc',
1299
+ '1d': '1Dutc',
1300
+ '3d': '3Dutc',
1301
+ '1w': '1Wutc',
1302
+ '1M': '1Mutc',
1303
1303
  },
1304
1304
  },
1305
1305
  'fetchMarkets': [
@@ -2901,7 +2901,7 @@ class bitget extends bitget$1 {
2901
2901
  const currencyCode = this.safeCurrencyCode(this.safeString(feeStructure, 'feeCoin'));
2902
2902
  fee = {
2903
2903
  'currency': currencyCode,
2904
- 'cost': Precise["default"].stringNeg(this.safeString(feeStructure, 'totalFee')),
2904
+ 'cost': Precise["default"].stringAbs(this.safeString(feeStructure, 'totalFee')),
2905
2905
  };
2906
2906
  }
2907
2907
  return this.safeTrade({
@@ -2752,7 +2752,7 @@ class bitmart extends bitmart$1 {
2752
2752
  * @description fetches information on multiple closed orders made by the user
2753
2753
  * @param {string} symbol unified market symbol of the market orders were made in
2754
2754
  * @param {int} [since] the earliest time in ms to fetch orders for
2755
- * @param {int} [limit] the maximum number of orde structures to retrieve
2755
+ * @param {int} [limit] the maximum number of order structures to retrieve
2756
2756
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2757
2757
  * @param {int} [params.until] timestamp in ms of the latest entry
2758
2758
  * @param {string} [params.marginMode] *spot only* 'cross' or 'isolated', for margin trading
@@ -872,7 +872,7 @@ class bitmex extends bitmex$1 {
872
872
  * @description fetches information on multiple orders made by the user
873
873
  * @param {string} symbol unified market symbol of the market orders were made in
874
874
  * @param {int} [since] the earliest time in ms to fetch orders for
875
- * @param {int} [limit] the maximum number of orde structures to retrieve
875
+ * @param {int} [limit] the maximum number of order structures to retrieve
876
876
  * @param {object} [params] extra parameters specific to the exchange API endpoint
877
877
  * @param {int} [params.until] the earliest time in ms to fetch orders for
878
878
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
@@ -936,7 +936,7 @@ class bitmex extends bitmex$1 {
936
936
  * @description fetches information on multiple closed orders made by the user
937
937
  * @param {string} symbol unified market symbol of the market orders were made in
938
938
  * @param {int} [since] the earliest time in ms to fetch orders for
939
- * @param {int} [limit] the maximum number of orde structures to retrieve
939
+ * @param {int} [limit] the maximum number of order structures to retrieve
940
940
  * @param {object} [params] extra parameters specific to the exchange API endpoint
941
941
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
942
942
  */
@@ -1267,7 +1267,7 @@ class bitopro extends bitopro$1 {
1267
1267
  * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_orders_data.md
1268
1268
  * @param {string} symbol unified market symbol of the market orders were made in
1269
1269
  * @param {int} [since] the earliest time in ms to fetch orders for
1270
- * @param {int} [limit] the maximum number of orde structures to retrieve
1270
+ * @param {int} [limit] the maximum number of order structures to retrieve
1271
1271
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1272
1272
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1273
1273
  */
@@ -1817,7 +1817,7 @@ class bitpanda extends bitpanda$1 {
1817
1817
  * @description fetches information on multiple closed orders made by the user
1818
1818
  * @param {string} symbol unified market symbol of the market orders were made in
1819
1819
  * @param {int} [since] the earliest time in ms to fetch orders for
1820
- * @param {int} [limit] the maximum number of orde structures to retrieve
1820
+ * @param {int} [limit] the maximum number of order structures to retrieve
1821
1821
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1822
1822
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1823
1823
  */
@@ -1258,7 +1258,7 @@ class bitvavo extends bitvavo$1 {
1258
1258
  * @description fetches information on multiple orders made by the user
1259
1259
  * @param {string} symbol unified market symbol of the market orders were made in
1260
1260
  * @param {int} [since] the earliest time in ms to fetch orders for
1261
- * @param {int} [limit] the maximum number of orde structures to retrieve
1261
+ * @param {int} [limit] the maximum number of order structures to retrieve
1262
1262
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1263
1263
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1264
1264
  * @param {int} [params.until] the latest time in ms to fetch entries for
@@ -688,7 +688,7 @@ class blockchaincom extends blockchaincom$1 {
688
688
  * @description fetches information on multiple closed orders made by the user
689
689
  * @param {string} symbol unified market symbol of the market orders were made in
690
690
  * @param {int} [since] the earliest time in ms to fetch orders for
691
- * @param {int} [limit] the maximum number of orde structures to retrieve
691
+ * @param {int} [limit] the maximum number of order structures to retrieve
692
692
  * @param {object} [params] extra parameters specific to the exchange API endpoint
693
693
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
694
694
  */
@@ -795,7 +795,7 @@ class btcalpha extends btcalpha$1 {
795
795
  * @description fetches information on multiple orders made by the user
796
796
  * @param {string} symbol unified market symbol of the market orders were made in
797
797
  * @param {int} [since] the earliest time in ms to fetch orders for
798
- * @param {int} [limit] the maximum number of orde structures to retrieve
798
+ * @param {int} [limit] the maximum number of order structures to retrieve
799
799
  * @param {object} [params] extra parameters specific to the exchange API endpoint
800
800
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
801
801
  */
@@ -835,7 +835,7 @@ class btcalpha extends btcalpha$1 {
835
835
  * @description fetches information on multiple closed orders made by the user
836
836
  * @param {string} symbol unified market symbol of the market orders were made in
837
837
  * @param {int} [since] the earliest time in ms to fetch orders for
838
- * @param {int} [limit] the maximum number of orde structures to retrieve
838
+ * @param {int} [limit] the maximum number of order structures to retrieve
839
839
  * @param {object} [params] extra parameters specific to the exchange API endpoint
840
840
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
841
841
  */
@@ -485,7 +485,7 @@ class btcbox extends btcbox$1 {
485
485
  * @description fetches information on multiple orders made by the user
486
486
  * @param {string} symbol unified market symbol of the market orders were made in
487
487
  * @param {int} [since] the earliest time in ms to fetch orders for
488
- * @param {int} [limit] the maximum number of orde structures to retrieve
488
+ * @param {int} [limit] the maximum number of order structures to retrieve
489
489
  * @param {object} [params] extra parameters specific to the exchange API endpoint
490
490
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
491
491
  */