ccxt 4.1.76 → 4.1.78

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 (64) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +574 -185
  3. package/dist/ccxt.browser.min.js +5 -5
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/bingx.js +4 -1
  6. package/dist/cjs/src/bitget.js +71 -0
  7. package/dist/cjs/src/bitmart.js +9 -13
  8. package/dist/cjs/src/bitmex.js +6 -0
  9. package/dist/cjs/src/bitrue.js +27 -1
  10. package/dist/cjs/src/bitstamp.js +3 -2
  11. package/dist/cjs/src/bybit.js +2 -0
  12. package/dist/cjs/src/coinbase.js +47 -9
  13. package/dist/cjs/src/coinex.js +7 -11
  14. package/dist/cjs/src/gate.js +5 -0
  15. package/dist/cjs/src/hitbtc.js +326 -123
  16. package/dist/cjs/src/idex.js +10 -1
  17. package/dist/cjs/src/mexc.js +33 -5
  18. package/dist/cjs/src/okx.js +6 -10
  19. package/dist/cjs/src/pro/binance.js +10 -2
  20. package/dist/cjs/src/pro/binanceus.js +1 -0
  21. package/dist/cjs/src/pro/gate.js +1 -1
  22. package/dist/cjs/src/upbit.js +5 -5
  23. package/js/ccxt.d.ts +1 -1
  24. package/js/ccxt.js +1 -1
  25. package/js/src/abstract/bybit.d.ts +2 -0
  26. package/js/src/abstract/gate.d.ts +3 -0
  27. package/js/src/abstract/gateio.d.ts +3 -0
  28. package/js/src/abstract/okx.d.ts +2 -0
  29. package/js/src/base/Exchange.d.ts +1 -1
  30. package/js/src/bingx.js +4 -1
  31. package/js/src/bitget.d.ts +5 -4
  32. package/js/src/bitget.js +71 -0
  33. package/js/src/bitmart.js +9 -13
  34. package/js/src/bitmex.d.ts +1 -1
  35. package/js/src/bitmex.js +6 -0
  36. package/js/src/bitrue.d.ts +1 -0
  37. package/js/src/bitrue.js +27 -1
  38. package/js/src/bitstamp.js +3 -2
  39. package/js/src/bybit.js +2 -0
  40. package/js/src/coinbase.d.ts +1 -0
  41. package/js/src/coinbase.js +47 -9
  42. package/js/src/coinex.js +7 -11
  43. package/js/src/gate.js +5 -0
  44. package/js/src/hitbtc.js +326 -123
  45. package/js/src/idex.js +10 -1
  46. package/js/src/mexc.d.ts +1 -0
  47. package/js/src/mexc.js +33 -5
  48. package/js/src/okx.js +6 -10
  49. package/js/src/pro/binance.js +10 -2
  50. package/js/src/pro/binanceus.js +1 -0
  51. package/js/src/pro/gate.js +1 -1
  52. package/js/src/upbit.js +5 -5
  53. package/package.json +1 -1
  54. package/skip-tests.json +2 -1
  55. package/js/src/huobipro.d.ts +0 -4
  56. package/js/src/huobipro.js +0 -20
  57. package/js/src/mexc3.d.ts +0 -4
  58. package/js/src/mexc3.js +0 -17
  59. package/js/src/okex.d.ts +0 -4
  60. package/js/src/okex.js +0 -17
  61. package/js/src/okex5.d.ts +0 -4
  62. package/js/src/okex5.js +0 -17
  63. package/js/src/tidex.d.ts +0 -36
  64. package/js/src/tidex.js +0 -1068
