ccxt 4.1.70 → 4.1.72

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.
@@ -7352,6 +7352,8 @@ class Exchange {
7352
7352
  'createLimitOrder': true,
7353
7353
  'createMarketOrder': true,
7354
7354
  'createOrder': true,
7355
+ 'createMarketBuyOrderWithCost': undefined,
7356
+ 'createMarketSellOrderWithCost': undefined,
7355
7357
  'createOrders': undefined,
7356
7358
  'createPostOnlyOrder': undefined,
7357
7359
  'createReduceOnlyOrder': undefined,
@@ -10553,6 +10555,30 @@ class Exchange {
10553
10555
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
10554
10556
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrder() is not supported yet');
10555
10557
  }
10558
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
10559
+ /**
10560
+ * @method
10561
+ * @name createMarketBuyWithCost
10562
+ * @description create a market buy order by providing the symbol and cost
10563
+ * @param {string} symbol unified symbol of the market to create an order in
10564
+ * @param {float} cost how much you want to trade in units of the quote currency
10565
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
10566
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
10567
+ */
10568
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createMarketBuyOrderWithCost() is not supported yet');
10569
+ }
10570
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
10571
+ /**
10572
+ * @method
10573
+ * @name createMarketSellOrderWithCost
10574
+ * @description create a market buy order by providing the symbol and cost
10575
+ * @param {string} symbol unified symbol of the market to create an order in
10576
+ * @param {float} cost how much you want to trade in units of the quote currency
10577
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
10578
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
10579
+ */
10580
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createMarketSellOrderWithCost() is not supported yet');
10581
+ }
10556
10582
  async createOrders(orders, params = {}) {
10557
10583
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrders() is not supported yet');
10558
10584
  }
@@ -17497,6 +17523,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17497
17523
  'sapiV2': {
17498
17524
  'get': {
17499
17525
  'sub-account/futures/account': 0.1,
17526
+ 'sub-account/futures/accountSummary': 1,
17500
17527
  'sub-account/futures/positionRisk': 0.1,
17501
17528
  },
17502
17529
  'post': {
@@ -28789,15 +28816,17 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28789
28816
  // "symbol": "XRP-USDT",
28790
28817
  // "orderId": 1514073325788200960,
28791
28818
  // "price": "0.5",
28819
+ // "StopPrice": "0",
28792
28820
  // "origQty": "20",
28793
- // "executedQty": "0",
28794
- // "cummulativeQuoteQty": "0",
28821
+ // "executedQty": "10",
28822
+ // "cummulativeQuoteQty": "5",
28795
28823
  // "status": "PENDING",
28796
28824
  // "type": "LIMIT",
28797
28825
  // "side": "BUY",
28798
28826
  // "time": 1649818185647,
28799
28827
  // "updateTime": 1649818185647,
28800
28828
  // "origQuoteOrderQty": "0"
28829
+ // "fee": "-0.01"
28801
28830
  // }
28802
28831
  //
28803
28832
  //
@@ -28857,9 +28886,24 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28857
28886
  const amount = this.safeString2(order, 'origQty', 'q');
28858
28887
  const filled = this.safeString2(order, 'executedQty', 'z');
28859
28888
  const statusId = this.safeString2(order, 'status', 'X');
28889
+ let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
28890
+ const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
28891
+ if ((feeCurrencyCode === undefined)) {
28892
+ if (market['spot']) {
28893
+ if (side === 'buy') {
28894
+ feeCurrencyCode = market['base'];
28895
+ }
28896
+ else {
28897
+ feeCurrencyCode = market['quote'];
28898
+ }
28899
+ }
28900
+ else {
28901
+ feeCurrencyCode = market['quote'];
28902
+ }
28903
+ }
28860
28904
  const fee = {
28861
- 'currency': this.safeString2(order, 'feeAsset', 'N'),
28862
- 'rate': this.safeStringN(order, ['fee', 'commission', 'n']),
28905
+ 'currency': feeCurrencyCode,
28906
+ 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCost),
28863
28907
  };
28864
28908
  const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
28865
28909
  return this.safeOrder({
@@ -85288,12 +85332,15 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
85288
85332
  'brokerage/transaction_summary',
85289
85333
  'brokerage/product_book',
85290
85334
  'brokerage/best_bid_ask',
85335
+ 'brokerage/convert/trade/{trade_id}',
85291
85336
  ],
85292
85337
  'post': [
85293
85338
  'brokerage/orders',
85294
85339
  'brokerage/orders/batch_cancel',
85295
85340
  'brokerage/orders/edit',
85296
85341
  'brokerage/orders/edit_preview',
85342
+ 'brokerage/convert/quote',
85343
+ 'brokerage/convert/trade/{trade_id}',
85297
85344
  ],
85298
85345
  },
85299
85346
  },
@@ -91135,6 +91182,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91135
91182
  'cancelOrders': true,
91136
91183
  'createDepositAddress': true,
91137
91184
  'createOrder': true,
