ccxt 4.1.88 → 4.1.90

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 (63) hide show
  1. package/CHANGELOG.md +8309 -5710
  2. package/README.md +3 -3
  3. package/changelog.js +101 -0
  4. package/dist/ccxt.browser.js +963 -387
  5. package/dist/ccxt.browser.min.js +3 -3
  6. package/dist/cjs/ccxt.js +1 -1
  7. package/dist/cjs/src/base/Exchange.js +2 -2
  8. package/dist/cjs/src/bigone.js +8 -1
  9. package/dist/cjs/src/bitforex.js +2 -0
  10. package/dist/cjs/src/bitget.js +11 -4
  11. package/dist/cjs/src/bitmex.js +2 -0
  12. package/dist/cjs/src/blockchaincom.js +0 -41
  13. package/dist/cjs/src/bybit.js +29 -14
  14. package/dist/cjs/src/coinex.js +14 -1
  15. package/dist/cjs/src/coinlist.js +2 -0
  16. package/dist/cjs/src/coinsph.js +2 -0
  17. package/dist/cjs/src/cryptocom.js +2 -0
  18. package/dist/cjs/src/gate.js +276 -11
  19. package/dist/cjs/src/htx.js +264 -219
  20. package/dist/cjs/src/kuna.js +2 -0
  21. package/dist/cjs/src/mexc.js +2 -0
  22. package/dist/cjs/src/okcoin.js +61 -17
  23. package/dist/cjs/src/phemex.js +159 -30
  24. package/dist/cjs/src/poloniex.js +28 -2
  25. package/dist/cjs/src/pro/binance.js +6 -6
  26. package/dist/cjs/src/pro/poloniex.js +15 -10
  27. package/dist/cjs/src/tokocrypto.js +30 -14
  28. package/dist/cjs/src/wazirx.js +2 -0
  29. package/dist/cjs/src/whitebit.js +2 -0
  30. package/dist/cjs/src/woo.js +41 -14
  31. package/js/ccxt.d.ts +1 -1
  32. package/js/ccxt.js +1 -1
  33. package/js/src/abstract/phemex.d.ts +1 -0
  34. package/js/src/base/Exchange.js +2 -2
  35. package/js/src/bigone.js +9 -2
  36. package/js/src/bitforex.js +2 -0
  37. package/js/src/bitget.js +11 -4
  38. package/js/src/bitmex.js +2 -0
  39. package/js/src/blockchaincom.d.ts +0 -2
  40. package/js/src/blockchaincom.js +0 -41
  41. package/js/src/bybit.js +29 -14
  42. package/js/src/coinex.js +14 -1
  43. package/js/src/coinlist.js +2 -0
  44. package/js/src/coinsph.js +2 -0
  45. package/js/src/cryptocom.js +2 -0
  46. package/js/src/gate.d.ts +47 -0
  47. package/js/src/gate.js +276 -11
  48. package/js/src/htx.js +264 -219
  49. package/js/src/kuna.js +2 -0
  50. package/js/src/mexc.js +2 -0
  51. package/js/src/okcoin.d.ts +1 -0
  52. package/js/src/okcoin.js +62 -18
  53. package/js/src/phemex.d.ts +3 -108
  54. package/js/src/phemex.js +159 -30
  55. package/js/src/poloniex.js +28 -2
  56. package/js/src/pro/binance.js +6 -6
  57. package/js/src/pro/poloniex.js +16 -11
  58. package/js/src/tokocrypto.js +30 -14
  59. package/js/src/wazirx.js +2 -0
  60. package/js/src/whitebit.js +2 -0
  61. package/js/src/woo.d.ts +1 -0
  62. package/js/src/woo.js +42 -15
  63. package/package.json +2 -2
