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/gate.js CHANGED
@@ -1592,9 +1592,9 @@ export default class gate extends Exchange {
1592
1592
  const networkId = this.safeString(entry, 'chain');
1593
1593
  const networkCode = this.networkIdToCode(networkId, code);
1594
1594
  const delisted = this.safeValue(entry, 'delisted');
1595
- const withdrawDisabled = this.safeValue(entry, 'withdraw_disabled', false);
1596
- const depositDisabled = this.safeValue(entry, 'deposit_disabled', false);
1597
- const tradeDisabled = this.safeValue(entry, 'trade_disabled', false);
1595
+ const withdrawDisabled = this.safeBool(entry, 'withdraw_disabled', false);
1596
+ const depositDisabled = this.safeBool(entry, 'deposit_disabled', false);
1597
+ const tradeDisabled = this.safeBool(entry, 'trade_disabled', false);
1598
1598
  const withdrawEnabled = !withdrawDisabled;
1599
1599
  const depositEnabled = !depositDisabled;
1600
1600
  const tradeEnabled = !tradeDisabled;
@@ -4051,7 +4051,7 @@ export default class gate extends Exchange {
4051
4051
  }
4052
4052
  }
4053
4053
  let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
4054
- const textIsRequired = this.safeValue(params, 'textIsRequired', false);
4054
+ const textIsRequired = this.safeBool(params, 'textIsRequired', false);
4055
4055
  if (clientOrderId !== undefined) {
4056
4056
  // user-defined, must follow the rules if not empty
4057
4057
  // prefixed with t-
@@ -4423,7 +4423,7 @@ export default class gate extends Exchange {
4423
4423
  // "message": "Not enough balance"
4424
4424
  // }
4425
4425
  //
4426
- const succeeded = this.safeValue(order, 'succeeded', true);
4426
+ const succeeded = this.safeBool(order, 'succeeded', true);
4427
4427
  if (!succeeded) {
4428
4428
  // cancelOrders response
4429
4429
  return this.safeOrder({
@@ -10,7 +10,7 @@ export default class gemini extends Exchange {
10
10
  fetchCurrenciesFromWeb(params?: {}): Promise<{}>;
11
11
  fetchMarkets(params?: {}): Promise<any>;
12
12
  fetchMarketsFromWeb(params?: {}): Promise<any[]>;
13
- parseMarketActive(status: any): any;
13
+ parseMarketActive(status: any): boolean;
14
14
  fetchUSDTMarkets(params?: {}): Promise<any[]>;
15
15
  fetchMarketsFromAPI(params?: {}): Promise<unknown[]>;
16
16
  parseMarket(response: any): Market;
package/js/src/gemini.js CHANGED
@@ -515,7 +515,7 @@ export default class gemini extends Exchange {
515
515
  'post_only': true,
516
516
  'limit_only': true,
517
517
  };
518
- return this.safeValue(statuses, status, true);
518
+ return this.safeBool(statuses, status, true);
519
519
  }
520
520
  async fetchUSDTMarkets(params = {}) {
521
521
  // these markets can't be scrapped and fetchMarketsFrom api does an extra call
@@ -554,7 +554,7 @@ export default class gemini extends Exchange {
554
554
  result[marketId] = this.parseMarket(market);
555
555
  }
556
556
  const options = this.safeValue(this.options, 'fetchMarketsFromAPI', {});
557
- const fetchDetailsForAllSymbols = this.safeValue(options, 'fetchDetailsForAllSymbols', false);
557
+ const fetchDetailsForAllSymbols = this.safeBool(options, 'fetchDetailsForAllSymbols', false);
558
558
  const fetchDetailsForMarketIds = this.safeValue(options, 'fetchDetailsForMarketIds', []);
559
559
  let promises = [];
560
560
  let marketIds = [];
@@ -1371,7 +1371,7 @@ export default class gemini extends Exchange {
1371
1371
  request['options'] = ['maker-or-cancel'];
1372
1372
  }
1373
1373
  }
1374
- const postOnly = this.safeValue(params, 'postOnly', false);
1374
+ const postOnly = this.safeBool(params, 'postOnly', false);
1375
1375
  params = this.omit(params, 'postOnly');
1376
1376
  if (postOnly) {
1377
1377
  request['options'] = ['maker-or-cancel'];
package/js/src/hitbtc.js CHANGED
@@ -693,7 +693,7 @@ export default class hitbtc extends Exchange {
693
693
  const expiry = this.safeInteger(market, 'expiry');
694
694
  const contract = (marketType === 'futures');
695
695
  const spot = (marketType === 'spot');
696
- const marginTrading = this.safeValue(market, 'margin_trading', false);
696
+ const marginTrading = this.safeBool(market, 'margin_trading', false);
697
697
  const margin = spot && marginTrading;
698
698
  const future = (expiry !== undefined);
699
699
  const swap = (contract && !future);
@@ -828,9 +828,9 @@ export default class hitbtc extends Exchange {
828
828
  const entry = response[currencyId];
829
829
  const name = this.safeString(entry, 'full_name');
830
830
  const precision = this.safeNumber(entry, 'precision_transfer');
831
- const payinEnabled = this.safeValue(entry, 'payin_enabled', false);
832
- const payoutEnabled = this.safeValue(entry, 'payout_enabled', false);
833
- const transferEnabled = this.safeValue(entry, 'transfer_enabled', false);
831
+ const payinEnabled = this.safeBool(entry, 'payin_enabled', false);
832
+ const payoutEnabled = this.safeBool(entry, 'payout_enabled', false);
833
+ const transferEnabled = this.safeBool(entry, 'transfer_enabled', false);
834
834
  const active = payinEnabled && payoutEnabled && transferEnabled;
835
835
  const rawNetworks = this.safeValue(entry, 'networks', []);
836
836
  const networks = {};
@@ -843,8 +843,8 @@ export default class hitbtc extends Exchange {
843
843
  const network = this.safeNetwork(networkId);
844
844
  fee = this.safeNumber(rawNetwork, 'payout_fee');
845
845
  const networkPrecision = this.safeNumber(rawNetwork, 'precision_payout');
846
- const payinEnabledNetwork = this.safeValue(entry, 'payin_enabled', false);
847
- const payoutEnabledNetwork = this.safeValue(entry, 'payout_enabled', false);
846
+ const payinEnabledNetwork = this.safeBool(entry, 'payin_enabled', false);
847
+ const payoutEnabledNetwork = this.safeBool(entry, 'payout_enabled', false);
848
848
  const activeNetwork = payinEnabledNetwork && payoutEnabledNetwork;
849
849
  if (payinEnabledNetwork && !depositEnabled) {
850
850
  depositEnabled = true;
@@ -2708,7 +2708,7 @@ export default class hitbtc extends Exchange {
2708
2708
  params = this.omit(params, 'network');
2709
2709
  }
2710
2710
  const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
2711
- const includeFee = this.safeValue(withdrawOptions, 'includeFee', false);
2711
+ const includeFee = this.safeBool(withdrawOptions, 'includeFee', false);
2712
2712
  if (includeFee) {
2713
2713
  request['include_fee'] = true;
2714
2714
  }
@@ -3230,7 +3230,7 @@ export default class hitbtc extends Exchange {
3230
3230
  await this.loadMarkets();
3231
3231
  const market = this.market(symbol);
3232
3232
  const leverage = this.safeString(params, 'leverage');
3233
- if (market['type'] === 'swap') {
3233
+ if (market['swap']) {
3234
3234
  if (leverage === undefined) {
3235
3235
  throw new ArgumentsRequired(this.id + ' modifyMarginHelper() requires a leverage parameter for swap markets');
3236
3236
  }
@@ -3254,21 +3254,15 @@ export default class hitbtc extends Exchange {
3254
3254
  let marginMode = undefined;
3255
3255
  [marketType, params] = this.handleMarketTypeAndParams('modifyMarginHelper', market, params);
3256
3256
  [marginMode, params] = this.handleMarginModeAndParams('modifyMarginHelper', params);
3257
- params = this.omit(params, ['marginMode', 'margin']);
3258
3257
  let response = undefined;
3259
- if (marginMode !== undefined) {
3258
+ if (marketType === 'swap') {
3259
+ response = await this.privatePutFuturesAccountIsolatedSymbol(this.extend(request, params));
3260
+ }
3261
+ else if ((marketType === 'margin') || (marketType === 'spot') || (marginMode === 'isolated')) {
3260
3262
  response = await this.privatePutMarginAccountIsolatedSymbol(this.extend(request, params));
3261
3263
  }
3262
3264
  else {
3263
- if (marketType === 'swap') {
3264
- response = await this.privatePutFuturesAccountIsolatedSymbol(this.extend(request, params));
3265
- }
3266
- else if (marketType === 'margin') {
3267
- response = await this.privatePutMarginAccountIsolatedSymbol(this.extend(request, params));
3268
- }
3269
- else {
3270
- throw new NotSupported(this.id + ' modifyMarginHelper() not support this market type');
3271
- }
3265
+ throw new NotSupported(this.id + ' modifyMarginHelper() not support this market type');
3272
3266
  }
3273
3267
  //
3274
3268
  // {
@@ -3580,7 +3574,7 @@ export default class hitbtc extends Exchange {
3580
3574
  * @returns {Array} the marginMode in lowercase
3581
3575
  */
3582
3576
  const defaultType = this.safeString(this.options, 'defaultType');
3583
- const isMargin = this.safeValue(params, 'margin', false);
3577
+ const isMargin = this.safeBool(params, 'margin', false);
3584
3578
  let marginMode = undefined;
3585
3579
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
3586
3580
  if (marginMode === undefined) {
package/js/src/hollaex.js CHANGED
@@ -1094,7 +1094,7 @@ export default class hollaex extends Exchange {
1094
1094
  const filled = this.safeString(order, 'filled');
1095
1095
  const status = this.parseOrderStatus(this.safeString(order, 'status'));
1096
1096
  const meta = this.safeValue(order, 'meta', {});
1097
- const postOnly = this.safeValue(meta, 'post_only', false);
1097
+ const postOnly = this.safeBool(meta, 'post_only', false);
1098
1098
  return this.safeOrder({
1099
1099
  'id': id,
1100
1100
  'clientOrderId': undefined,
@@ -1148,7 +1148,7 @@ export default class hollaex extends Exchange {
1148
1148
  };
1149
1149
  const stopPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop']);
1150
1150
  const meta = this.safeValue(params, 'meta', {});
1151
- const exchangeSpecificParam = this.safeValue(meta, 'post_only', false);
1151
+ const exchangeSpecificParam = this.safeBool(meta, 'post_only', false);
1152
1152
  const isMarketOrder = type === 'market';
1153
1153
  const postOnly = this.isPostOnly(isMarketOrder, exchangeSpecificParam, params);
1154
1154
  if (!isMarketOrder) {
package/js/src/htx.js CHANGED
@@ -3984,7 +3984,7 @@ export default class htx extends Exchange {
3984
3984
  let response = undefined;
3985
3985
  const stop = this.safeValue(params, 'stop');
3986
3986
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
3987
- const trailing = this.safeValue(params, 'trailing', false);
3987
+ const trailing = this.safeBool(params, 'trailing', false);
3988
3988
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
3989
3989
  if (stop || stopLossTakeProfit || trailing) {
3990
3990
  if (limit !== undefined) {
@@ -4359,7 +4359,7 @@ export default class htx extends Exchange {
4359
4359
  request['contract_code'] = market['id'];
4360
4360
  const stop = this.safeValue(params, 'stop');
4361
4361
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
4362
- const trailing = this.safeValue(params, 'trailing', false);
4362
+ const trailing = this.safeBool(params, 'trailing', false);
4363
4363
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
4364
4364
  if (market['linear']) {
4365
4365
  let marginMode = undefined;
@@ -5738,7 +5738,7 @@ export default class htx extends Exchange {
5738
5738
  }
5739
5739
  const stop = this.safeValue(params, 'stop');
5740
5740
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
5741
- const trailing = this.safeValue(params, 'trailing', false);
5741
+ const trailing = this.safeBool(params, 'trailing', false);
5742
5742
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
5743
5743
  if (market['linear']) {
5744
5744
  let marginMode = undefined;
@@ -6063,7 +6063,7 @@ export default class htx extends Exchange {
6063
6063
  request['contract_code'] = market['id'];
6064
6064
  const stop = this.safeValue(params, 'stop');
6065
6065
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
6066
- const trailing = this.safeValue(params, 'trailing', false);
6066
+ const trailing = this.safeBool(params, 'trailing', false);
6067
6067
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
6068
6068
  if (market['linear']) {
6069
6069
  let marginMode = undefined;
@@ -6529,7 +6529,7 @@ export default class htx extends Exchange {
6529
6529
  }
6530
6530
  amount = parseFloat(this.currencyToPrecision(code, amount, networkCode));
6531
6531
  const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
6532
- if (this.safeValue(withdrawOptions, 'includeFee', false)) {
6532
+ if (this.safeBool(withdrawOptions, 'includeFee', false)) {
6533
6533
  let fee = this.safeNumber(params, 'fee');
6534
6534
  if (fee === undefined) {
6535
6535
  const currencies = await this.fetchCurrencies();
package/js/src/huobijp.js CHANGED
@@ -1046,7 +1046,7 @@ export default class huobijp extends Exchange {
1046
1046
  const depositEnabled = this.safeValue(currency, 'deposit-enabled');
1047
1047
  const withdrawEnabled = this.safeValue(currency, 'withdraw-enabled');
1048
1048
  const countryDisabled = this.safeValue(currency, 'country-disabled');
1049
- const visible = this.safeValue(currency, 'visible', false);
1049
+ const visible = this.safeBool(currency, 'visible', false);
1050
1050
  const state = this.safeString(currency, 'state');
1051
1051
  const active = visible && depositEnabled && withdrawEnabled && (state === 'online') && !countryDisabled;
1052
1052
  const name = this.safeString(currency, 'display-name');
@@ -548,7 +548,7 @@ export default class krakenfutures extends Exchange {
548
548
  const volume = this.safeString(ticker, 'vol24h');
549
549
  let baseVolume = undefined;
550
550
  let quoteVolume = undefined;
551
- const isIndex = this.safeValue(market, 'index', false);
551
+ const isIndex = this.safeBool(market, 'index', false);
552
552
  if (!isIndex) {
553
553
  if (market['linear']) {
554
554
  baseVolume = volume;
package/js/src/kucoin.js CHANGED
@@ -943,7 +943,7 @@ export default class kucoin extends Exchange {
943
943
  //
944
944
  const data = this.safeValue(response, 'data');
945
945
  const options = this.safeValue(this.options, 'fetchMarkets', {});
946
- const fetchTickersFees = this.safeValue(options, 'fetchTickersFees', true);
946
+ const fetchTickersFees = this.safeBool(options, 'fetchTickersFees', true);
947
947
  let tickersResponse = {};
948
948
  if (fetchTickersFees) {
949
949
  tickersResponse = await this.publicGetMarketAllTickers(params);
@@ -1151,14 +1151,14 @@ export default class kucoin extends Exchange {
1151
1151
  const chain = chains[j];
1152
1152
  const chainId = this.safeString(chain, 'chainId');
1153
1153
  const networkCode = this.networkIdToCode(chainId);
1154
- const chainWithdrawEnabled = this.safeValue(chain, 'isWithdrawEnabled', false);
1154
+ const chainWithdrawEnabled = this.safeBool(chain, 'isWithdrawEnabled', false);
1155
1155
  if (isWithdrawEnabled === undefined) {
1156
1156
  isWithdrawEnabled = chainWithdrawEnabled;
1157
1157
  }
1158
1158
  else {
1159
1159
  isWithdrawEnabled = isWithdrawEnabled || chainWithdrawEnabled;
1160
1160
  }
1161
- const chainDepositEnabled = this.safeValue(chain, 'isDepositEnabled', false);
1161
+ const chainDepositEnabled = this.safeBool(chain, 'isDepositEnabled', false);
1162
1162
  if (isDepositEnabled === undefined) {
1163
1163
  isDepositEnabled = chainDepositEnabled;
1164
1164
  }
@@ -1916,9 +1916,9 @@ export default class kucoin extends Exchange {
1916
1916
  */
1917
1917
  await this.loadMarkets();
1918
1918
  const market = this.market(symbol);
1919
- const testOrder = this.safeValue(params, 'test', false);
1919
+ const testOrder = this.safeBool(params, 'test', false);
1920
1920
  params = this.omit(params, 'test');
1921
- const isHf = this.safeValue(params, 'hf', false);
1921
+ const isHf = this.safeBool(params, 'hf', false);
1922
1922
  const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
1923
1923
  const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
1924
1924
  const isTriggerOrder = (triggerPrice || stopLossPrice || takeProfitPrice);
@@ -2045,7 +2045,7 @@ export default class kucoin extends Exchange {
2045
2045
  'symbol': market['id'],
2046
2046
  'orderList': ordersRequests,
2047
2047
  };
2048
- const hf = this.safeValue(params, 'hf', false);
2048
+ const hf = this.safeBool(params, 'hf', false);
2049
2049
  params = this.omit(params, 'hf');
2050
2050
  let response = undefined;
2051
2051
  if (hf) {
@@ -2227,7 +2227,7 @@ export default class kucoin extends Exchange {
2227
2227
  const request = {};
2228
2228
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2229
2229
  const stop = this.safeValue2(params, 'stop', 'trigger', false);
2230
- const hf = this.safeValue(params, 'hf', false);
2230
+ const hf = this.safeBool(params, 'hf', false);
2231
2231
  if (hf) {
2232
2232
  if (symbol === undefined) {
2233
2233
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol parameter for hf orders');
@@ -2282,8 +2282,8 @@ export default class kucoin extends Exchange {
2282
2282
  */
2283
2283
  await this.loadMarkets();
2284
2284
  const request = {};
2285
- const stop = this.safeValue(params, 'stop', false);
2286
- const hf = this.safeValue(params, 'hf', false);
2285
+ const stop = this.safeBool(params, 'stop', false);
2286
+ const hf = this.safeBool(params, 'hf', false);
2287
2287
  params = this.omit(params, ['stop', 'hf']);
2288
2288
  const [marginMode, query] = this.handleMarginModeAndParams('cancelAllOrders', params);
2289
2289
  if (symbol !== undefined) {
@@ -2340,8 +2340,8 @@ export default class kucoin extends Exchange {
2340
2340
  await this.loadMarkets();
2341
2341
  let lowercaseStatus = status.toLowerCase();
2342
2342
  const until = this.safeInteger2(params, 'until', 'till');
2343
- const stop = this.safeValue(params, 'stop', false);
2344
- const hf = this.safeValue(params, 'hf', false);
2343
+ const stop = this.safeBool(params, 'stop', false);
2344
+ const hf = this.safeBool(params, 'hf', false);
2345
2345
  params = this.omit(params, ['stop', 'hf', 'till', 'until']);
2346
2346
  const [marginMode, query] = this.handleMarginModeAndParams('fetchOrdersByStatus', params);
2347
2347
  if (lowercaseStatus === 'open') {
@@ -2515,8 +2515,8 @@ export default class kucoin extends Exchange {
2515
2515
  await this.loadMarkets();
2516
2516
  const request = {};
2517
2517
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2518
- const stop = this.safeValue(params, 'stop', false);
2519
- const hf = this.safeValue(params, 'hf', false);
2518
+ const stop = this.safeBool(params, 'stop', false);
2519
+ const hf = this.safeBool(params, 'hf', false);
2520
2520
  let market = undefined;
2521
2521
  if (symbol !== undefined) {
2522
2522
  market = this.market(symbol);
@@ -2693,10 +2693,10 @@ export default class kucoin extends Exchange {
2693
2693
  const marketId = this.safeString(order, 'symbol');
2694
2694
  const timestamp = this.safeInteger(order, 'createdAt');
2695
2695
  const feeCurrencyId = this.safeString(order, 'feeCurrency');
2696
- const cancelExist = this.safeValue(order, 'cancelExist', false);
2696
+ const cancelExist = this.safeBool(order, 'cancelExist', false);
2697
2697
  const responseStop = this.safeString(order, 'stop');
2698
2698
  const stop = responseStop !== undefined;
2699
- const stopTriggered = this.safeValue(order, 'stopTriggered', false);
2699
+ const stopTriggered = this.safeBool(order, 'stopTriggered', false);
2700
2700
  const isActive = this.safeValue2(order, 'isActive', 'active');
2701
2701
  const responseStatus = this.safeString(order, 'status');
2702
2702
  let status = undefined;
@@ -2793,7 +2793,7 @@ export default class kucoin extends Exchange {
2793
2793
  return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
2794
2794
  }
2795
2795
  let request = {};
2796
- const hf = this.safeValue(params, 'hf', false);
2796
+ const hf = this.safeBool(params, 'hf', false);
2797
2797
  if (hf && symbol === undefined) {
2798
2798
  throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol parameter for hf orders');
2799
2799
  }
@@ -3472,7 +3472,7 @@ export default class kucoin extends Exchange {
3472
3472
  const accountsByType = this.safeValue(this.options, 'accountsByType');
3473
3473
  let type = this.safeString(accountsByType, requestedType, requestedType);
3474
3474
  params = this.omit(params, 'type');
3475
- const isHf = this.safeValue(params, 'hf', false);
3475
+ const isHf = this.safeBool(params, 'hf', false);
3476
3476
  if (isHf) {
3477
3477
  type = 'trade_hf';
3478
3478
  }
@@ -1124,7 +1124,7 @@ export default class kucoinfutures extends kucoin {
1124
1124
  */
1125
1125
  await this.loadMarkets();
1126
1126
  const market = this.market(symbol);
1127
- const testOrder = this.safeValue(params, 'test', false);
1127
+ const testOrder = this.safeBool(params, 'test', false);
1128
1128
  params = this.omit(params, 'test');
1129
1129
  const orderRequest = this.createContractOrderRequest(symbol, type, side, amount, price, params);
1130
1130
  let response = undefined;
@@ -1787,7 +1787,7 @@ export default class kucoinfutures extends kucoin {
1787
1787
  // const average = Precise.stringDiv (cost, Precise.stringMul (filled, market['contractSize']));
1788
1788
  // bool
1789
1789
  const isActive = this.safeValue(order, 'isActive');
1790
- const cancelExist = this.safeValue(order, 'cancelExist', false);
1790
+ const cancelExist = this.safeBool(order, 'cancelExist', false);
1791
1791
  let status = undefined;
1792
1792
  if (isActive !== undefined) {
1793
1793
  status = isActive ? 'open' : 'closed';
@@ -2511,7 +2511,7 @@ export default class kucoinfutures extends kucoin {
2511
2511
  await this.loadMarkets();
2512
2512
  const market = this.market(symbol);
2513
2513
  let clientOrderId = this.safeString(params, 'clientOrderId');
2514
- const testOrder = this.safeValue(params, 'test', false);
2514
+ const testOrder = this.safeBool(params, 'test', false);
2515
2515
  params = this.omit(params, ['test', 'clientOrderId']);
2516
2516
  if (clientOrderId === undefined) {
2517
2517
  clientOrderId = this.numberToString(this.nonce());
package/js/src/lbank.js CHANGED
@@ -1315,7 +1315,7 @@ export default class lbank extends Exchange {
1315
1315
  await this.loadMarkets();
1316
1316
  const market = this.market(symbol);
1317
1317
  const clientOrderId = this.safeString2(params, 'custom_id', 'clientOrderId');
1318
- const postOnly = this.safeValue(params, 'postOnly', false);
1318
+ const postOnly = this.safeBool(params, 'postOnly', false);
1319
1319
  const timeInForce = this.safeStringUpper(params, 'timeInForce');
1320
1320
  params = this.omit(params, ['custom_id', 'clientOrderId', 'timeInForce', 'postOnly']);
1321
1321
  const request = {
package/js/src/mexc.js CHANGED
@@ -958,8 +958,8 @@ export default class mexc extends Exchange {
958
958
  const chain = chains[j];
959
959
  const networkId = this.safeString(chain, 'network');
960
960
  const network = this.safeNetwork(networkId);
961
- const isDepositEnabled = this.safeValue(chain, 'depositEnable', false);
962
- const isWithdrawEnabled = this.safeValue(chain, 'withdrawEnable', false);
961
+ const isDepositEnabled = this.safeBool(chain, 'depositEnable', false);
962
+ const isWithdrawEnabled = this.safeBool(chain, 'withdrawEnable', false);
963
963
  const active = (isDepositEnabled && isWithdrawEnabled);
964
964
  currencyActive = active || currencyActive;
965
965
  const withdrawMin = this.safeString(chain, 'withdrawMin');
@@ -2218,7 +2218,7 @@ export default class mexc extends Exchange {
2218
2218
  await this.loadMarkets();
2219
2219
  const symbol = market['symbol'];
2220
2220
  const unavailableContracts = this.safeValue(this.options, 'unavailableContracts', {});
2221
- const isContractUnavaiable = this.safeValue(unavailableContracts, symbol, false);
2221
+ const isContractUnavaiable = this.safeBool(unavailableContracts, symbol, false);
2222
2222
  if (isContractUnavaiable) {
2223
2223
  throw new NotSupported(this.id + ' createSwapOrder() does not support yet this symbol:' + symbol);
2224
2224
  }
@@ -2286,7 +2286,7 @@ export default class mexc extends Exchange {
2286
2286
  throw new ArgumentsRequired(this.id + ' createSwapOrder() requires a leverage parameter for isolated margin orders');
2287
2287
  }
2288
2288
  }
2289
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
2289
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
2290
2290
  if (reduceOnly) {
2291
2291
  request['side'] = (side === 'buy') ? 2 : 4;
2292
2292
  }
@@ -3622,7 +3622,7 @@ export default class mexc extends Exchange {
3622
3622
  const request = {};
3623
3623
  [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
3624
3624
  const marginMode = this.safeString(params, 'marginMode');
3625
- const isMargin = this.safeValue(params, 'margin', false);
3625
+ const isMargin = this.safeBool(params, 'margin', false);
3626
3626
  params = this.omit(params, ['margin', 'marginMode']);
3627
3627
  let response = undefined;
3628
3628
  if ((marginMode !== undefined) || (isMargin) || (marketType === 'margin')) {
@@ -5300,7 +5300,7 @@ export default class mexc extends Exchange {
5300
5300
  * @returns {Array} the marginMode in lowercase
5301
5301
  */
5302
5302
  const defaultType = this.safeString(this.options, 'defaultType');
5303
- const isMargin = this.safeValue(params, 'margin', false);
5303
+ const isMargin = this.safeBool(params, 'margin', false);
5304
5304
  let marginMode = undefined;
5305
5305
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
5306
5306
  if ((defaultType === 'margin') || (isMargin === true)) {
@@ -5392,7 +5392,7 @@ export default class mexc extends Exchange {
5392
5392
  // {"code":10216,"msg":"No available deposit address"}
5393
5393
  // {"success":true, "code":0, "data":1634095541710}
5394
5394
  //
5395
- const success = this.safeValue(response, 'success', false); // v1
5395
+ const success = this.safeBool(response, 'success', false); // v1
5396
5396
  if (success === true) {
5397
5397
  return undefined;
5398
5398
  }
package/js/src/novadax.js CHANGED
@@ -1165,7 +1165,7 @@ export default class novadax extends Exchange {
1165
1165
  //
1166
1166
  const transfer = this.parseTransfer(response, currency);
1167
1167
  const transferOptions = this.safeValue(this.options, 'transfer', {});
1168
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
1168
+ const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
1169
1169
  if (fillResponseFromRequest) {
1170
1170
  transfer['fromAccount'] = fromAccount;
1171
1171
  transfer['toAccount'] = toAccount;
package/js/src/okcoin.js CHANGED
@@ -860,7 +860,7 @@ export default class okcoin extends Exchange {
860
860
  const symbol = market['symbol'];
861
861
  const last = this.safeString(ticker, 'last');
862
862
  const open = this.safeString(ticker, 'open24h');
863
- const spot = this.safeValue(market, 'spot', false);
863
+ const spot = this.safeBool(market, 'spot', false);
864
864
  const quoteVolume = spot ? this.safeString(ticker, 'volCcy24h') : undefined;
865
865
  const baseVolume = this.safeString(ticker, 'vol24h');
866
866
  const high = this.safeString(ticker, 'high24h');
@@ -1404,7 +1404,7 @@ export default class okcoin extends Exchange {
1404
1404
  }
1405
1405
  else {
1406
1406
  marginMode = defaultMarginMode;
1407
- margin = this.safeValue(params, 'margin', false);
1407
+ margin = this.safeBool(params, 'margin', false);
1408
1408
  }
1409
1409
  if (margin) {
1410
1410
  const defaultCurrency = (side === 'buy') ? market['quote'] : market['base'];
package/js/src/okx.js CHANGED
@@ -2141,7 +2141,8 @@ export default class okx extends Exchange {
2141
2141
  if (since < historyBorder) {
2142
2142
  defaultType = 'HistoryCandles';
2143
2143
  }
2144
- request['before'] = since;
2144
+ const startTime = Math.max(since - 1, 0);
2145
+ request['before'] = startTime;
2145
2146
  request['after'] = this.sum(since, durationInMilliseconds * limit);
2146
2147
  }
2147
2148
  const until = this.safeInteger(params, 'until');
@@ -3106,7 +3107,7 @@ export default class okx extends Exchange {
3106
3107
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
3107
3108
  }
3108
3109
  const stop = this.safeValue2(params, 'stop', 'trigger');
3109
- const trailing = this.safeValue(params, 'trailing', false);
3110
+ const trailing = this.safeBool(params, 'trailing', false);
3110
3111
  if (stop || trailing) {
3111
3112
  const orderInner = await this.cancelOrders([id], symbol, params);
3112
3113
  return this.safeValue(orderInner, 0);
@@ -3174,7 +3175,7 @@ export default class okx extends Exchange {
3174
3175
  const clientOrderIds = this.parseIds(this.safeValue2(params, 'clOrdId', 'clientOrderId'));
3175
3176
  const algoIds = this.parseIds(this.safeValue(params, 'algoId'));
3176
3177
  const stop = this.safeValue2(params, 'stop', 'trigger');
3177
- const trailing = this.safeValue(params, 'trailing', false);
3178
+ const trailing = this.safeBool(params, 'trailing', false);
3178
3179
  if (stop || trailing) {
3179
3180
  method = 'privatePostTradeCancelAlgos';
3180
3181
  }
@@ -3673,7 +3674,7 @@ export default class okx extends Exchange {
3673
3674
  let method = this.safeString(params, 'method', defaultMethod);
3674
3675
  const ordType = this.safeString(params, 'ordType');
3675
3676
  const stop = this.safeValue2(params, 'stop', 'trigger');
3676
- const trailing = this.safeValue(params, 'trailing', false);
3677
+ const trailing = this.safeBool(params, 'trailing', false);
3677
3678
  if (trailing || stop || (ordType in algoOrderTypes)) {
3678
3679
  method = 'privateGetTradeOrdersAlgoPending';
3679
3680
  }
@@ -3842,7 +3843,7 @@ export default class okx extends Exchange {
3842
3843
  let method = this.safeString(params, 'method', defaultMethod);
3843
3844
  const ordType = this.safeString(params, 'ordType');
3844
3845
  const stop = this.safeValue2(params, 'stop', 'trigger');
3845
- const trailing = this.safeValue(params, 'trailing', false);
3846
+ const trailing = this.safeBool(params, 'trailing', false);
3846
3847
  if (trailing) {
3847
3848
  method = 'privateGetTradeOrdersAlgoHistory';
3848
3849
  request['ordType'] = 'move_order_stop';
@@ -4036,7 +4037,7 @@ export default class okx extends Exchange {
4036
4037
  let method = this.safeString(params, 'method', defaultMethod);
4037
4038
  const ordType = this.safeString(params, 'ordType');
4038
4039
  const stop = this.safeValue2(params, 'stop', 'trigger');
4039
- const trailing = this.safeValue(params, 'trailing', false);
4040
+ const trailing = this.safeBool(params, 'trailing', false);
4040
4041
  if (trailing || stop || (ordType in algoOrderTypes)) {
4041
4042
  method = 'privateGetTradeOrdersAlgoHistory';
4042
4043
  request['state'] = 'effective';
package/js/src/p2b.js CHANGED
@@ -22,6 +22,7 @@ export default class p2b extends Exchange {
22
22
  'countries': ['LT'],
23
23
  'rateLimit': 100,
24
24
  'version': 'v2',
25
+ 'pro': true,
25
26
  'has': {
26
27
  'CORS': undefined,
27
28
  'spot': true,
package/js/src/phemex.js CHANGED
@@ -2420,7 +2420,7 @@ export default class phemex extends Exchange {
2420
2420
  });
2421
2421
  }
2422
2422
  parseOrder(order, market = undefined) {
2423
- const isSwap = this.safeValue(market, 'swap', false);
2423
+ const isSwap = this.safeBool(market, 'swap', false);
2424
2424
  const hasPnl = ('closedPnl' in order);
2425
2425
  if (isSwap || hasPnl) {
2426
2426
  return this.parseSwapOrder(order, market);
@@ -4332,7 +4332,7 @@ export default class phemex extends Exchange {
4332
4332
  throw new BadRequest(this.id + ' setLeverage() leverage should be between -100 and 100');
4333
4333
  }
4334
4334
  await this.loadMarkets();
4335
- const isHedged = this.safeValue(params, 'hedged', false);
4335
+ const isHedged = this.safeBool(params, 'hedged', false);
4336
4336
  const longLeverageRr = this.safeInteger(params, 'longLeverageRr');
4337
4337
  const shortLeverageRr = this.safeInteger(params, 'shortLeverageRr');
4338
4338
  const market = this.market(symbol);
@@ -4428,7 +4428,7 @@ export default class phemex extends Exchange {
4428
4428
  transfer = this.parseTransfer(response);
4429
4429
  }
4430
4430
  const transferOptions = this.safeValue(this.options, 'transfer', {});
4431
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
4431
+ const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
4432
4432
  if (fillResponseFromRequest) {
4433
4433
  if (transfer['fromAccount'] === undefined) {
4434
4434
  transfer['fromAccount'] = fromAccount;
@@ -864,7 +864,7 @@ export default class poloniexfutures extends Exchange {
864
864
  request['timeInForce'] = timeInForce;
865
865
  }
866
866
  }
867
- const postOnly = this.safeValue(params, 'postOnly', false);
867
+ const postOnly = this.safeBool(params, 'postOnly', false);
868
868
  const hidden = this.safeValue(params, 'hidden');
869
869
  if (postOnly && (hidden !== undefined)) {
870
870
  throw new BadRequest(this.id + ' createOrder() does not support the postOnly parameter together with a hidden parameter');
@@ -1555,8 +1555,8 @@ export default class poloniexfutures extends Exchange {
1555
1555
  // precision reported by their api is 8 d.p.
1556
1556
  // const average = Precise.stringDiv (rawCost, Precise.stringMul (filled, market['contractSize']));
1557
1557
  // bool
1558
- const isActive = this.safeValue(order, 'isActive', false);
1559
- const cancelExist = this.safeValue(order, 'cancelExist', false);
1558
+ const isActive = this.safeBool(order, 'isActive', false);
1559
+ const cancelExist = this.safeBool(order, 'cancelExist', false);
1560
1560
  const status = isActive ? 'open' : 'closed';
1561
1561
  let id = this.safeString(order, 'id');
1562
1562
  if ('cancelledOrderIds' in order) {
@@ -227,7 +227,7 @@ export default class alpaca extends alpacaRest {
227
227
  const symbol = this.safeSymbol(marketId);
228
228
  const datetime = this.safeString(message, 't');
229
229
  const timestamp = this.parse8601(datetime);
230
- const isSnapshot = this.safeValue(message, 'r', false);
230
+ const isSnapshot = this.safeBool(message, 'r', false);
231
231
  let orderbook = this.safeValue(this.orderbooks, symbol);
232
232
  if (orderbook === undefined) {
233
233
  orderbook = this.orderBook();
@@ -1273,7 +1273,7 @@ export default class binance extends binanceRest {
1273
1273
  return undefined;
1274
1274
  }
1275
1275
  const options = this.safeValue(this.options, 'watchBalance');
1276
- const fetchBalanceSnapshot = this.safeValue(options, 'fetchBalanceSnapshot', false);
1276
+ const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
1277
1277
  if (fetchBalanceSnapshot) {
1278
1278
  const messageHash = type + ':fetchBalanceSnapshot';
1279
1279
  if (!(messageHash in client.futures)) {
@@ -1399,8 +1399,8 @@ export default class binance extends binanceRest {
1399
1399
  this.setBalanceCache(client, type);
1400
1400
  this.setPositionsCache(client, type);
1401
1401
  const options = this.safeValue(this.options, 'watchBalance');
1402
- const fetchBalanceSnapshot = this.safeValue(options, 'fetchBalanceSnapshot', false);
1403
- const awaitBalanceSnapshot = this.safeValue(options, 'awaitBalanceSnapshot', true);
1402
+ const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
1403
+ const awaitBalanceSnapshot = this.safeBool(options, 'awaitBalanceSnapshot', true);
1404
1404
  if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
1405
1405
  await client.future(type + ':fetchBalanceSnapshot');
1406
1406
  }
@@ -1561,7 +1561,7 @@ export default class binance extends binanceRest {
1561
1561
  let returnRateLimits = false;
1562
1562
  [returnRateLimits, params] = this.handleOptionAndParams(params, 'createOrderWs', 'returnRateLimits', false);
1563
1563
  payload['returnRateLimits'] = returnRateLimits;
1564
- const test = this.safeValue(params, 'test', false);
1564
+ const test = this.safeBool(params, 'test', false);
1565
1565
  params = this.omit(params, 'test');
1566
1566
  const message = {
1567
1567
  'id': messageHash,