91185
+ 'createMarketBuyOrderWithCost': true,
91138
91186
  'createOrders': true,
91139
91187
  'createReduceOnlyOrder': true,
91140
91188
  'editOrder': true,
@@ -92973,6 +93021,19 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92973
93021
  'info': order,
92974
93022
  }, market);
92975
93023
  }
93024
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
93025
+ /**
93026
+ * @method
93027
+ * @name coinex#createMarketBuyWithCost
93028
+ * @description create a market buy order by providing the symbol and cost
93029
+ * @param {string} symbol unified symbol of the market to create an order in
93030
+ * @param {float} cost how much you want to trade in units of the quote currency
93031
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
93032
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
93033
+ */
93034
+ params['createMarketBuyOrderRequiresPrice'] = false;
93035
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
93036
+ }
92976
93037
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
92977
93038
  const market = this.market(symbol);
92978
93039
  const swap = market['swap'];
@@ -93073,16 +93134,20 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93073
93134
  else {
93074
93135
  request['type'] = side;
93075
93136
  if ((type === 'market') && (side === 'buy')) {
93076
- if (this.options['createMarketBuyOrderRequiresPrice']) {
93077
- if (price === undefined) {
93078
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(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)");
93137
+ let createMarketBuyOrderRequiresPrice = true;
93138
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
93139
+ const cost = this.safeNumber(params, 'cost');
93140
+ params = this.omit(params, 'cost');
93141
+ if (createMarketBuyOrderRequiresPrice) {
93142
+ if ((price === undefined) && (cost === undefined)) {
93143
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.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 in the amount argument');
93079
93144
  }
93080
93145
  else {
93081
- const amountString = this.amountToPrecision(symbol, amount);
93082
- const priceString = this.priceToPrecision(symbol, price);
93083
- const costString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString);
93084
- const costNumber = this.parseNumber(costString);
93085
- request['amount'] = this.costToPrecision(symbol, costNumber);
93146
+ const amountString = this.numberToString(amount);
93147
+ const priceString = this.numberToString(price);
93148
+ const quoteAmount = this.parseToNumeric(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString));
93149
+ const costRequest = (cost !== undefined) ? cost : quoteAmount;
93150
+ request['amount'] = this.costToPrecision(symbol, costRequest);
93086
93151
  }
93087
93152
  }
93088
93153
  else {
@@ -123969,11 +124034,16 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
123969
124034
  if (limit !== undefined) {
123970
124035
  request['limit'] = limit;
123971
124036
  }
123972
- const method = this.getSupportedMapping(type, {
123973
- 'swap': 'privateFuturesGetSettleAccountBook',
123974
- 'future': 'privateDeliveryGetSettleAccountBook',
123975
- });
123976
- const response = await this[method](this.extend(request, requestParams));
124037
+ let response = undefined;
124038
+ if (type === 'swap') {
124039
+ response = await this.privateFuturesGetSettleAccountBook(this.extend(request, requestParams));
124040
+ }
124041
+ else if (type === 'future') {
124042
+ response = await this.privateDeliveryGetSettleAccountBook(this.extend(request, requestParams));
124043
+ }
124044
+ else {
124045
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingHistory() only support swap & future market type');
124046
+ }
123977
124047
  //
123978
124048
  // [
123979
124049
  // {
@@ -124046,18 +124116,26 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124046
124116
  // };
124047
124117
  //
124048
124118
  const [request, query] = this.prepareRequest(market, market['type'], params);
124049
- const method = this.getSupportedMapping(market['type'], {
124050
- 'spot': 'publicSpotGetOrderBook',
124051
- 'margin': 'publicSpotGetOrderBook',
124052
- 'swap': 'publicFuturesGetSettleOrderBook',
124053
- 'future': 'publicDeliveryGetSettleOrderBook',
124054
- 'option': 'publicOptionsGetOrderBook',
124055
- });
124056
124119
  if (limit !== undefined) {
124057
124120
  request['limit'] = limit; // default 10, max 100
124058
124121
  }
124059
124122
  request['with_id'] = true;
124060
- const response = await this[method](this.extend(request, query));
124123
+ let response = undefined;
124124
+ if (market['spot'] || market['margin']) {
124125
+ response = await this.publicSpotGetOrderBook(this.extend(request, query));
124126
+ }
124127
+ else if (market['swap']) {
124128
+ response = await this.publicFuturesGetSettleOrderBook(this.extend(request, query));
124129
+ }
124130
+ else if (market['future']) {
124131
+ response = await this.publicDeliveryGetSettleOrderBook(this.extend(request, query));
124132
+ }
124133
+ else if (market['option']) {
124134
+ response = await this.publicOptionsGetOrderBook(this.extend(request, query));
124135
+ }
124136
+ else {
124137
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrderBook() not support this market type');
124138
+ }
124061
124139
  //
124062
124140
  // spot
124063
124141
  //
@@ -124149,19 +124227,25 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124149
124227
  await this.loadMarkets();
124150
124228
  const market = this.market(symbol);
124151
124229
  const [request, query] = this.prepareRequest(market, undefined, params);
124152
- const method = this.getSupportedMapping(market['type'], {
124153
- 'spot': 'publicSpotGetTickers',
124154
- 'margin': 'publicSpotGetTickers',
124155
- 'swap': 'publicFuturesGetSettleTickers',
124156
- 'future': 'publicDeliveryGetSettleTickers',
124157
- 'option': 'publicOptionsGetTickers',
124158
- });
124159
- if (market['option']) {
124230
+ let response = undefined;
124231
+ if (market['spot'] || market['margin']) {
124232
+ response = await this.publicSpotGetTickers(this.extend(request, query));
124233
+ }
124234
+ else if (market['swap']) {
124235
+ response = await this.publicFuturesGetSettleTickers(this.extend(request, query));
124236
+ }
124237
+ else if (market['future']) {
124238
+ response = await this.publicDeliveryGetSettleTickers(this.extend(request, query));
124239
+ }
124240
+ else if (market['option']) {
124160
124241
  const marketId = market['id'];
124161
124242
  const optionParts = marketId.split('-');
124162
124243
  request['underlying'] = this.safeString(optionParts, 0);
124244
+ response = await this.publicOptionsGetTickers(this.extend(request, query));
124245
+ }
124246
+ else {
124247
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTicker() not support this market type');
124163
124248
  }
124164
- const response = await this[method](this.extend(request, query));
124165
124249
  let ticker = undefined;
124166
124250
  if (market['option']) {
124167
124251
  for (let i = 0; i < response.length; i++) {
@@ -124311,20 +124395,26 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124311
124395
  }
124312
124396
  const [type, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
124313
124397
  const [request, requestParams] = this.prepareRequest(undefined, type, query);
124314
- const method = this.getSupportedMapping(type, {
124315
- 'spot': 'publicSpotGetTickers',
124316
- 'margin': 'publicSpotGetTickers',
124317
- 'swap': 'publicFuturesGetSettleTickers',
124318
- 'future': 'publicDeliveryGetSettleTickers',
124319
- 'option': 'publicOptionsGetTickers',
124320
- });
124321
- if (type === 'option') {
124398
+ let response = undefined;
124399
+ if (type === 'spot' || type === 'margin') {
124400
+ response = await this.publicSpotGetTickers(this.extend(request, requestParams));
124401
+ }
124402
+ else if (type === 'swap') {
124403
+ response = await this.publicFuturesGetSettleTickers(this.extend(request, requestParams));
124404
+ }
124405
+ else if (type === 'future') {
124406
+ response = await this.publicDeliveryGetSettleTickers(this.extend(request, requestParams));
124407
+ }
124408
+ else if (type === 'option') {
124322
124409
  this.checkRequiredArgument('fetchTickers', symbols, 'symbols');
124323
124410
  const marketId = market['id'];
124324
124411
  const optionParts = marketId.split('-');
124325
124412
  request['underlying'] = this.safeString(optionParts, 0);
124413
+ response = await this.publicOptionsGetTickers(this.extend(request, requestParams));
124414
+ }
124415
+ else {
124416
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers() not support this market type');
124326
124417
  }
124327
- const response = await this[method](this.extend(request, requestParams));
124328
124418
  return this.parseTickers(response, symbols);
124329
124419
  }
124330
124420
  parseBalanceHelper(entry) {
@@ -124355,18 +124445,36 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124355
124445
  const market = this.market(symbol);
124356
124446
  request['currency_pair'] = market['id'];
124357
124447
  }
124358
- const method = this.getSupportedMapping(type, {
124359
- 'spot': this.getSupportedMapping(marginMode, {
124360
- 'spot': 'privateSpotGetAccounts',
124361
- 'margin': 'privateMarginGetAccounts',
124362
- 'cross_margin': 'privateMarginGetCrossAccounts',
124363
- }),
124364
- 'funding': 'privateMarginGetFundingAccounts',
124365
- 'swap': 'privateFuturesGetSettleAccounts',
124366
- 'future': 'privateDeliveryGetSettleAccounts',
124367
- 'option': 'privateOptionsGetAccounts',
124368
- });
124369
- let response = await this[method](this.extend(request, requestQuery));
124448
+ let response = undefined;
124449
+ if (type === 'spot') {
124450
+ if (marginMode === 'spot') {
124451
+ response = await this.privateSpotGetAccounts(this.extend(request, requestQuery));
124452
+ }
124453
+ else if (marginMode === 'margin') {
124454
+ response = await this.privateMarginGetAccounts(this.extend(request, requestQuery));
124455
+ }
124456
+ else if (marginMode === 'cross_margin') {
124457
+ response = await this.privateMarginGetCrossAccounts(this.extend(request, requestQuery));
124458
+ }
124459
+ else {
124460
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchBalance() not support this marginMode');
124461
+ }
124462
+ }
124463
+ else if (type === 'funding') {
124464
+ response = await this.privateMarginGetFundingAccounts(this.extend(request, requestQuery));
124465
+ }
124466
+ else if (type === 'swap') {
124467
+ response = await this.privateFuturesGetSettleAccounts(this.extend(request, requestQuery));
124468
+ }
124469
+ else if (type === 'future') {
124470
+ response = await this.privateDeliveryGetSettleAccounts(this.extend(request, requestQuery));
124471
+ }
124472
+ else if (type === 'option') {
124473
+ response = await this.privateOptionsGetAccounts(this.extend(request, requestQuery));
124474
+ }
124475
+ else {
124476
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchBalance() not support this market type');
124477
+ }
124370
124478
  const contract = ((type === 'swap') || (type === 'future') || (type === 'option'));
124371
124479
  if (contract) {
124372
124480
  response = [response];
@@ -124586,23 +124694,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124586
124694
  let request = {};
124587
124695
  [request, params] = this.prepareRequest(market, undefined, params);
124588
124696
  request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
124589
- let method = 'publicSpotGetCandlesticks';
124590
124697
  let maxLimit = 1000;
124591
- if (market['contract']) {
124592
- maxLimit = 1999;
124593
- if (market['future']) {
124594
- method = 'publicDeliveryGetSettleCandlesticks';
124595
- }
124596
- else if (market['swap']) {
124597
- method = 'publicFuturesGetSettleCandlesticks';
124598
- }
124599
- const isMark = (price === 'mark');
124600
- const isIndex = (price === 'index');
124601
- if (isMark || isIndex) {
124602
- request['contract'] = price + '_' + market['id'];
124603
- params = this.omit(params, 'price');
124604
- }
124605
- }
124606
124698
  limit = (limit === undefined) ? maxLimit : Math.min(limit, maxLimit);
124607
124699
  let until = this.safeInteger(params, 'until');
124608
124700
  if (until !== undefined) {
@@ -124629,7 +124721,25 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124629
124721
  }
124630
124722
  request['limit'] = limit;
124631
124723
  }
124632
- const response = await this[method](this.extend(request, params));
124724
+ let response = undefined;
124725
+ if (market['contract']) {
124726
+ maxLimit = 1999;
124727
+ const isMark = (price === 'mark');
124728
+ const isIndex = (price === 'index');
124729
+ if (isMark || isIndex) {
124730
+ request['contract'] = price + '_' + market['id'];
124731
+ params = this.omit(params, 'price');
124732
+ }
124733
+ if (market['future']) {
124734
+ response = await this.publicDeliveryGetSettleCandlesticks(this.extend(request, params));
124735
+ }
124736
+ else if (market['swap']) {
124737
+ response = await this.publicFuturesGetSettleCandlesticks(this.extend(request, params));
124738
+ }
124739
+ }
124740
+ else {
124741
+ response = await this.publicSpotGetCandlesticks(this.extend(request, params));
124742
+ }
124633
124743
  return this.parseOHLCVs(response, market, timeframe, since, limit);
124634
124744
  }
124635
124745
  async fetchOptionOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
@@ -124666,8 +124776,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124666
124776
  if (limit !== undefined) {
124667
124777
  request['limit'] = limit;
124668
124778
  }
124669
- const method = 'publicFuturesGetSettleFundingRate';
124670
- const response = await this[method](this.extend(request, query));
124779
+ const response = await this.publicFuturesGetSettleFundingRate(this.extend(request, query));
124671
124780
  //
124672
124781
  // {
124673
124782
  // "r": "0.00063521",
@@ -124782,13 +124891,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124782
124891
  // };
124783
124892
  //
124784
124893
  const [request, query] = this.prepareRequest(market, undefined, params);
124785
- const method = this.getSupportedMapping(market['type'], {
124786
- 'spot': 'publicSpotGetTrades',
124787
- 'margin': 'publicSpotGetTrades',
124788
- 'swap': 'publicFuturesGetSettleTrades',
124789
- 'future': 'publicDeliveryGetSettleTrades',
124790
- 'option': 'publicOptionsGetTrades',
124791
- });
124792
124894
  const until = this.safeInteger2(params, 'to', 'until');
124793
124895
  if (until !== undefined) {
124794
124896
  params = this.omit(params, ['until']);
@@ -124800,7 +124902,22 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124800
124902
  if (since !== undefined && (market['contract'])) {
124801
124903
  request['from'] = this.parseToInt(since / 1000);
124802
124904
  }
124803
- const response = await this[method](this.extend(request, query));
124905
+ let response = undefined;
124906
+ if (market['type'] === 'spot' || market['type'] === 'margin') {
124907
+ response = await this.publicSpotGetTrades(this.extend(request, query));
124908
+ }
124909
+ else if (market['swap']) {
124910
+ response = await this.publicFuturesGetSettleTrades(this.extend(request, query));
124911
+ }
124912
+ else if (market['future']) {
124913
+ response = await this.publicDeliveryGetSettleTrades(this.extend(request, query));
124914
+ }
124915
+ else if (market['type'] === 'option') {
124916
+ response = await this.publicOptionsGetTrades(this.extend(request, query));
124917
+ }
124918
+ else {
124919
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTrades() not support this market type.');
124920
+ }
124804
124921
  //
124805
124922
  // spot
124806
124923
  //
@@ -124946,14 +125063,22 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124946
125063
  if (until !== undefined) {
124947
125064
  request['to'] = this.parseToInt(until / 1000);
124948
125065
  }
124949
- const method = this.getSupportedMapping(type, {
124950
- 'spot': 'privateSpotGetMyTrades',
124951
- 'margin': 'privateSpotGetMyTrades',
124952
- 'swap': 'privateFuturesGetSettleMyTradesTimerange',
124953
- 'future': 'privateDeliveryGetSettleMyTrades',
124954
- 'option': 'privateOptionsGetMyTrades',
124955
- });
124956
- const response = await this[method](this.extend(request, params));
125066
+ let response = undefined;
125067
+ if (type === 'spot' || type === 'margin') {
125068
+ response = await this.privateSpotGetMyTrades(this.extend(request, params));
125069
+ }
125070
+ else if (type === 'swap') {
125071
+ response = await this.privateFuturesGetSettleMyTradesTimerange(this.extend(request, params));
125072
+ }
125073
+ else if (type === 'future') {
125074
+ response = await this.privateDeliveryGetSettleMyTrades(this.extend(request, params));
125075
+ }
125076
+ else if (type === 'option') {
125077
+ response = await this.privateOptionsGetMyTrades(this.extend(request, params));
125078
+ }
125079
+ else {
125080
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchMyTrades() not support this market type.');
125081
+ }
124957
125082
  //
124958
125083
  // spot
124959
125084
  //
@@ -125294,7 +125419,14 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
125294
125419
  'PEND': 'pending',
125295
125420
  'REQUEST': 'pending',
125296
125421
  'DMOVE': 'pending',
125297
- 'CANCEL': 'failed',
125422
+ 'MANUAL': 'pending',
125423
+ 'VERIFY': 'pending',
125424
+ 'PROCES': 'pending',
125425
+ 'EXTPEND': 'pending',
125426
+ 'SPLITPEND': 'pending',
125427
+ 'CANCEL': 'canceled',
125428
+ 'FAIL': 'failed',
125429
+ 'INVALID': 'failed',
125298
125430
  'DONE': 'ok',
125299
125431
  'BCODE': 'ok', // GateCode withdrawal
125300
125432
  };
@@ -126204,15 +126336,37 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126204
126336
  const contract = (type === 'swap') || (type === 'future') || (type === 'option');
126205
126337
  const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market, stop, query);
126206
126338
  request['order_id'] = orderId;
126207
- const methodMiddle = stop ? 'PriceOrders' : 'Orders';
126208
- const method = this.getSupportedMapping(type, {
126209
- 'spot': 'privateSpotGet' + methodMiddle + 'OrderId',
126210
- 'margin': 'privateSpotGet' + methodMiddle + 'OrderId',
126211
- 'swap': 'privateFuturesGetSettle' + methodMiddle + 'OrderId',
126212
- 'future': 'privateDeliveryGetSettle' + methodMiddle + 'OrderId',
126213
- 'option': 'privateOptionsGetOrdersOrderId',
126214
- });
126215
- const response = await this[method](this.extend(request, requestParams));
126339
+ let response = undefined;
126340
+ if (type === 'spot' || type === 'margin') {
126341
+ if (stop) {
126342
+ response = await this.privateSpotGetPriceOrdersOrderId(this.extend(request, requestParams));
126343
+ }
126344
+ else {
126345
+ response = await this.privateSpotGetOrdersOrderId(this.extend(request, requestParams));
126346
+ }
126347
+ }
126348
+ else if (type === 'swap') {
126349
+ if (stop) {
126350
+ response = await this.privateFuturesGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
126351
+ }
126352
+ else {
126353
+ response = await this.privateFuturesGetSettleOrdersOrderId(this.extend(request, requestParams));
126354
+ }
126355
+ }
126356
+ else if (type === 'future') {
126357
+ if (stop) {
126358
+ response = await this.privateDeliveryGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
126359
+ }
126360
+ else {
126361
+ response = await this.privateDeliveryGetSettleOrdersOrderId(this.extend(request, requestParams));
126362
+ }
126363
+ }
126364
+ else if (type === 'option') {
126365
+ response = await this.privateOptionsGetOrdersOrderId(this.extend(request, requestParams));
126366
+ }
126367
+ else {
126368
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrder() not support this market type');
126369
+ }
126216
126370
  return this.parseOrder(response, market);
126217
126371
  }
126218
126372
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -126277,19 +126431,41 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126277
126431
  if (since !== undefined && spot) {
126278
126432
  request['from'] = this.parseToInt(since / 1000);
126279
126433
  }
126280
- let methodTail = stop ? 'PriceOrders' : 'Orders';
126281
126434
  const openSpotOrders = spot && (status === 'open') && !stop;
126282
- if (openSpotOrders) {
126283
- methodTail = 'OpenOrders';
126435
+ let response = undefined;
126436
+ if (type === 'spot' || type === 'margin') {
126437
+ if (openSpotOrders) {
126438
+ response = await this.privateSpotGetOpenOrders(this.extend(request, requestParams));
126439
+ }
126440
+ else if (stop) {
126441
+ response = await this.privateSpotGetPriceOrders(this.extend(request, requestParams));
126442
+ }
126443
+ else {
126444
+ response = await this.privateSpotGetOrders(this.extend(request, requestParams));
126445
+ }
126446
+ }
126447
+ else if (type === 'swap') {
126448
+ if (stop) {
126449
+ response = await this.privateFuturesGetSettlePriceOrders(this.extend(request, requestParams));
126450
+ }
126451
+ else {
126452
+ response = await this.privateFuturesGetSettleOrders(this.extend(request, requestParams));
126453
+ }
126454
+ }
126455
+ else if (type === 'future') {
126456
+ if (stop) {
126457
+ response = await this.privateDeliveryGetSettlePriceOrders(this.extend(request, requestParams));
126458
+ }
126459
+ else {
126460
+ response = await this.privateDeliveryGetSettleOrders(this.extend(request, requestParams));
126461
+ }
126462
+ }
126463
+ else if (type === 'option') {
126464
+ response = await this.privateOptionsGetOrders(this.extend(request, requestParams));
126465
+ }
126466
+ else {
126467
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrders() not support this market type');
126284
126468
  }
126285
- const method = this.getSupportedMapping(type, {
126286
- 'spot': 'privateSpotGet' + methodTail,
126287
- 'margin': 'privateSpotGet' + methodTail,
126288
- 'swap': 'privateFuturesGetSettle' + methodTail,
126289
- 'future': 'privateDeliveryGetSettle' + methodTail,
126290
- 'option': 'privateOptionsGetOrders',
126291
- });
126292
- const response = await this[method](this.extend(request, requestParams));
126293
126469
  //
126294
126470
  // spot open orders
126295
126471
  //
@@ -126469,15 +126645,37 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126469
126645
  const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
126470
126646
  const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
126471
126647
  request['order_id'] = id;
126472
- const pathMiddle = stop ? 'Price' : '';
126473
- const method = this.getSupportedMapping(type, {
126474
- 'spot': 'privateSpotDelete' + pathMiddle + 'OrdersOrderId',
126475
- 'margin': 'privateSpotDelete' + pathMiddle + 'OrdersOrderId',
126476
- 'swap': 'privateFuturesDeleteSettle' + pathMiddle + 'OrdersOrderId',
126477
- 'future': 'privateDeliveryDeleteSettle' + pathMiddle + 'OrdersOrderId',
126478
- 'option': 'privateOptionsDeleteOrdersOrderId',
126479
- });
126480
- const response = await this[method](this.extend(request, requestParams));
126648
+ let response = undefined;
126649
+ if (type === 'spot' || type === 'margin') {
126650
+ if (stop) {
126651
+ response = await this.privateSpotDeletePriceOrdersOrderId(this.extend(request, requestParams));
126652
+ }
126653
+ else {
126654
+ response = await this.privateSpotDeleteOrdersOrderId(this.extend(request, requestParams));
126655
+ }
126656
+ }
126657
+ else if (type === 'swap') {
126658
+ if (stop) {
126659
+ response = await this.privateFuturesDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
126660
+ }
126661
+ else {
126662
+ response = await this.privateFuturesDeleteSettleOrdersOrderId(this.extend(request, requestParams));
126663
+ }
126664
+ }
126665
+ else if (type === 'future') {
126666
+ if (stop) {
126667
+ response = await this.privateDeliveryDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
126668
+ }
126669
+ else {
126670
+ response = await this.privateDeliveryDeleteSettleOrdersOrderId(this.extend(request, requestParams));
126671
+ }
126672
+ }
126673
+ else if (type === 'option') {
126674
+ response = await this.privateOptionsDeleteOrdersOrderId(this.extend(request, requestParams));
126675
+ }
126676
+ else {
126677
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelOrder() not support this market type');
126678
+ }
126481
126679
  //
126482
126680
  // spot
126483
126681
  //
@@ -126580,15 +126778,37 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126580
126778
  params = this.omit(params, 'stop');
126581
126779
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
126582
126780
  const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
126583
- const methodTail = stop ? 'PriceOrders' : 'Orders';
126584
- const method = this.getSupportedMapping(type, {
126585
- 'spot': 'privateSpotDelete' + methodTail,
126586
- 'margin': 'privateSpotDelete' + methodTail,
126587
- 'swap': 'privateFuturesDeleteSettle' + methodTail,
126588
- 'future': 'privateDeliveryDeleteSettle' + methodTail,
126589
- 'option': 'privateOptionsDeleteOrders',
126590
- });
126591
- const response = await this[method](this.extend(request, requestParams));
126781
+ let response = undefined;
126782
+ if (type === 'spot' || type === 'margin') {
126783
+ if (stop) {
126784
+ response = await this.privateSpotDeletePriceOrders(this.extend(request, requestParams));
126785
+ }
126786
+ else {
126787
+ response = await this.privateSpotDeleteOrders(this.extend(request, requestParams));
126788
+ }
126789
+ }
126790
+ else if (type === 'swap') {
126791
+ if (stop) {
126792
+ response = await this.privateFuturesDeleteSettlePriceOrders(this.extend(request, requestParams));
126793
+ }
126794
+ else {
126795
+ response = await this.privateFuturesDeleteSettleOrders(this.extend(request, requestParams));
126796
+ }
126797
+ }
126798
+ else if (type === 'future') {
126799
+ if (stop) {
126800
+ response = await this.privateDeliveryDeleteSettlePriceOrders(this.extend(request, requestParams));
126801
+ }
126802
+ else {
126803
+ response = await this.privateDeliveryDeleteSettleOrders(this.extend(request, requestParams));
126804
+ }
126805
+ }
126806
+ else if (type === 'option') {
126807
+ response = await this.privateOptionsDeleteOrders(this.extend(request, requestParams));
126808
+ }
126809
+ else {
126810
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelAllOrders() not support this market type');
126811
+ }
126592
126812
  //
126593
126813
  // [
126594
126814
  // {
@@ -126718,10 +126938,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126718
126938
  }
126719
126939
  await this.loadMarkets();
126720
126940
  const market = this.market(symbol);
126721
- const method = this.getSupportedMapping(market['type'], {
126722
- 'swap': 'privateFuturesPostSettlePositionsContractLeverage',
126723
- 'future': 'privateDeliveryPostSettlePositionsContractLeverage',
126724
- });
126725
126941
  const [request, query] = this.prepareRequest(market, undefined, params);
126726
126942
  const defaultMarginMode = this.safeString2(this.options, 'marginMode', 'defaultMarginMode');
126727
126943
  const crossLeverageLimit = this.safeString(query, 'cross_leverage_limit');
@@ -126737,7 +126953,16 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126737
126953
  else {
126738
126954
  request['leverage'] = leverage.toString();
126739
126955
  }
126740
- const response = await this[method](this.extend(request, query));
126956
+ let response = undefined;
126957
+ if (market['swap']) {
126958
+ response = await this.privateFuturesPostSettlePositionsContractLeverage(this.extend(request, query));
126959
+ }
126960
+ else if (market['future']) {
126961
+ response = await this.privateDeliveryPostSettlePositionsContractLeverage(this.extend(request, query));
126962
+ }
126963
+ else {
126964
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' setLeverage() not support this market type');
126965
+ }
126741
126966
  //
126742
126967
  // {
126743
126968
  // "value": "0",
@@ -126898,10 +127123,10 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126898
127123
  [request, params] = this.prepareRequest(market, market['type'], params);
126899
127124
  const extendedRequest = this.extend(request, params);
126900
127125
  let response = undefined;
126901
- if (market['type'] === 'swap') {
127126
+ if (market['swap']) {
126902
127127
  response = await this.privateFuturesGetSettlePositionsContract(extendedRequest);
126903
127128
  }
126904
- else if (market['type'] === 'future') {
127129
+ else if (market['future']) {
126905
127130
  response = await this.privateDeliveryGetSettlePositionsContract(extendedRequest);
126906
127131
  }
126907
127132
  else if (market['type'] === 'option') {
@@ -127081,11 +127306,16 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
127081
127306
  if (type !== 'future' && type !== 'swap') {
127082
127307
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchLeverageTiers only supports swap and future');
127083
127308
  }
127084
- const method = this.getSupportedMapping(type, {
127085
- 'swap': 'publicFuturesGetSettleContracts',
127086
- 'future': 'publicDeliveryGetSettleContracts',
127087
- });
127088
- const response = await this[method](this.extend(request, requestParams));
127309
+ let response = undefined;
127310
+ if (type === 'swap') {
127311
+ response = await this.publicFuturesGetSettleContracts(this.extend(request, requestParams));
127312
+ }
127313
+ else if (type === 'future') {
127314
+ response = await this.publicDeliveryGetSettleContracts(this.extend(request, requestParams));
127315
+ }
127316
+ else {
127317
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverageTiers() not support this market type');
127318
+ }
127089
127319
  //
127090
127320
  // Perpetual swap
127091
127321
  //
@@ -127591,11 +127821,16 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
127591
127821
  const market = this.market(symbol);
127592
127822
  const [request, query] = this.prepareRequest(market, undefined, params);
127593
127823
  request['change'] = this.numberToString(amount);
127594
- const method = this.getSupportedMapping(market['type'], {
127595
- 'swap': 'privateFuturesPostSettlePositionsContractMargin',
127596
- 'future': 'privateDeliveryPostSettlePositionsContractMargin',
127597
- });
127598
- const response = await this[method](this.extend(request, query));
127824
+ let response = undefined;
127825
+ if (market['swap']) {
127826
+ response = await this.privateFuturesPostSettlePositionsContractMargin(this.extend(request, query));
127827
+ }
127828
+ else if (market['future']) {
127829
+ response = await this.privateDeliveryPostSettlePositionsContractMargin(this.extend(request, query));
127830
+ }
127831
+ else {
127832
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' modifyMarginHelper() not support this market type');
127833
+ }
127599
127834
  return this.parseMarginModification(response, market);
127600
127835
  }
127601
127836
  parseMarginModification(data, market = undefined) {
@@ -173773,7 +174008,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
173773
174008
  }
173774
174009
  createSpotOrderRequest(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
173775
174010
  const symbol = market['symbol'];
173776
- const orderSide = (side === 'buy') ? 'BUY' : 'SELL';
174011
+ const orderSide = side.toUpperCase();
173777
174012
  const request = {
173778
174013
  'symbol': market['id'],
173779
174014
  'side': orderSide,
@@ -173792,10 +174027,10 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
173792
174027
  const amountString = this.numberToString(amount);
173793
174028
  const priceString = this.numberToString(price);
173794
174029
  const quoteAmount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString);
173795
- amount = this.parseNumber(quoteAmount);
174030
+ amount = quoteAmount;
173796
174031
  }
173797
174032
  }
173798
- request['quoteOrderQty'] = amount;
174033
+ request['quoteOrderQty'] = this.costToPrecision(symbol, amount);
173799
174034
  }
173800
174035
  else {
173801
174036
  request['quantity'] = this.amountToPrecision(symbol, amount);
@@ -173995,7 +174230,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
173995
174230
  ordersRequests.push(orderRequest);
173996
174231
  }
173997
174232
  const request = {
173998
- 'batchOrders': ordersRequests,
174233
+ 'batchOrders': this.json(ordersRequests),
173999
174234
  };
174000
174235
  const response = await this.spotPrivatePostBatchOrders(request);
174001
174236
  //
@@ -205735,20 +205970,23 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
205735
205970
  return;
205736
205971
  }