@@ -194,6 +194,7 @@ class poloniex extends poloniex$1 {
194
194
  * @param {object} [params] extra parameters specific to the poloniex api endpoint
195
195
  * @param {string} [params.timeInForce] GTC (default), IOC, FOK
196
196
  * @param {string} [params.clientOrderId] Maximum 64-character length.*
197
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
197
198
  *
198
199
  * EXCHANGE SPECIFIC PARAMETERS
199
200
  * @param {string} [params.amount] quote units for the order
@@ -217,25 +218,29 @@ class poloniex extends poloniex$1 {
217
218
  'type': type.toUpperCase(),
218
219
  };
219
220
  if ((uppercaseType === 'MARKET') && (uppercaseSide === 'BUY')) {
220
- let quoteAmount = this.safeString(params, 'amount');
221
- if ((quoteAmount === undefined) && (this.options['createMarketBuyOrderRequiresPrice'])) {
222
- const cost = this.safeNumber(params, 'cost');
223
- params = this.omit(params, 'cost');
224
- if (price === undefined && cost === undefined) {
225
- throw new errors.ArgumentsRequired(this.id + ' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false to supply the cost in the amount argument (the exchange-specific behaviour)');
221
+ let quoteAmount = undefined;
222
+ let createMarketBuyOrderRequiresPrice = true;
223
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
224
+ const cost = this.safeNumber(params, 'cost');
225
+ params = this.omit(params, 'cost');
226
+ if (cost !== undefined) {
227
+ quoteAmount = this.costToPrecision(symbol, cost);
228
+ }
229
+ else if (createMarketBuyOrderRequiresPrice) {
230
+ if (price === undefined) {
231
+ throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
226
232
  }
227
233
  else {
228
234
  const amountString = this.numberToString(amount);
229
235
  const priceString = this.numberToString(price);
230
- const quote = Precise["default"].stringMul(amountString, priceString);
231
- amount = (cost !== undefined) ? cost : this.parseNumber(quote);
232
- quoteAmount = this.costToPrecision(symbol, amount);
236
+ const costRequest = Precise["default"].stringMul(amountString, priceString);
237
+ quoteAmount = this.costToPrecision(symbol, costRequest);
233
238
  }
234
239
  }
235
240
  else {
236
241
  quoteAmount = this.costToPrecision(symbol, amount);
237
242
  }
238
- request['amount'] = this.amountToPrecision(market['symbol'], quoteAmount);
243
+ request['amount'] = quoteAmount;
239
244
  }
240
245
  else {
241
246
  request['quantity'] = this.amountToPrecision(market['symbol'], amount);
@@ -35,6 +35,9 @@ class tokocrypto extends tokocrypto$1 {
35
35
  'cancelOrder': true,
36
36
  'cancelOrders': undefined,
37
37
  'createDepositAddress': false,
38
+ 'createMarketBuyOrderWithCost': true,
39
+ 'createMarketOrderWithCost': false,
40
+ 'createMarketSellOrderWithCost': false,
38
41
  'createOrder': true,
39
42
  'createReduceOnlyOrder': undefined,
40
43
  'createStopLimitOrder': true,
@@ -102,6 +105,8 @@ class tokocrypto extends tokocrypto$1 {
102
105
  'fetchWithdrawals': true,
103
106
  'fetchWithdrawalWhitelist': false,
104
107
  'reduceMargin': false,
108
+ 'repayCrossMargin': false,
109
+ 'repayIsolatedMargin': false,
105
110
  'setLeverage': false,
106
111
  'setMargin': false,
107
112
  'setMarginMode': false,
@@ -1577,6 +1582,7 @@ class tokocrypto extends tokocrypto$1 {
1577
1582
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1578
1583
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1579
1584
  * @param {float} [params.triggerPrice] the price at which a trigger order would be triggered
1585
+ * @param {float} [params.cost] for spot market buy orders, the quote quantity that can be used as an alternative for the amount
1580
1586
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1581
1587
  */
1582
1588
  await this.loadMarkets();
@@ -1656,20 +1662,30 @@ class tokocrypto extends tokocrypto$1 {
1656
1662
  // LIMIT_MAKER quantity, price
1657
1663
  //
1658
1664
  if (uppercaseType === 'MARKET') {
1659
- const quoteOrderQtyInner = this.safeValue2(params, 'quoteOrderQty', 'cost');
1660
- if (this.options['createMarketBuyOrderRequiresPrice'] && (side === 'buy') && (price === undefined) && (quoteOrderQtyInner === undefined)) {
1661
- throw new errors.InvalidOrder(this.id + ' createOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
1662
- }
1663
- const precision = market['precision']['price'];
1664
- if (quoteOrderQtyInner !== undefined) {
1665
- request['quoteOrderQty'] = this.decimalToPrecision(quoteOrderQtyInner, number.TRUNCATE, precision, this.precisionMode);
1666
- params = this.omit(params, ['quoteOrderQty', 'cost']);
1667
- }
1668
- else if (price !== undefined) {
1669
- const amountString = this.numberToString(amount);
1670
- const priceString = this.numberToString(price);
1671
- const quoteOrderQty = Precise["default"].stringMul(amountString, priceString);
1672
- request['quoteOrderQty'] = this.decimalToPrecision(quoteOrderQty, number.TRUNCATE, precision, this.precisionMode);
1665
+ if (side === 'buy') {
1666
+ const precision = market['precision']['price'];
1667
+ let quoteAmount = undefined;
1668
+ let createMarketBuyOrderRequiresPrice = true;
1669
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
1670
+ const cost = this.safeNumber2(params, 'cost', 'quoteOrderQty');
1671
+ params = this.omit(params, ['cost', 'quoteOrderQty']);
1672
+ if (cost !== undefined) {
1673
+ quoteAmount = cost;
1674
+ }
1675
+ else if (createMarketBuyOrderRequiresPrice) {
1676
+ if (price === undefined) {
1677
+ throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
1678
+ }
1679
+ else {
1680
+ const amountString = this.numberToString(amount);
1681
+ const priceString = this.numberToString(price);
1682
+ quoteAmount = Precise["default"].stringMul(amountString, priceString);
1683
+ }
1684
+ }
1685
+ else {
1686
+ quoteAmount = amount;
1687
+ }
1688
+ request['quoteOrderQty'] = this.decimalToPrecision(quoteAmount, number.TRUNCATE, precision, this.precisionMode);
1673
1689
  }
1674
1690
  else {
1675
1691
  quantityIsRequired = true;
@@ -87,6 +87,8 @@ class wazirx extends wazirx$1 {
87
87
  'fetchTransfers': false,
88
88
  'fetchWithdrawals': false,
89
89
  'reduceMargin': false,
90
+ 'repayCrossMargin': false,
91
+ 'repayIsolatedMargin': false,
90
92
  'setLeverage': false,
91
93
  'setMargin': false,
92
94
  'setMarginMode': false,
@@ -73,6 +73,8 @@ class whitebit extends whitebit$1 {
73
73
  'fetchTradingFee': false,
74
74
  'fetchTradingFees': true,
75
75
  'fetchTransactionFees': true,
76
+ 'repayCrossMargin': false,
77
+ 'repayIsolatedMargin': false,
76
78
  'setLeverage': true,
77
79
  'transfer': true,
78
80
  'withdraw': true,
@@ -37,7 +37,10 @@ class woo extends woo$1 {
37
37
  'closeAllPositions': false,
38
38
  'closePosition': false,
39
39
  'createDepositAddress': false,
40
+ 'createMarketBuyOrderWithCost': true,
40
41
  'createMarketOrder': false,
42
+ 'createMarketOrderWithCost': false,
43
+ 'createMarketSellOrderWithCost': false,
41
44
  'createOrder': true,
42
45
  'createReduceOnlyOrder': true,
43
46
  'createStopLimitOrder': false,
@@ -739,6 +742,25 @@ class woo extends woo$1 {
739
742
  }
740
743
  return result;
741
744
  }
745
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
746
+ /**
747
+ * @method
748
+ * @name woo#createMarketBuyOrderWithCost
749
+ * @description create a market buy order by providing the symbol and cost
750
+ * @see https://docs.woo.org/#send-order
751
+ * @param {string} symbol unified symbol of the market to create an order in
752
+ * @param {float} cost how much you want to trade in units of the quote currency
753
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
754
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
755
+ */
756
+ await this.loadMarkets();
757
+ const market = this.market(symbol);
758
+ if (!market['spot']) {
759
+ throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
760
+ }
761
+ params['createMarketBuyOrderRequiresPrice'] = false;
762
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
763
+ }
742
764
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
743
765
  /**
744
766
  * @method
@@ -758,9 +780,11 @@ class woo extends woo$1 {
758
780
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
759
781
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
760
782
  * @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
783
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
761
784
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
762
785
  */
763
786
  const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
787
+ params = this.omit(params, ['reduceOnly', 'reduce_only']);
764
788
  const orderType = type.toUpperCase();
765
789
  await this.loadMarkets();
766
790
  const market = this.market(symbol);
@@ -803,26 +827,29 @@ class woo extends woo$1 {
803
827
  if (isMarket && !isStop) {
804
828
  // for market buy it requires the amount of quote currency to spend
805
829
  if (market['spot'] && orderSide === 'BUY') {
806
- const cost = this.safeNumber(params, 'cost');
807
- if (this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true)) {
808
- if (cost === undefined) {
809
- if (price === undefined) {
810
- throw new errors.InvalidOrder(this.id + " createOrder() requires the price argument for market buy orders to calculate total order cost. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or alternatively, supply the total cost value in the 'order_amount' in exchange-specific parameters");
811
- }
812
- else {
813
- const amountString = this.numberToString(amount);
814
- const priceString = this.numberToString(price);
815
- const orderAmount = Precise["default"].stringMul(amountString, priceString);
816
- request['order_amount'] = this.costToPrecision(symbol, orderAmount);
817
- }
830
+ let quoteAmount = undefined;
831
+ let createMarketBuyOrderRequiresPrice = true;
832
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
833
+ const cost = this.safeNumber2(params, 'cost', 'order_amount');
834
+ params = this.omit(params, ['cost', 'order_amount']);
835
+ if (cost !== undefined) {
836
+ quoteAmount = this.costToPrecision(symbol, cost);
837
+ }
838
+ else if (createMarketBuyOrderRequiresPrice) {
839
+ if (price === undefined) {
840
+ throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
818
841
  }
819
842
  else {
820
- request['order_amount'] = this.costToPrecision(symbol, cost);
843
+ const amountString = this.numberToString(amount);
844
+ const priceString = this.numberToString(price);
845
+ const costRequest = Precise["default"].stringMul(amountString, priceString);
846
+ quoteAmount = this.costToPrecision(symbol, costRequest);
821
847
  }
822
848
  }
823
849
  else {
824
- request['order_amount'] = this.costToPrecision(symbol, amount);
850
+ quoteAmount = this.costToPrecision(symbol, amount);
825
851
  }
852
+ request['order_amount'] = quoteAmount;
826
853
  }
827
854
  else {
828
855
  request['order_quantity'] = this.amountToPrecision(symbol, amount);
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { 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, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.87";
7
+ declare const version = "4.1.89";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { 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, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.88';
41
+ const version = '4.1.90';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -22,6 +22,7 @@ interface Exchange {
22
22
  v1GetMdSpotTicker24hrAll(params?: {}): Promise<implicitReturnType>;
23
23
  v1GetExchangePublicProducts(params?: {}): Promise<implicitReturnType>;
24
24
  v1GetApiDataPublicDataFundingRateHistory(params?: {}): Promise<implicitReturnType>;
25
+ v2GetPublicProducts(params?: {}): Promise<implicitReturnType>;
25
26
  v2GetMdV2Orderbook(params?: {}): Promise<implicitReturnType>;
26
27
  v2GetMdV2Trade(params?: {}): Promise<implicitReturnType>;
27
28
  v2GetMdV2Ticker24hr(params?: {}): Promise<implicitReturnType>;
@@ -3693,7 +3693,7 @@ export default class Exchange {
3693
3693
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3694
3694
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3695
3695
  */
3696
- if (this.options['createMarketOrderWithCost'] || (this.options['createMarketBuyOrderWithCost'] && this.options['createMarketSellOrderWithCost'])) {
3696
+ if (this.has['createMarketOrderWithCost'] || (this.has['createMarketBuyOrderWithCost'] && this.has['createMarketSellOrderWithCost'])) {
3697
3697
  return await this.createOrder(symbol, 'market', side, cost, 1, params);
3698
3698
  }
3699
3699
  throw new NotSupported(this.id + ' createMarketOrderWithCost() is not supported yet');
@@ -3708,7 +3708,7 @@ export default class Exchange {
3708
3708
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3709
3709
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3710
3710
  */
3711
- if (this.options['createMarketBuyOrderRequiresPrice'] || this.options['createMarketBuyOrderWithCost']) {
3711
+ if (this.options['createMarketBuyOrderRequiresPrice'] || this.has['createMarketBuyOrderWithCost']) {
3712
3712
  return await this.createOrder(symbol, 'market', 'buy', cost, 1, params);
3713
3713
  }
3714
3714
  throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() is not supported yet');
package/js/src/bigone.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bigone.js';
9
- import { ExchangeError, AuthenticationError, InsufficientFunds, PermissionDenied, BadRequest, BadSymbol, RateLimitExceeded, InvalidOrder, ArgumentsRequired } from './base/errors.js';
9
+ import { ExchangeError, AuthenticationError, InsufficientFunds, PermissionDenied, BadRequest, BadSymbol, RateLimitExceeded, InvalidOrder, ArgumentsRequired, NotSupported } from './base/errors.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { jwt } from './base/functions/rsa.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
@@ -34,6 +34,7 @@ export default class bigone extends Exchange {
34
34
  'cancelAllOrders': true,
35
35
  'cancelOrder': true,
36
36
  'createMarketBuyOrderWithCost': true,
37
+ 'createMarketOrderWithCost': false,
37
38
  'createMarketSellOrderWithCost': false,
38
39
  'createOrder': true,
39
40
  'createPostOnlyOrder': true,
@@ -1161,13 +1162,18 @@ export default class bigone extends Exchange {
1161
1162
  /**
1162
1163
  * @method
1163
1164
  * @name bigone#createMarketBuyOrderWithCost
1164
- * @see https://open.big.one/docs/spot_orders.html#create-order
1165
1165
  * @description create a market buy order by providing the symbol and cost
1166
+ * @see https://open.big.one/docs/spot_orders.html#create-order
1166
1167
  * @param {string} symbol unified symbol of the market to create an order in
1167
1168
  * @param {float} cost how much you want to trade in units of the quote currency
1168
1169
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1169
1170
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1170
1171
  */
1172
+ await this.loadMarkets();
1173
+ const market = this.market(symbol);
1174
+ if (!market['spot']) {
1175
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
1176
+ }
1171
1177
  params['createMarketBuyOrderRequiresPrice'] = false;
1172
1178
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
1173
1179
  }
@@ -1186,6 +1192,7 @@ export default class bigone extends Exchange {
1186
1192
  * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
1187
1193
  * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
1188
1194
  * @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
1195
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
1189
1196
  *
1190
1197
  * EXCHANGE SPECIFIC PARAMETERS
1191
1198
  * @param {string} operator *stop order only* GTE or LTE (default)
@@ -77,6 +77,8 @@ export default class bitforex extends Exchange {
77
77
  'fetchWithdrawal': false,
78
78
  'fetchWithdrawals': false,
79
79
  'reduceMargin': false,
80
+ 'repayCrossMargin': false,
81
+ 'repayIsolatedMargin': false,
80
82
  'setLeverage': false,
81
83
  'setMargin': false,
82
84
  'setMarginMode': false,
package/js/src/bitget.js CHANGED
@@ -3858,7 +3858,7 @@ export default class bitget extends Exchange {
3858
3858
  if (feeCostString !== undefined) {
3859
3859
  // swap
3860
3860
  fee = {
3861
- 'cost': feeCostString,
3861
+ 'cost': this.parseNumber(Precise.stringAbs(feeCostString)),
3862
3862
  'currency': market['settle'],
3863
3863
  };
3864
3864
  }
@@ -3866,10 +3866,17 @@ export default class bitget extends Exchange {
3866
3866
  if (feeDetail !== undefined) {
3867
3867
  const parsedFeeDetail = JSON.parse(feeDetail);
3868
3868
  const feeValues = Object.values(parsedFeeDetail);
3869
- const first = this.safeValue(feeValues, 0);
3869
+ let feeObject = undefined;
3870
+ for (let i = 0; i < feeValues.length; i++) {
3871
+ const feeValue = feeValues[i];
3872
+ if (this.safeValue(feeValue, 'feeCoinCode') !== undefined) {
3873
+ feeObject = feeValue;
3874
+ break;
3875
+ }
3876
+ }
3870
3877
  fee = {
3871
- 'cost': this.safeString(first, 'totalFee'),
3872
- 'currency': this.safeCurrencyCode(this.safeString(first, 'feeCoinCode')),
3878
+ 'cost': this.parseNumber(Precise.stringAbs(this.safeString(feeObject, 'totalFee'))),
3879
+ 'currency': this.safeCurrencyCode(this.safeString(feeObject, 'feeCoinCode')),
3873
3880
  };
3874
3881
  }
3875
3882
  let postOnly = undefined;
package/js/src/bitmex.js CHANGED
@@ -41,6 +41,8 @@ export default class bitmex extends Exchange {
41
41
  'cancelAllOrders': true,
42
42
  'cancelOrder': true,
43
43
  'cancelOrders': true,
44
+ 'closeAllPositions': false,
45
+ 'closePosition': true,
44
46
  'createOrder': true,
45
47
  'createReduceOnlyOrder': true,
46
48
  'editOrder': true,
@@ -36,8 +36,6 @@ export default class blockchaincom extends Exchange {
36
36
  }>;
37
37
  parseTransactionState(state: any): string;
38
38
  parseTransaction(transaction: any, currency?: Currency): Transaction;
39
- fetchWithdrawalWhitelist(params?: {}): Promise<any[]>;
40
- fetchWithdrawalWhitelistByCurrency(code: string, params?: {}): Promise<any[]>;
41
39
  withdraw(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<Transaction>;
42
40
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
43
41
  fetchWithdrawal(id: string, code?: Str, params?: {}): Promise<Transaction>;
@@ -909,47 +909,6 @@ export default class blockchaincom extends Exchange {
909
909
  'fee': fee,
910
910
  };
911
911
  }
912
- async fetchWithdrawalWhitelist(params = {}) {
913
- /**
914
- * @method
915
- * @name blockchaincom#fetchWithdrawalWhitelist
916
- * @description fetch the list of withdrawal addresses on the whitelist
917
- * @param {object} [params] extra parameters specific to the exchange API endpoint
918
- * @returns {object} dictionary with keys beneficiaryId, name, currency
919
- */
920
- await this.loadMarkets();
921
- const response = await this.privateGetWhitelist();
922
- const result = [];
923
- for (let i = 0; i < response.length; i++) {
924
- const entry = response[i];
925
- result.push({
926
- 'beneficiaryId': this.safeString(entry, 'whitelistId'),
927
- 'name': this.safeString(entry, 'name'),
928
- 'currency': this.safeString(entry, 'currency'),
929
- 'info': entry,
930
- });
931
- }
932
- return result;
933
- }
934
- async fetchWithdrawalWhitelistByCurrency(code, params = {}) {
935
- await this.loadMarkets();
936
- const currency = this.currency(code);
937
- const request = {
938
- 'currency': currency['id'],
939
- };
940
- const response = await this.privateGetWhitelistCurrency(this.extend(request, params));
941
- const result = [];
942
- for (let i = 0; i < response.length; i++) {
943
- const entry = response[i];
944
- result.push({
945
- 'beneficiaryId': this.safeString(entry, 'whitelistId'),
946
- 'name': this.safeString(entry, 'name'),
947
- 'currency': this.safeString(entry, 'currency'),
948
- 'info': entry,
949
- });
950
- }
951
- return result;
952
- }
953
912
  async withdraw(code, amount, address, tag = undefined, params = {}) {
954
913
  /**
955
914
  * @method
package/js/src/bybit.js CHANGED
@@ -947,6 +947,7 @@ export default class bybit extends Exchange {
947
947
  },
948
948
  'precisionMode': TICK_SIZE,
949
949
  'options': {
950
+ 'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
950
951
  'enableUnifiedMargin': undefined,
951
952
  'enableUnifiedAccount': undefined,
952
953
  'createMarketBuyOrderRequiresPrice': true,
@@ -1452,21 +1453,35 @@ export default class bybit extends Exchange {
1452
1453
  if (this.options['adjustForTimeDifference']) {
1453
1454
  await this.loadTimeDifference();
1454
1455
  }
1455
- const promisesUnresolved = [
1456
- this.fetchSpotMarkets(params),
1457
- this.fetchFutureMarkets({ 'category': 'linear' }),
1458
- this.fetchFutureMarkets({ 'category': 'inverse' }),
1459
- this.fetchOptionMarkets({ 'baseCoin': 'BTC' }),
1460
- this.fetchOptionMarkets({ 'baseCoin': 'ETH' }),
1461
- this.fetchOptionMarkets({ 'baseCoin': 'SOL' }),
1462
- ];
1456
+ const promisesUnresolved = [];
1457
+ const fetchMarkets = this.safeValue(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']);
1458
+ for (let i = 0; i < fetchMarkets.length; i++) {
1459
+ const marketType = fetchMarkets[i];
1460
+ if (marketType === 'spot') {
1461
+ promisesUnresolved.push(this.fetchSpotMarkets(params));
1462
+ }
1463
+ else if (marketType === 'linear') {
1464
+ promisesUnresolved.push(this.fetchFutureMarkets({ 'category': 'linear' }));
1465
+ }
1466
+ else if (marketType === 'inverse') {
1467
+ promisesUnresolved.push(this.fetchFutureMarkets({ 'category': 'inverse' }));
1468
+ }
1469
+ else if (marketType === 'option') {
1470
+ promisesUnresolved.push(this.fetchOptionMarkets({ 'baseCoin': 'BTC' }));
1471
+ promisesUnresolved.push(this.fetchOptionMarkets({ 'baseCoin': 'ETH' }));
1472
+ promisesUnresolved.push(this.fetchOptionMarkets({ 'baseCoin': 'SOL' }));
1473
+ }
1474
+ else {
1475
+ throw new ExchangeError(this.id + ' fetchMarkets() this.options fetchMarkets "' + marketType + '" is not a supported market type');
1476
+ }
1477
+ }
1463
1478
  const promises = await Promise.all(promisesUnresolved);
1464
- const spotMarkets = promises[0];
1465
- const linearMarkets = promises[1];
1466
- const inverseMarkets = promises[2];
1467
- const btcOptionMarkets = promises[3];
1468
- const ethOptionMarkets = promises[4];
1469
- const solOptionMarkets = promises[5];
1479
+ const spotMarkets = this.safeValue(promises, 0, []);
1480
+ const linearMarkets = this.safeValue(promises, 1, []);
1481
+ const inverseMarkets = this.safeValue(promises, 2, []);
1482
+ const btcOptionMarkets = this.safeValue(promises, 3, []);
1483
+ const ethOptionMarkets = this.safeValue(promises, 4, []);
1484
+ const solOptionMarkets = this.safeValue(promises, 5, []);
1470
1485
  const futureMarkets = this.arrayConcat(linearMarkets, inverseMarkets);
1471
1486
  let optionMarkets = this.arrayConcat(btcOptionMarkets, ethOptionMarkets);
1472
1487
  optionMarkets = this.arrayConcat(optionMarkets, solOptionMarkets);
package/js/src/coinex.js CHANGED
@@ -49,6 +49,8 @@ export default class coinex extends Exchange {
49
49
  'cancelOrders': true,
50
50
  'createDepositAddress': true,
51
51
  'createMarketBuyOrderWithCost': true,
52
+ 'createMarketOrderWithCost': false,
53
+ 'createMarketSellOrderWithCost': false,
52
54
  'createOrder': true,
53
55
  'createOrders': true,
54
56
  'createReduceOnlyOrder': true,
@@ -1929,13 +1931,19 @@ export default class coinex extends Exchange {
1929
1931
  async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1930
1932
  /**
1931
1933
  * @method
1932
- * @name coinex#createMarketBuyWithCost
1934
+ * @name coinex#createMarketBuyOrderWithCost
1933
1935
  * @description create a market buy order by providing the symbol and cost
1936
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
1934
1937
  * @param {string} symbol unified symbol of the market to create an order in
1935
1938
  * @param {float} cost how much you want to trade in units of the quote currency
1936
1939
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1937
1940
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1938
1941
  */
1942
+ await this.loadMarkets();
1943
+ const market = this.market(symbol);
1944
+ if (!market['spot']) {
1945
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
1946
+ }
1939
1947
  params['createMarketBuyOrderRequiresPrice'] = false;
1940
1948
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
1941
1949
  }
@@ -2101,6 +2109,11 @@ export default class coinex extends Exchange {
2101
2109
  * @method
2102
2110
  * @name coinex#createOrder
2103
2111
  * @description create a trade order
2112
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade001_limit_order
2113
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
2114
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade004_IOC_order
2115
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade005_stop_limit_order
2116
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade006_stop_market_order
2104
2117
  * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
2105
2118
  * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
2106
2119
  * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
@@ -109,6 +109,8 @@ export default class coinlist extends Exchange {
109
109
  'fetchWithdrawals': false,
110
110
  'fetchWithdrawalWhitelist': false,
111
111
  'reduceMargin': false,
112
+ 'repayCrossMargin': false,
113
+ 'repayIsolatedMargin': false,
112
114
  'setLeverage': false,
113
115
  'setMargin': false,
114
116
  'setMarginMode': false,
package/js/src/coinsph.js CHANGED
@@ -111,6 +111,8 @@ export default class coinsph extends Exchange {
111
111
  'fetchWithdrawals': true,
112
112
  'fetchWithdrawalWhitelist': false,
113
113
  'reduceMargin': false,
114
+ 'repayCrossMargin': false,
115
+ 'repayIsolatedMargin': false,
114
116
  'setLeverage': false,
115
117
  'setMargin': false,
116
118
  'setMarginMode': false,
@@ -99,6 +99,8 @@ export default class cryptocom extends Exchange {
99
99
  'fetchVolatilityHistory': false,
100
100
  'fetchWithdrawals': true,
101
101
  'reduceMargin': false,
102
+ 'repayCrossMargin': false,
103
+ 'repayIsolatedMargin': false,
102
104
  'setLeverage': false,
103
105
  'setMarginMode': false,
104
106
  'setPositionMode': false,