@@ -93,6 +93,7 @@ export default class coinbase extends Exchange {
93
93
  prepareAccountRequestWithCurrencyCode(code?: Str, limit?: Int, params?: {}): Promise<{
94
94
  account_id: string;
95
95
  }>;
96
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
96
97
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
97
98
  parseOrder(order: any, market?: Market): Order;
98
99
  parseOrderStatus(status: any): string;
@@ -44,7 +44,10 @@ export default class coinbase extends Exchange {
44
44
  'createLimitBuyOrder': true,
45
45
  'createLimitSellOrder': true,
46
46
  'createMarketBuyOrder': true,
47
+ 'createMarketBuyOrderWithCost': true,
48
+ 'createMarketOrderWithCost': false,
47
49
  'createMarketSellOrder': true,
50
+ 'createMarketSellOrderWithCost': false,
48
51
  'createOrder': true,
49
52
  'createPostOnlyOrder': true,
50
53
  'createReduceOnlyOrder': false,
@@ -907,7 +910,11 @@ export default class coinbase extends Exchange {
907
910
  else {
908
911
  cost = costString;
909
912
  }
910
- const feeCurrencyId = this.safeString(feeObject, 'currency');
913
+ let feeCurrencyId = this.safeString(feeObject, 'currency');
914
+ const feeCost = this.safeNumber(feeObject, 'amount', this.parseNumber(v3FeeCost));
915
+ if ((feeCurrencyId === undefined) && (market !== undefined) && (feeCost !== undefined)) {
916
+ feeCurrencyId = market['quote'];
917
+ }
911
918
  const datetime = this.safeStringN(trade, ['created_at', 'trade_time', 'time']);
912
919
  const side = this.safeStringLower2(trade, 'resource', 'side');
913
920
  const takerOrMaker = this.safeStringLower(trade, 'liquidity_indicator');
@@ -925,7 +932,7 @@ export default class coinbase extends Exchange {
925
932
  'amount': amountString,
926
933
  'cost': cost,
927
934
  'fee': {
928
- 'cost': this.safeNumber(feeObject, 'amount', this.parseNumber(v3FeeCost)),
935
+ 'cost': feeCost,
929
936
  'currency': this.safeCurrencyCode(feeCurrencyId),
930
937
  },
931
938
  });
@@ -2083,6 +2090,25 @@ export default class coinbase extends Exchange {
2083
2090
  }
2084
2091
  return request;
2085
2092
  }
2093
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
2094
+ /**
2095
+ * @method
2096
+ * @name coinbase#createMarketBuyOrderWithCost
2097
+ * @description create a market buy order by providing the symbol and cost
2098
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_postorder
2099
+ * @param {string} symbol unified symbol of the market to create an order in
2100
+ * @param {float} cost how much you want to trade in units of the quote currency
2101
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2102
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2103
+ */
2104
+ await this.loadMarkets();
2105
+ const market = this.market(symbol);
2106
+ if (!market['spot']) {
2107
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
2108
+ }
2109
+ params['createMarketBuyOrderRequiresPrice'] = false;
2110
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
2111
+ }
2086
2112
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2087
2113
  /**
2088
2114
  * @method
@@ -2103,6 +2129,7 @@ export default class coinbase extends Exchange {
2103
2129
  * @param {string} [params.timeInForce] 'GTC', 'IOC', 'GTD' or 'PO'
2104
2130
  * @param {string} [params.stop_direction] 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2105
2131
  * @param {string} [params.end_time] '2023-05-25T17:01:05.092Z' for 'GTD' orders
2132
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
2106
2133
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2107
2134
  */
2108
2135
  await this.loadMarkets();
@@ -2205,21 +2232,27 @@ export default class coinbase extends Exchange {
2205
2232
  throw new NotSupported(this.id + ' createOrder() only stop limit orders are supported');
2206
2233
  }