205737
205972
  let method = 'publicPutUserDataStream';
205973
+ const request = {};
205974
+ const symbol = this.safeString(params, 'symbol');
205975
+ const sendParams = this.omit(params, ['type', 'symbol']);
205738
205976
  if (type === 'future') {
205739
205977
  method = 'fapiPrivatePutListenKey';
205740
205978
  }
205741
205979
  else if (type === 'delivery') {
205742
205980
  method = 'dapiPrivatePutListenKey';
205743
205981
  }
205744
- else if (type === 'margin') {
205745
- method = 'sapiPutUserDataStream';
205982
+ else {
205983
+ request['listenKey'] = listenKey;
205984
+ if (type === 'margin') {
205985
+ request['symbol'] = symbol;
205986
+ method = 'sapiPutUserDataStream';
205987
+ }
205746
205988
  }
205747
- const request = {
205748
- 'listenKey': listenKey,
205749
- };
205750
205989
  const time = this.milliseconds();
205751
- const sendParams = this.omit(params, 'type');
205752
205990
  try {
205753
205991
  await this[method](this.extend(request, sendParams));
205754
205992
  }
@@ -206502,9 +206740,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206502
206740
  market = this.market(symbol);
206503
206741
  symbol = market['symbol'];
206504
206742
  messageHash += ':' + symbol;
206505
- params = this.extend(params, { 'type': market['type'], 'symbol': symbol }); // needed inside authenticate for isolated margin
206506
206743
  }
