ccxt 4.2.29 → 4.2.30

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 (154) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +1709 -533
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +3 -1
  5. package/dist/cjs/src/ascendex.js +5 -5
  6. package/dist/cjs/src/base/Exchange.js +21 -21
  7. package/dist/cjs/src/base/errors.js +3 -3
  8. package/dist/cjs/src/base/functions/type.js +12 -0
  9. package/dist/cjs/src/bigone.js +2 -2
  10. package/dist/cjs/src/binance.js +896 -217
  11. package/dist/cjs/src/bingx.js +1 -1
  12. package/dist/cjs/src/bitfinex.js +1 -1
  13. package/dist/cjs/src/bitfinex2.js +52 -62
  14. package/dist/cjs/src/bitget.js +8 -4
  15. package/dist/cjs/src/bitmart.js +3 -3
  16. package/dist/cjs/src/bitmex.js +4 -4
  17. package/dist/cjs/src/bitrue.js +1 -1
  18. package/dist/cjs/src/bitso.js +1 -1
  19. package/dist/cjs/src/bitteam.js +2 -2
  20. package/dist/cjs/src/btcalpha.js +1 -1
  21. package/dist/cjs/src/bybit.js +3 -3
  22. package/dist/cjs/src/coinbase.js +12 -5
  23. package/dist/cjs/src/coincheck.js +1 -1
  24. package/dist/cjs/src/coinex.js +2 -2
  25. package/dist/cjs/src/coinlist.js +1 -1
  26. package/dist/cjs/src/coinmate.js +1 -1
  27. package/dist/cjs/src/coinmetro.js +2 -2
  28. package/dist/cjs/src/coinsph.js +1 -1
  29. package/dist/cjs/src/cryptocom.js +3 -3
  30. package/dist/cjs/src/digifinex.js +6 -4
  31. package/dist/cjs/src/exmo.js +2 -2
  32. package/dist/cjs/src/gate.js +5 -5
  33. package/dist/cjs/src/gemini.js +3 -3
  34. package/dist/cjs/src/hitbtc.js +14 -20
  35. package/dist/cjs/src/hollaex.js +2 -2
  36. package/dist/cjs/src/htx.js +5 -5
  37. package/dist/cjs/src/huobijp.js +1 -1
  38. package/dist/cjs/src/krakenfutures.js +1 -1
  39. package/dist/cjs/src/kucoin.js +17 -17
  40. package/dist/cjs/src/kucoinfutures.js +3 -3
  41. package/dist/cjs/src/lbank.js +1 -1
  42. package/dist/cjs/src/mexc.js +7 -7
  43. package/dist/cjs/src/novadax.js +1 -1
  44. package/dist/cjs/src/okcoin.js +2 -2
  45. package/dist/cjs/src/okx.js +7 -6
  46. package/dist/cjs/src/p2b.js +1 -0
  47. package/dist/cjs/src/phemex.js +3 -3
  48. package/dist/cjs/src/poloniexfutures.js +3 -3
  49. package/dist/cjs/src/pro/alpaca.js +1 -1
  50. package/dist/cjs/src/pro/binance.js +4 -4
  51. package/dist/cjs/src/pro/bitget.js +1 -1
  52. package/dist/cjs/src/pro/bitmart.js +1 -1
  53. package/dist/cjs/src/pro/bitmex.js +49 -6
  54. package/dist/cjs/src/pro/bitvavo.js +1 -1
  55. package/dist/cjs/src/pro/bybit.js +2 -2
  56. package/dist/cjs/src/pro/cex.js +2 -2
  57. package/dist/cjs/src/pro/independentreserve.js +1 -1
  58. package/dist/cjs/src/pro/okx.js +1 -1
  59. package/dist/cjs/src/pro/onetrading.js +2 -2
  60. package/dist/cjs/src/pro/p2b.js +432 -0
  61. package/dist/cjs/src/pro/probit.js +5 -5
  62. package/dist/cjs/src/pro/whitebit.js +1 -1
  63. package/dist/cjs/src/probit.js +1 -1
  64. package/dist/cjs/src/timex.js +1 -1
  65. package/dist/cjs/src/tokocrypto.js +3 -3
  66. package/dist/cjs/src/wavesexchange.js +2 -2
  67. package/dist/cjs/src/whitebit.js +2 -2
  68. package/dist/cjs/src/woo.js +3 -3
  69. package/dist/cjs/src/yobit.js +1 -1
  70. package/dist/cjs/src/zaif.js +1 -1
  71. package/dist/cjs/src/zonda.js +3 -3
  72. package/js/ccxt.d.ts +4 -1
  73. package/js/ccxt.js +3 -1
  74. package/js/src/abstract/bybit.d.ts +2 -2
  75. package/js/src/ascendex.js +5 -5
  76. package/js/src/base/Exchange.d.ts +1 -1
  77. package/js/src/base/Exchange.js +21 -21
  78. package/js/src/base/errorHierarchy.d.ts +7 -6
  79. package/js/src/base/errorHierarchy.js +7 -6
  80. package/js/src/base/errors.d.ts +3 -3
  81. package/js/src/base/errors.js +3 -3
  82. package/js/src/base/functions/type.js +12 -0
  83. package/js/src/bigone.js +2 -2
  84. package/js/src/binance.d.ts +1 -0
  85. package/js/src/binance.js +897 -218
  86. package/js/src/bingx.js +1 -1
  87. package/js/src/bitfinex.js +1 -1
  88. package/js/src/bitfinex2.js +52 -62
  89. package/js/src/bitget.js +8 -4
  90. package/js/src/bitmart.js +3 -3
  91. package/js/src/bitmex.js +4 -4
  92. package/js/src/bitrue.js +1 -1
  93. package/js/src/bitso.d.ts +1 -1
  94. package/js/src/bitso.js +1 -1
  95. package/js/src/bitteam.js +2 -2
  96. package/js/src/btcalpha.js +1 -1
  97. package/js/src/bybit.js +3 -3
  98. package/js/src/coinbase.js +12 -5
  99. package/js/src/coincheck.js +1 -1
  100. package/js/src/coinex.js +2 -2
  101. package/js/src/coinlist.js +1 -1
  102. package/js/src/coinmate.js +1 -1
  103. package/js/src/coinmetro.d.ts +1 -1
  104. package/js/src/coinmetro.js +2 -2
  105. package/js/src/coinsph.js +1 -1
  106. package/js/src/cryptocom.js +3 -3
  107. package/js/src/digifinex.js +6 -4
  108. package/js/src/exmo.js +2 -2
  109. package/js/src/gate.js +5 -5
  110. package/js/src/gemini.d.ts +1 -1
  111. package/js/src/gemini.js +3 -3
  112. package/js/src/hitbtc.js +14 -20
  113. package/js/src/hollaex.js +2 -2
  114. package/js/src/htx.js +5 -5
  115. package/js/src/huobijp.js +1 -1
  116. package/js/src/krakenfutures.js +1 -1
  117. package/js/src/kucoin.js +17 -17
  118. package/js/src/kucoinfutures.js +3 -3
  119. package/js/src/lbank.js +1 -1
  120. package/js/src/mexc.js +7 -7
  121. package/js/src/novadax.js +1 -1
  122. package/js/src/okcoin.js +2 -2
  123. package/js/src/okx.js +7 -6
  124. package/js/src/p2b.js +1 -0
  125. package/js/src/phemex.js +3 -3
  126. package/js/src/poloniexfutures.js +3 -3
  127. package/js/src/pro/alpaca.js +1 -1
  128. package/js/src/pro/binance.js +4 -4
  129. package/js/src/pro/bitget.js +1 -1
  130. package/js/src/pro/bitmart.js +1 -1
  131. package/js/src/pro/bitmex.d.ts +2 -1
  132. package/js/src/pro/bitmex.js +49 -6
  133. package/js/src/pro/bitvavo.js +1 -1
  134. package/js/src/pro/bybit.js +2 -2
  135. package/js/src/pro/cex.js +2 -2
  136. package/js/src/pro/independentreserve.js +1 -1
  137. package/js/src/pro/okx.js +1 -1
  138. package/js/src/pro/onetrading.js +2 -2
  139. package/js/src/pro/p2b.d.ts +23 -0
  140. package/js/src/pro/p2b.js +433 -0
  141. package/js/src/pro/probit.js +5 -5
  142. package/js/src/pro/whitebit.js +1 -1
  143. package/js/src/probit.js +1 -1
  144. package/js/src/timex.js +1 -1
  145. package/js/src/tokocrypto.js +3 -3
  146. package/js/src/wavesexchange.js +2 -2
  147. package/js/src/whitebit.js +2 -2
  148. package/js/src/woo.js +3 -3
  149. package/js/src/yobit.js +1 -1
  150. package/js/src/zaif.js +1 -1
  151. package/js/src/zonda.d.ts +1 -1
  152. package/js/src/zonda.js +3 -3
  153. package/package.json +1 -1
  154. package/skip-tests.json +3 -10