2207
2234
  if (side === 'buy') {
2208
- const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
2209
2235
  let total = undefined;
2210
- if (createMarketBuyOrderRequiresPrice) {
2236
+ let createMarketBuyOrderRequiresPrice = true;
2237
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
2238
+ const cost = this.safeNumber(params, 'cost');
2239
+ params = this.omit(params, 'cost');
2240
+ if (cost !== undefined) {
2241
+ total = this.costToPrecision(symbol, cost);
2242
+ }
2243
+ else if (createMarketBuyOrderRequiresPrice) {
2211
2244
  if (price === undefined) {
2212
- throw new InvalidOrder(this.id + ' createOrder() requires a 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');
2245
+ throw new InvalidOrder(this.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
2213
2246
  }
2214
2247
  else {
2215
2248
  const amountString = this.numberToString(amount);
2216
2249
  const priceString = this.numberToString(price);
2217
- const cost = this.parseNumber(Precise.stringMul(amountString, priceString));
2218
- total = this.priceToPrecision(symbol, cost);
2250
+ const costRequest = Precise.stringMul(amountString, priceString);
2251
+ total = this.costToPrecision(symbol, costRequest);
2219
2252
  }
2220
2253
  }
2221
2254
  else {
2222
- total = this.priceToPrecision(symbol, amount);
2255
+ total = this.costToPrecision(symbol, amount);
2223
2256
  }
2224
2257
  request['order_configuration'] = {
2225
2258
  'market_market_ioc': {
@@ -2349,6 +2382,11 @@ export default class coinbase extends Exchange {
2349
2382
  amount = this.safeString(marketIOC, 'base_size');
2350
2383
  }
2351
2384
  const datetime = this.safeString(order, 'created_time');
2385
+ const totalFees = this.safeString(order, 'total_fees');
2386
+ let currencyFee = undefined;
2387
+ if ((totalFees !== undefined) && (market !== undefined)) {
2388
+ currencyFee = market['quote'];
2389
+ }
2352
2390
  return this.safeOrder({
2353
2391
  'info': order,
2354
2392
  'id': this.safeString(order, 'order_id'),
@@ -2372,7 +2410,7 @@ export default class coinbase extends Exchange {
2372
2410
  'status': this.parseOrderStatus(this.safeString(order, 'status')),
2373
2411
  'fee': {
2374
2412
  'cost': this.safeString(order, 'total_fees'),
2375
- 'currency': undefined,
2413
+ 'currency': currencyFee,
2376
2414
  },
2377
2415
  'trades': undefined,
2378
2416
  }, market);
package/js/src/coinex.js CHANGED
@@ -4825,17 +4825,13 @@ export default class coinex extends Exchange {
4825
4825
  return this.parseIsolatedBorrowRate(data, market);
4826
4826
  }
4827
4827
  async fetchIsolatedBorrowRates(params = {}) {
4828
- //
4829
- // @method
4830
- // @name coinex#fetchIsolatedBorrowRates
4831
- // @description fetch the borrow interest rates of all currencies
4832
- // @param {object} [params] extra parameters specific to the exchange API endpoint
4833
- // <<<<<<< HEAD
4834
- // @returns {object} a list of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
4835
- // =======
4836
- // @returns {object} a list of [isolated borrow rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#isolated-borrow-rate-structure}
4837
- // >>>>>>> 3215552206edf1cda1ae63d2063535e19973dbe5
4838
- //
4828
+ /**
4829
+ * @method
4830
+ * @name coinex#fetchIsolatedBorrowRates
4831
+ * @description fetch the borrow interest rates of all currencies
4832
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4833
+ * @returns {object} a list of [isolated borrow rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#isolated-borrow-rate-structure}
4834
+ */
4839
4835
  await this.loadMarkets();
4840
4836
  const response = await this.privateGetMarginConfig(params);
4841
4837
  //
package/js/src/gate.js CHANGED
@@ -48,6 +48,7 @@ export default class gate extends Exchange {
48
48
  'spot': 'https://api.gateio.ws/api/v4',
49
49
  'options': 'https://api.gateio.ws/api/v4',
50
50
  'subAccounts': 'https://api.gateio.ws/api/v4',
51
+ 'portfolio': 'https://api.gateio.ws/api/v4',
51
52
  'rebate': 'https://api.gateio.ws/api/v4',
52
53
  'earn': 'https://api.gateio.ws/api/v4',
53
54
  'account': 'https://api.gateio.ws/api/v4',
@@ -485,10 +486,13 @@ export default class gate extends Exchange {
485
486
  },
486
487
  'earn': {
487
488
  'get': {
489
+ 'uni/currencies': 20 / 15,
490
+ 'uni/currencies/{currency}': 20 / 15,
488
491
  'uni/lends': 20 / 15,
489
492
  'uni/lend_records': 20 / 15,
490
493
  'uni/interests/{currency}': 20 / 15,
491
494
  'uni/interest_records': 20 / 15,
495
+ 'uni/interest_status/{currency}': 20 / 15,
492
496
  },
493
497
  'post': {
494
498
  'uni/lends': 20 / 15,
@@ -545,6 +549,7 @@ export default class gate extends Exchange {
545
549
  '15m': '15m',
546
550
  '30m': '30m',
547
551
  '1h': '1h',
552
+ '2h': '2h',
548
553
  '4h': '4h',
549
554
  '8h': '8h',
550
555
  '1d': '1d',