206507
- await this.authenticate(params);
206508
206744
  let type = undefined;
206509
206745
  [type, params] = this.handleMarketTypeAndParams('watchOrders', market, params);
206510
206746
  let subType = undefined;
@@ -206515,6 +206751,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206515
206751
  else if (this.isInverse(type, subType)) {
206516
206752
  type = 'delivery';
206517
206753
  }
206754
+ params = this.extend(params, { 'type': type, 'symbol': symbol }); // needed inside authenticate for isolated margin
206755
+ await this.authenticate(params);
206518
206756
  let urlType = type;
206519
206757
  if (type === 'margin') {
206520
206758
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
@@ -206819,6 +207057,9 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206819
207057
  return this.filterBySymbolsSinceLimit(cache, symbols, since, limit, true);
206820
207058
  }
206821
207059
  setPositionsCache(client, type, symbols = undefined) {
207060
+ if (type === 'spot') {
207061
+ return;
207062
+ }
206822
207063
  if (this.positions === undefined) {
206823
207064
  this.positions = {};
206824
207065
  }
@@ -288310,7 +288551,7 @@ SOFTWARE.
288310
288551
 
288311
288552
  //-----------------------------------------------------------------------------
288312
288553
  // this is updated by vss.js when building
288313
- const version = '4.1.70';
288554
+ const version = '4.1.72';
288314
288555
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
288315
288556
  //-----------------------------------------------------------------------------
288316
288557