package/js/src/bingx.js CHANGED
@@ -1845,7 +1845,7 @@ export default class bingx extends Exchange {
1845
1845
  if (((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) && !isTrailing) {
1846
1846
  request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
1847
1847
  }
1848
- let reduceOnly = this.safeValue(params, 'reduceOnly', false);
1848
+ let reduceOnly = this.safeBool(params, 'reduceOnly', false);
1849
1849
  if (isTriggerOrder) {
1850
1850
  request['stopPrice'] = this.parseToNumeric(this.priceToPrecision(symbol, triggerPrice));
1851
1851
  if (isMarketOrder || (type === 'TRIGGER_MARKET')) {
@@ -1057,7 +1057,7 @@ export default class bitfinex extends Exchange {
1057
1057
  */
1058
1058
  await this.loadMarkets();
1059
1059
  const market = this.market(symbol);
1060
- const postOnly = this.safeValue(params, 'postOnly', false);
1060
+ const postOnly = this.safeBool(params, 'postOnly', false);
1061
1061
  type = type.toLowerCase();
1062
1062
  params = this.omit(params, ['postOnly']);
1063
1063
  if (market['spot']) {
@@ -38,9 +38,13 @@ export default class bitfinex2 extends Exchange {
38
38
  'createLimitOrder': true,
39
39
  'createMarketOrder': true,
40
40
  'createOrder': true,
41
+ 'createReduceOnlyOrder': true,
41
42
  'createStopLimitOrder': true,
42
43
  'createStopMarketOrder': true,
43
44
  'createStopOrder': true,
45
+ 'createTriggerOrder': true,
46
+ 'createTrailingAmountOrder': true,
47
+ 'createTrailingPercentOrder': false,
44
48
  'editOrder': false,
45
49
  'fetchBalance': true,
46
50
  'fetchClosedOrder': true,
@@ -1495,94 +1499,81 @@ export default class bitfinex2 extends Exchange {
1495
1499
  /**
1496
1500
  * @method
1497
1501
  * @name bitfinex2#createOrder
1498
- * @description Create an order on the exchange
1502
+ * @description create an order on the exchange
1499
1503
  * @see https://docs.bitfinex.com/reference/rest-auth-submit-order
1500
- * @param {string} symbol Unified CCXT market symbol
1504
+ * @param {string} symbol unified CCXT market symbol
1501
1505
  * @param {string} type 'limit' or 'market'
1502
1506
  * @param {string} side 'buy' or 'sell'
1503
1507
  * @param {float} amount the amount of currency to trade
1504
- * @param {float} [price] price of order
1505
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1506
- * @param {float} [params.stopPrice] The price at which a trigger order is triggered at
1508
+ * @param {float} [price] price of the order
1509
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1510
+ * @param {float} [params.stopPrice] the price that triggers a trigger order
1507
1511
  * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
1508
- * @param {bool} params.postOnly
1509
- * @param {bool} [params.reduceOnly] Ensures that the executed order does not flip the opened position.
1512
+ * @param {boolean} [params.postOnly] set to true if you want to make a post only order
1513
+ * @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
1510
1514
  * @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
1511
1515
  * @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
1512
- * @param {string} [params.price_traling] The trailing price for a trailing stop order
1513
- * @param {string} [params.price_aux_limit] Order price for stop limit orders
1516
+ * @param {string} [params.price_aux_limit] order price for stop limit orders
1514
1517
  * @param {string} [params.price_oco_stop] OCO stop price
1518
+ * @param {string} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
1515
1519
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1516
1520
  */
1517
1521
  await this.loadMarkets();
1518
1522
  const market = this.market(symbol);
1519
- // order types "limit" and "market" immediatley parsed "EXCHANGE LIMIT" and "EXCHANGE MARKET"
1520
- // note: same order types exist for margin orders without the EXCHANGE prefix
1521
- const orderTypes = this.safeValue(this.options, 'orderTypes', {});
1522
- let orderType = type.toUpperCase();
1523
- if (market['spot']) {
1524
- // although they claim that type needs to be 'exchange limit' or 'exchange market'
1525
- // in fact that's not the case for swap markets
1526
- orderType = this.safeStringUpper(orderTypes, type, type);
1527
- }
1528
- const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
1529
- const timeInForce = this.safeString(params, 'timeInForce');
1530
- const postOnlyParam = this.safeValue(params, 'postOnly', false);
1531
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
1532
- const clientOrderId = this.safeValue2(params, 'cid', 'clientOrderId');
1533
- params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'price_aux_limit']);
1534
1523
  let amountString = this.amountToPrecision(symbol, amount);
1535
1524
  amountString = (side === 'buy') ? amountString : Precise.stringNeg(amountString);
1536
1525
  const request = {
1537
- // 'gid': 0123456789, // int32, optional group id for the order
1538
- // 'cid': 0123456789, // int32 client order id
1539
- 'type': orderType,
1540
1526
  'symbol': market['id'],
1541
- // 'price': this.numberToString (price),
1542
1527
  'amount': amountString,
1543
- // 'flags': 0, // int32, https://docs.bitfinex.com/v2/docs/flag-values
1544
- // 'lev': 10, // leverage for a derivative orders, the value should be between 1 and 100 inclusive, optional, 10 by default
1545
- // 'price_trailing': this.numberToString (priceTrailing),
1546
- // 'price_aux_limit': this.numberToString (stopPrice),
1547
- // 'price_oco_stop': this.numberToString (ocoStopPrice),
1548
- // 'tif': '2020-01-01 10:45:23', // datetime for automatic order cancellation
1549
- // 'meta': {
1550
- // 'aff_code': 'AFF_CODE_HERE'
1551
- // },
1552
1528
  };
1553
- const stopLimit = ((orderType === 'EXCHANGE STOP LIMIT') || ((orderType === 'EXCHANGE LIMIT') && (stopPrice !== undefined)));
1554
- const exchangeStop = (orderType === 'EXCHANGE STOP');
1555
- const exchangeMarket = (orderType === 'EXCHANGE MARKET');
1556
- const stopMarket = (exchangeStop || (exchangeMarket && (stopPrice !== undefined)));
1557
- const ioc = ((orderType === 'EXCHANGE IOC') || (timeInForce === 'IOC'));
1558
- const fok = ((orderType === 'EXCHANGE FOK') || (timeInForce === 'FOK'));
1529
+ const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
1530
+ const trailingAmount = this.safeString(params, 'trailingAmount');
1531
+ const timeInForce = this.safeString(params, 'timeInForce');
1532
+ const postOnlyParam = this.safeBool(params, 'postOnly', false);
1533
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
1534
+ const clientOrderId = this.safeValue2(params, 'cid', 'clientOrderId');
1535
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId']);
1536
+ let orderType = type.toUpperCase();
1537
+ if (trailingAmount !== undefined) {
1538
+ orderType = 'TRAILING STOP';
1539
+ request['price_trailing'] = trailingAmount;
1540
+ }
1541
+ else if (stopPrice !== undefined) {
1542
+ // request['price'] is taken as stopPrice for stop orders
1543
+ request['price'] = this.priceToPrecision(symbol, stopPrice);
1544
+ if (type === 'limit') {
1545
+ orderType = 'STOP LIMIT';
1546
+ request['price_aux_limit'] = this.priceToPrecision(symbol, price);
1547
+ }
1548
+ else {
1549
+ orderType = 'STOP';
1550
+ }
1551
+ }
1552
+ const ioc = (timeInForce === 'IOC');
1553
+ const fok = (timeInForce === 'FOK');
1559
1554
  const postOnly = (postOnlyParam || (timeInForce === 'PO'));
1560
1555
  if ((ioc || fok) && (price === undefined)) {
1561
1556
  throw new InvalidOrder(this.id + ' createOrder() requires a price argument with IOC and FOK orders');
1562
1557
  }
1563
- if ((ioc || fok) && exchangeMarket) {
1558
+ if ((ioc || fok) && (type === 'market')) {
1564
1559
  throw new InvalidOrder(this.id + ' createOrder() does not allow market IOC and FOK orders');
1565
1560
  }
1566
- if ((orderType !== 'MARKET') && (!exchangeMarket) && (!exchangeStop)) {
1561
+ if ((type !== 'market') && (stopPrice === undefined)) {
1567
1562
  request['price'] = this.priceToPrecision(symbol, price);
1568
1563
  }
1569
- if (stopLimit || stopMarket) {
1570
- // request['price'] is taken as stopPrice for stop orders
1571
- request['price'] = this.priceToPrecision(symbol, stopPrice);
1572
- if (stopMarket) {
1573
- request['type'] = 'EXCHANGE STOP';
1574
- }
1575
- else if (stopLimit) {
1576
- request['type'] = 'EXCHANGE STOP LIMIT';
1577
- request['price_aux_limit'] = this.priceToPrecision(symbol, price);
1578
- }
1579
- }
1580
1564
  if (ioc) {
1581
- request['type'] = 'EXCHANGE IOC';
1565
+ orderType = 'IOC';
1582
1566
  }
1583
1567
  else if (fok) {
1584
- request['type'] = 'EXCHANGE FOK';
1568
+ orderType = 'FOK';
1569
+ }
1570
+ let marginMode = undefined;
1571
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
1572
+ if (market['spot'] && (marginMode === undefined)) {
1573
+ // The EXCHANGE prefix is only required for non margin spot markets
1574
+ orderType = 'EXCHANGE ' + orderType;
1585
1575
  }
1576
+ request['type'] = orderType;
1586
1577
  // flag values may be summed to combine flags
1587
1578
  let flags = 0;
1588
1579
  if (postOnly) {
@@ -1596,7 +1587,6 @@ export default class bitfinex2 extends Exchange {
1596
1587
  }
1597
1588
  if (clientOrderId !== undefined) {
1598
1589
  request['cid'] = clientOrderId;
1599
- params = this.omit(params, ['cid', 'clientOrderId']);
1600
1590
  }
1601
1591
  const response = await this.privatePostAuthWOrderSubmit(this.extend(request, params));
1602
1592
  //
@@ -1652,8 +1642,8 @@ export default class bitfinex2 extends Exchange {
1652
1642
  const errorText = response[7];
1653
1643
  throw new ExchangeError(this.id + ' ' + response[6] + ': ' + errorText + ' (#' + errorCode + ')');
1654
1644
  }
1655
- const orders = this.safeValue(response, 4, []);
1656
- const order = this.safeValue(orders, 0);
1645
+ const orders = this.safeList(response, 4, []);
1646
+ const order = this.safeList(orders, 0);
1657
1647
  return this.parseOrder(order, market);
1658
1648
  }
1659
1649
  async cancelAllOrders(symbol = undefined, params = {}) {
@@ -2401,7 +2391,7 @@ export default class bitfinex2 extends Exchange {
2401
2391
  request['payment_id'] = tag;
2402
2392
  }
2403
2393
  const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
2404
- const includeFee = this.safeValue(withdrawOptions, 'includeFee', false);
2394
+ const includeFee = this.safeBool(withdrawOptions, 'includeFee', false);
2405
2395
  if (includeFee) {
2406
2396
  request['fee_deduct'] = 1;
2407
2397
  }
package/js/src/bitget.js CHANGED
@@ -69,6 +69,7 @@ export default class bitget extends Exchange {
69
69
  'fetchCrossBorrowRate': true,
70
70
  'fetchCrossBorrowRates': false,
71
71
  'fetchCurrencies': true,
72
+ 'fetchDeposit': false,
72
73
  'fetchDepositAddress': true,
73
74
  'fetchDepositAddresses': false,
74
75
  'fetchDeposits': true,
@@ -98,6 +99,7 @@ export default class bitget extends Exchange {
98
99
  'fetchOpenOrders': true,
99
100
  'fetchOrder': true,
100
101
  'fetchOrderBook': true,
102
+ 'fetchOrderBooks': false,
101
103
  'fetchOrders': false,
102
104
  'fetchOrderTrades': false,
103
105
  'fetchPosition': true,
@@ -105,6 +107,7 @@ export default class bitget extends Exchange {
105
107
  'fetchPositions': true,
106
108
  'fetchPositionsRisk': false,
107
109
  'fetchPremiumIndexOHLCV': false,
110
+ 'fetchStatus': false,
108
111
  'fetchTicker': true,
109
112
  'fetchTickers': true,
110
113
  'fetchTime': true,
@@ -121,6 +124,7 @@ export default class bitget extends Exchange {
121
124
  'repayCrossMargin': true,
122
125
  'repayIsolatedMargin': true,
123
126
  'setLeverage': true,
127
+ 'setMargin': false,
124
128
  'setMarginMode': true,
125
129
  'setPositionMode': true,
126
130
  'signIn': false,
@@ -2238,7 +2242,7 @@ export default class bitget extends Exchange {
2238
2242
  'fee': undefined,
2239
2243
  };
2240
2244
  const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
2241
- const fillResponseFromRequest = this.safeValue(withdrawOptions, 'fillResponseFromRequest', true);
2245
+ const fillResponseFromRequest = this.safeBool(withdrawOptions, 'fillResponseFromRequest', true);
2242
2246
  if (fillResponseFromRequest) {
2243
2247
  result['currency'] = code;
2244
2248
  result['timestamp'] = this.milliseconds();
@@ -3123,7 +3127,7 @@ export default class bitget extends Exchange {
3123
3127
  [marginMode, params] = this.handleMarginModeAndParams('fetchTradingFees', params);
3124
3128
  [marketType, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
3125
3129
  if (marketType === 'spot') {
3126
- const margin = this.safeValue(params, 'margin', false);
3130
+ const margin = this.safeBool(params, 'margin', false);
3127
3131
  params = this.omit(params, 'margin');
3128
3132
  if ((marginMode !== undefined) || margin) {
3129
3133
  response = await this.publicMarginGetV2MarginCurrencies(params);
@@ -4144,7 +4148,7 @@ export default class bitget extends Exchange {
4144
4148
  request['price'] = this.priceToPrecision(symbol, price);
4145
4149
  }
4146
4150
  const triggerType = this.safeString(params, 'triggerType', 'mark_price');
4147
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
4151
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
4148
4152
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
4149
4153
  const exchangeSpecificTifParam = this.safeString2(params, 'force', 'timeInForce');
4150
4154
  let postOnly = undefined;
@@ -4240,7 +4244,7 @@ export default class bitget extends Exchange {
4240
4244
  }
4241
4245
  const marginModeRequest = (marginMode === 'cross') ? 'crossed' : 'isolated';
4242
4246
  request['marginMode'] = marginModeRequest;
4243
- const oneWayMode = this.safeValue(params, 'oneWayMode', false);
4247
+ const oneWayMode = this.safeBool(params, 'oneWayMode', false);
4244
4248
  params = this.omit(params, 'oneWayMode');
4245
4249
  let requestSide = side;
4246
4250
  if (reduceOnly) {
package/js/src/bitmart.js CHANGED
@@ -1939,7 +1939,7 @@ export default class bitmart extends Exchange {
1939
1939
  let marketType = undefined;
1940
1940
  [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1941
1941
  const marginMode = this.safeString(params, 'marginMode');
1942
- const isMargin = this.safeValue(params, 'margin', false);
1942
+ const isMargin = this.safeBool(params, 'margin', false);
1943
1943
  params = this.omit(params, ['margin', 'marginMode']);
1944
1944
  if (marginMode !== undefined || isMargin) {
1945
1945
  marketType = 'margin';
@@ -2813,7 +2813,7 @@ export default class bitmart extends Exchange {
2813
2813
  response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
2814
2814
  }
2815
2815
  else {
2816
- const trailing = this.safeValue(params, 'trailing', false);
2816
+ const trailing = this.safeBool(params, 'trailing', false);
2817
2817
  let orderType = this.safeString(params, 'orderType');
2818
2818
  params = this.omit(params, ['orderType', 'trailing']);
2819
2819
  if (trailing) {
@@ -2993,7 +2993,7 @@ export default class bitmart extends Exchange {
2993
2993
  if (symbol === undefined) {
2994
2994
  throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
2995
2995
  }
2996
- const trailing = this.safeValue(params, 'trailing', false);
2996
+ const trailing = this.safeBool(params, 'trailing', false);
2997
2997
  let orderType = this.safeString(params, 'orderType');
2998
2998
  params = this.omit(params, ['orderType', 'trailing']);
2999
2999
  if (trailing) {
package/js/src/bitmex.js CHANGED
@@ -342,8 +342,8 @@ export default class bitmex extends Exchange {
342
342
  const network = this.networkIdToCode(networkId);
343
343
  const withdrawalFeeRaw = this.safeString(chain, 'withdrawalFee');
344
344
  const withdrawalFee = this.parseNumber(Precise.stringMul(withdrawalFeeRaw, precisionString));
345
- const isDepositEnabled = this.safeValue(chain, 'depositEnabled', false);
346
- const isWithdrawEnabled = this.safeValue(chain, 'withdrawalEnabled', false);
345
+ const isDepositEnabled = this.safeBool(chain, 'depositEnabled', false);
346
+ const isWithdrawEnabled = this.safeBool(chain, 'withdrawalEnabled', false);
347
347
  const active = (isDepositEnabled && isWithdrawEnabled);
348
348
  if (isDepositEnabled) {
349
349
  depositEnabled = true;
@@ -1719,7 +1719,7 @@ export default class bitmex extends Exchange {
1719
1719
  isInverse = (defaultSubType === 'inverse');
1720
1720
  }
1721
1721
  else {
1722
- isInverse = this.safeValue(market, 'inverse', false);
1722
+ isInverse = this.safeBool(market, 'inverse', false);
1723
1723
  }
1724
1724
  if (isInverse) {
1725
1725
  cost = this.convertFromRawQuantity(symbol, qty);
@@ -2426,7 +2426,7 @@ export default class bitmex extends Exchange {
2426
2426
  const item = response[i];
2427
2427
  const marketId = this.safeString(item, 'symbol');
2428
2428
  const market = this.safeMarket(marketId);
2429
- const swap = this.safeValue(market, 'swap', false);
2429
+ const swap = this.safeBool(market, 'swap', false);
2430
2430
  if (swap) {
2431
2431
  filteredResponse.push(item);
2432
2432
  }
package/js/src/bitrue.js CHANGED
@@ -3191,7 +3191,7 @@ export default class bitrue extends Exchange {
3191
3191
  }
3192
3192
  // check success value for wapi endpoints
3193
3193
  // response in format {'msg': 'The coin does not exist.', 'success': true/false}
3194
- const success = this.safeValue(response, 'success', true);
3194
+ const success = this.safeBool(response, 'success', true);
3195
3195
  if (!success) {
3196
3196
  const messageInner = this.safeString(response, 'msg');
3197
3197
  let parsedMessage = undefined;
package/js/src/bitso.d.ts CHANGED
@@ -23,7 +23,7 @@ export default class bitso extends Exchange {
23
23
  after: number;
24
24
  status: string;
25
25
  fee: any;
26
- info: any;
26
+ info: import("./base/types.js").Dictionary<any>;
27
27
  };
28
28
  fetchMarkets(params?: {}): Promise<any[]>;
29
29
  parseBalance(response: any): Balances;
package/js/src/bitso.js CHANGED
@@ -1729,7 +1729,7 @@ export default class bitso extends Exchange {
1729
1729
  //
1730
1730
  // {"success":false,"error":{"code":104,"message":"Cannot perform request - nonce must be higher than 1520307203724237"}}
1731
1731
  //
1732
- let success = this.safeValue(response, 'success', false);
1732
+ let success = this.safeBool(response, 'success', false);
1733
1733
  if (typeof success === 'string') {
1734
1734
  if ((success === 'true') || (success === '1')) {
1735
1735
  success = true;
package/js/src/bitteam.js CHANGED
@@ -356,7 +356,7 @@ export default class bitteam extends Exchange {
356
356
  const created = this.parse8601(timeStart);
357
357
  let minCost = undefined;
358
358
  const currenciesValuedInUsd = this.safeValue(this.options, 'currenciesValuedInUsd', {});
359
- const quoteInUsd = this.safeValue(currenciesValuedInUsd, quote, false);
359
+ const quoteInUsd = this.safeBool(currenciesValuedInUsd, quote, false);
360
360
  if (quoteInUsd) {
361
361
  const settings = this.safeValue(market, 'settings', {});
362
362
  minCost = this.safeNumber(settings, 'limit_usd');
@@ -543,7 +543,7 @@ export default class bitteam extends Exchange {
543
543
  const id = this.safeString(currency, 'symbol');
544
544
  const numericId = this.safeInteger(currency, 'id');
545
545
  const code = this.safeCurrencyCode(id);
546
- const active = this.safeValue(currency, 'active', false);
546
+ const active = this.safeBool(currency, 'active', false);
547
547
  const precision = this.safeInteger(currency, 'precision');
548
548
  const txLimits = this.safeValue(currency, 'txLimits', {});
549
549
  const minWithdraw = this.safeString(txLimits, 'minWithdraw');
@@ -680,7 +680,7 @@ export default class btcalpha extends Exchange {
680
680
  const marketId = this.safeString(order, 'pair');
681
681
  market = this.safeMarket(marketId, market, '_');
682
682
  const symbol = market['symbol'];
683
- const success = this.safeValue(order, 'success', false);
683
+ const success = this.safeBool(order, 'success', false);
684
684
  let timestamp = undefined;
685
685
  if (success) {
686
686
  timestamp = this.safeTimestamp(order, 'date');
package/js/src/bybit.js CHANGED
@@ -299,8 +299,6 @@ export default class bybit extends Exchange {
299
299
  // account
300
300
  'v5/account/wallet-balance': 1,
301
301
  'v5/account/borrow-history': 1,
302
- 'v5/account/set-collateral-switch': 5,
303
- 'v5/account/set-collateral-switch-batch': 5,
304
302
  'v5/account/collateral-info': 1,
305
303
  'v5/asset/coin-greeks': 1,
306
304
  'v5/account/fee-rate': 10,
@@ -493,6 +491,8 @@ export default class bybit extends Exchange {
493
491
  'v5/lending/purchase': 5,
494
492
  'v5/lending/redeem': 5,
495
493
  'v5/lending/redeem-cancel': 5,
494
+ 'v5/account/set-collateral-switch': 5,
495
+ 'v5/account/set-collateral-switch-batch': 5,
496
496
  },
497
497
  },
498
498
  },
@@ -3462,7 +3462,7 @@ export default class bybit extends Exchange {
3462
3462
  const result = await this.fetchOrders(symbol, undefined, undefined, this.extend(request, params));
3463
3463
  const length = result.length;
3464
3464
  if (length === 0) {
3465
- const isTrigger = this.safeValueN(params, ['trigger', 'stop'], false);
3465
+ const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
3466
3466
  const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
3467
3467
  throw new OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
3468
3468
  }
@@ -1364,7 +1364,11 @@ export default class coinbase extends Exchange {
1364
1364
  async fetchTickersV3(symbols = undefined, params = {}) {
1365
1365
  await this.loadMarkets();
1366
1366
  symbols = this.marketSymbols(symbols);
1367
- const response = await this.v3PrivateGetBrokerageProducts(params);
1367
+ const request = {};
1368
+ if (symbols !== undefined) {
1369
+ request['product_ids'] = this.marketIds(symbols);
1370
+ }
1371
+ const response = await this.v3PrivateGetBrokerageProducts(this.extend(request, params));
1368
1372
  //
1369
1373
  // {
1370
1374
  // "products": [
@@ -1682,7 +1686,7 @@ export default class coinbase extends Exchange {
1682
1686
  'limit': 250,
1683
1687
  };
1684
1688
  let response = undefined;
1685
- const isV3 = this.safeValue(params, 'v3', false);
1689
+ const isV3 = this.safeBool(params, 'v3', false);
1686
1690
  params = this.omit(params, 'v3');
1687
1691
  const method = this.safeString(this.options, 'fetchBalance', 'v3PrivateGetBrokerageAccounts');
1688
1692
  if ((isV3) || (method === 'v3PrivateGetBrokerageAccounts')) {
@@ -3198,8 +3202,11 @@ export default class coinbase extends Exchange {
3198
3202
  */
3199
3203
  await this.loadMarkets();
3200
3204
  symbols = this.marketSymbols(symbols);
3201
- // the 'product_ids' param isn't working properly and returns {"pricebooks":[]} when defined
3202
- const response = await this.v3PrivateGetBrokerageBestBidAsk(params);
3205
+ const request = {};
3206
+ if (symbols !== undefined) {
3207
+ request['product_ids'] = this.marketIds(symbols);
3208
+ }
3209
+ const response = await this.v3PrivateGetBrokerageBestBidAsk(this.extend(request, params));
3203
3210
  //
3204
3211
  // {
3205
3212
  // "pricebooks": [
@@ -3328,7 +3335,7 @@ export default class coinbase extends Exchange {
3328
3335
  const savedPath = fullPath;
3329
3336
  if (method === 'GET') {
3330
3337
  if (Object.keys(query).length) {
3331
- fullPath += '?' + this.urlencode(query);
3338
+ fullPath += '?' + this.urlencodeWithArrayRepeat(query);
3332
3339
  }
3333
3340
  }
3334
3341
  const url = this.urls['api']['rest'] + fullPath;
@@ -832,7 +832,7 @@ export default class coincheck extends Exchange {
832
832
  // {"success":false,"error":"disabled API Key"}'
833
833
  // {"success":false,"error":"invalid authentication"}
834
834
  //
835
- const success = this.safeValue(response, 'success', true);
835
+ const success = this.safeBool(response, 'success', true);
836
836
  if (!success) {
837
837
  const error = this.safeString(response, 'error');
838
838
  const feedback = this.id + ' ' + this.json(response);
package/js/src/coinex.js CHANGED
@@ -3327,7 +3327,7 @@ export default class coinex extends Exchange {
3327
3327
  const data = this.safeValue(response, 'data', {});
3328
3328
  const depositAddress = this.parseDepositAddress(data, currency);
3329
3329
  const options = this.safeValue(this.options, 'fetchDepositAddress', {});
3330
- const fillResponseFromRequest = this.safeValue(options, 'fillResponseFromRequest', true);
3330
+ const fillResponseFromRequest = this.safeBool(options, 'fillResponseFromRequest', true);
3331
3331
  if (fillResponseFromRequest) {
3332
3332
  depositAddress['network'] = this.safeNetworkCode(network, currency);
3333
3333
  }
@@ -5354,7 +5354,7 @@ export default class coinex extends Exchange {
5354
5354
  * @returns {Array} the marginMode in lowercase
5355
5355
  */
5356
5356
  const defaultType = this.safeString(this.options, 'defaultType');
5357
- const isMargin = this.safeValue(params, 'margin', false);
5357
+ const isMargin = this.safeBool(params, 'margin', false);
5358
5358
  let marginMode = undefined;
5359
5359
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
5360
5360
  if (marginMode === undefined) {
@@ -364,7 +364,7 @@ export default class coinlist extends Exchange {
364
364
  const currency = currencies[i];
365
365
  const id = this.safeString(currency, 'asset');
366
366
  const code = this.safeCurrencyCode(id);
367
- const isTransferable = this.safeValue(currency, 'is_transferable', false);
367
+ const isTransferable = this.safeBool(currency, 'is_transferable', false);
368
368
  const withdrawEnabled = isTransferable;
369
369
  const depositEnabled = isTransferable;
370
370
  const active = isTransferable;
@@ -544,7 +544,7 @@ export default class coinmate extends Exchange {
544
544
  //
545
545
  const data = this.safeValue(response, 'data');
546
546
  const transaction = this.parseTransaction(data, currency);
547
- const fillResponseFromRequest = this.safeValue(withdrawOptions, 'fillResponseFromRequest', true);
547
+ const fillResponseFromRequest = this.safeBool(withdrawOptions, 'fillResponseFromRequest', true);
548
548
  if (fillResponseFromRequest) {
549
549
  transaction['amount'] = amount;
550
550
  transaction['currency'] = code;
@@ -45,7 +45,7 @@ export default class coinmetro extends Exchange {
45
45
  after: number;
46
46
  status: string;
47
47
  fee: any;
48
- info: any;
48
+ info: import("./base/types.js").Dictionary<any>;
49
49
  };
50
50
  parseLedgerEntryDescription(description: any): any[];
51
51
  parseLedgerEntryType(type: any): string;
@@ -380,7 +380,7 @@ export default class coinmetro extends Exchange {
380
380
  const quote = this.safeCurrencyCode(quoteId);
381
381
  const basePrecisionAndLimits = this.parseMarketPrecisionAndLimits(baseId);
382
382
  const quotePrecisionAndLimits = this.parseMarketPrecisionAndLimits(quoteId);
383
- const margin = this.safeValue(market, 'margin', false);
383
+ const margin = this.safeBool(market, 'margin', false);
384
384
  const tradingFees = this.safeValue(this.fees, 'trading', {});
385
385
  return this.safeMarketStructure({
386
386
  'id': id,
@@ -1339,7 +1339,7 @@ export default class coinmetro extends Exchange {
1339
1339
  };
1340
1340
  const marginMode = undefined;
1341
1341
  [params, params] = this.handleMarginModeAndParams('cancelOrder', params);
1342
- const isMargin = this.safeValue(params, 'margin', false);
1342
+ const isMargin = this.safeBool(params, 'margin', false);
1343
1343
  params = this.omit(params, 'margin');
1344
1344
  let response = undefined;
1345
1345
  if (isMargin || (marginMode !== undefined)) {
package/js/src/coinsph.js CHANGED
@@ -1562,7 +1562,7 @@ export default class coinsph extends Exchange {
1562
1562
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1563
1563
  */
1564
1564
  const options = this.safeValue(this.options, 'withdraw');
1565
- const warning = this.safeValue(options, 'warning', true);
1565
+ const warning = this.safeBool(options, 'warning', true);
1566
1566
  if (warning) {
1567
1567
  throw new InvalidAddress(this.id + " withdraw() makes a withdrawals only to coins_ph account, add .options['withdraw']['warning'] = false to make a withdrawal to your coins_ph account");
1568
1568
  }
@@ -1057,7 +1057,7 @@ export default class cryptocom extends Exchange {
1057
1057
  request['time_in_force'] = timeInForce;
1058
1058
  }
1059
1059
  }
1060
- const postOnly = this.safeValue(params, 'postOnly', false);
1060
+ const postOnly = this.safeBool(params, 'postOnly', false);
1061
1061
  if ((postOnly) || (timeInForce === 'PO')) {
1062
1062
  request['exec_inst'] = ['POST_ONLY'];
1063
1063
  request['time_in_force'] = 'GOOD_TILL_CANCEL';
@@ -1278,7 +1278,7 @@ export default class cryptocom extends Exchange {
1278
1278
  request['time_in_force'] = timeInForce;
1279
1279
  }
1280
1280
  }
1281
- const postOnly = this.safeValue(params, 'postOnly', false);
1281
+ const postOnly = this.safeBool(params, 'postOnly', false);
1282
1282
  if ((postOnly) || (timeInForce === 'PO')) {
1283
1283
  request['exec_inst'] = ['POST_ONLY'];
1284
1284
  request['time_in_force'] = 'GOOD_TILL_CANCEL';
@@ -2249,7 +2249,7 @@ export default class cryptocom extends Exchange {
2249
2249
  * @returns {Array} the marginMode in lowercase
2250
2250
  */
2251
2251
  const defaultType = this.safeString(this.options, 'defaultType');
2252
- const isMargin = this.safeValue(params, 'margin', false);
2252
+ const isMargin = this.safeBool(params, 'margin', false);
2253
2253
  params = this.omit(params, 'margin');
2254
2254
  let marginMode = undefined;
2255
2255
  [marginMode, params] = this.handleMarginModeAndParams(methodName, params);
@@ -1162,9 +1162,11 @@ export default class digifinex extends Exchange {
1162
1162
  // "timestamp": 1663221614998
1163
1163
  // }
1164
1164
  //
1165
+ const indexPrice = this.safeNumber(ticker, 'index_price');
1166
+ const marketType = (indexPrice !== undefined) ? 'contract' : 'spot';
1165
1167
  const marketId = this.safeStringUpper2(ticker, 'symbol', 'instrument_id');
1166
- const symbol = this.safeSymbol(marketId, market);
1167
- market = this.safeMarket(marketId);
1168
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
1169
+ market = this.safeMarket(marketId, market, undefined, marketType);
1168
1170
  let timestamp = this.safeTimestamp(ticker, 'date');
1169
1171
  if (market['swap']) {
1170
1172
  timestamp = this.safeInteger(ticker, 'timestamp');
@@ -1751,7 +1753,7 @@ export default class digifinex extends Exchange {
1751
1753
  let postOnly = this.isPostOnly(isMarketOrder, false, params);
1752
1754
  let postOnlyParsed = undefined;
1753
1755
  if (swap) {
1754
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
1756
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
1755
1757
  const timeInForce = this.safeString(params, 'timeInForce');
1756
1758
  let orderType = undefined;
1757
1759
  if (side === 'buy') {
@@ -3951,7 +3953,7 @@ export default class digifinex extends Exchange {
3951
3953
  * @returns {Array} the marginMode in lowercase
3952
3954
  */
3953
3955
  const defaultType = this.safeString(this.options, 'defaultType');
3954
- const isMargin = this.safeValue(params, 'margin', false);
3956
+ const isMargin = this.safeBool(params, 'margin', false);
3955
3957
  let marginMode = undefined;
3956
3958
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
3957
3959
  if (marginMode !== undefined) {
package/js/src/exmo.js CHANGED
@@ -252,7 +252,7 @@ export default class exmo extends Exchange {
252
252
  //
253
253
  const margin = this.parseMarginModification(response, market);
254
254
  const options = this.safeValue(this.options, 'margin', {});
255
- const fillResponseFromRequest = this.safeValue(options, 'fillResponseFromRequest', true);
255
+ const fillResponseFromRequest = this.safeBool(options, 'fillResponseFromRequest', true);
256
256
  if (fillResponseFromRequest) {
257
257
  margin['type'] = type;
258
258
  margin['amount'] = amount;
@@ -2616,7 +2616,7 @@ export default class exmo extends Exchange {
2616
2616
  // {"result":false,"error":"Error 50052: Insufficient funds"}
2617
2617
  // {"s":"error","errmsg":"strconv.ParseInt: parsing \"\": invalid syntax"}
2618
2618
  //
2619
- let success = this.safeValue(response, 'result', false);
2619
+ let success = this.safeBool(response, 'result', false);
2620
2620
  if (typeof success === 'string') {
2621
2621
  if ((success === 'true') || (success === '1')) {
2622
2622
  success = true;