ccxt 4.3.47 → 4.3.48

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.
package/dist/cjs/ccxt.js CHANGED
@@ -188,7 +188,7 @@ var woofipro$1 = require('./src/pro/woofipro.js');
188
188
 
189
189
  //-----------------------------------------------------------------------------
190
190
  // this is updated by vss.js when building
191
- const version = '4.3.47';
191
+ const version = '4.3.48';
192
192
  Exchange["default"].ccxtVersion = version;
193
193
  const exchanges = {
194
194
  'ace': ace,
@@ -6166,7 +6166,7 @@ class binance extends binance$1 {
6166
6166
  if (!market['spot']) {
6167
6167
  throw new errors.NotSupported(this.id + ' createMarketOrderWithCost() supports spot orders only');
6168
6168
  }
6169
- params['quoteOrderQty'] = cost;
6169
+ params['cost'] = cost;
6170
6170
  return await this.createOrder(symbol, 'market', side, cost, undefined, params);
6171
6171
  }
6172
6172
  async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
@@ -6185,7 +6185,7 @@ class binance extends binance$1 {
6185
6185
  if (!market['spot']) {
6186
6186
  throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
6187
6187
  }
6188
- params['quoteOrderQty'] = cost;
6188
+ params['cost'] = cost;
6189
6189
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
6190
6190
  }
6191
6191
  async createMarketSellOrderWithCost(symbol, cost, params = {}) {
@@ -7920,6 +7920,9 @@ class binance extends binance$1 {
7920
7920
  return this.parseTransactions(response, currency, since, limit);
7921
7921
  }
7922
7922
  parseTransactionStatusByType(status, type = undefined) {
7923
+ if (type === undefined) {
7924
+ return status;
7925
+ }
7923
7926
  const statusesByType = {
7924
7927
  'deposit': {
7925
7928
  '0': 'pending',
@@ -8806,7 +8809,7 @@ class binance extends binance$1 {
8806
8809
  const request = {
8807
8810
  'coin': currency['id'],
8808
8811
  'address': address,
8809
- 'amount': amount,
8812
+ 'amount': this.currencyToPrecision(code, amount),
8810
8813
  // https://binance-docs.github.io/apidocs/spot/en/#withdraw-sapi
8811
8814
  // issue sapiGetCapitalConfigGetall () to get networks for withdrawing USDT ERC20 vs USDT Omni
8812
8815
  // 'network': 'ETH', // 'BTC', 'TRX', etc, optional
@@ -779,6 +779,7 @@ class gate extends gate$1 {
779
779
  'NOT_ACCEPTABLE': errors.BadRequest,
780
780
  'METHOD_NOT_ALLOWED': errors.BadRequest,
781
781
  'NOT_FOUND': errors.ExchangeError,
782
+ 'AUTHENTICATION_FAILED': errors.AuthenticationError,
782
783
  'INVALID_CREDENTIALS': errors.AuthenticationError,
783
784
  'INVALID_KEY': errors.AuthenticationError,
784
785
  'IP_FORBIDDEN': errors.AuthenticationError,
@@ -3879,19 +3880,16 @@ class gate extends gate$1 {
3879
3880
  //
3880
3881
  return this.parseOrder(response, market);
3881
3882
  }
3882
- async createOrders(orders, params = {}) {
3883
- /**
3884
- * @method
3885
- * @name gate#createOrders
3886
- * @description create a list of trade orders
3887
- * @see https://www.gate.io/docs/developers/apiv4/en/#get-a-single-order-2
3888
- * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-batch-of-orders
3889
- * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
3890
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3891
- */
3892
- await this.loadMarkets();
3883
+ createOrdersRequest(orders, params = {}) {
3893
3884
  const ordersRequests = [];
3894
3885
  const orderSymbols = [];
3886
+ const ordersLength = orders.length;
3887
+ if (ordersLength === 0) {
3888
+ throw new errors.BadRequest(this.id + ' createOrders() requires at least one order');
3889
+ }
3890
+ if (ordersLength > 10) {
3891
+ throw new errors.BadRequest(this.id + ' createOrders() accepts a maximum of 10 orders at a time');
3892
+ }
3895
3893
  for (let i = 0; i < orders.length; i++) {
3896
3894
  const rawOrder = orders[i];
3897
3895
  const marketId = this.safeString(rawOrder, 'symbol');
@@ -3915,6 +3913,23 @@ class gate extends gate$1 {
3915
3913
  if (market['future'] || market['option']) {
3916
3914
  throw new errors.NotSupported(this.id + ' createOrders() does not support futures or options markets');
3917
3915
  }
3916
+ return ordersRequests;
3917
+ }
3918
+ async createOrders(orders, params = {}) {
3919
+ /**
3920
+ * @method
3921
+ * @name gate#createOrders
3922
+ * @description create a list of trade orders
3923
+ * @see https://www.gate.io/docs/developers/apiv4/en/#get-a-single-order-2
3924
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-batch-of-orders
3925
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-batch-of-futures-orders
3926
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
3927
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3928
+ */
3929
+ await this.loadMarkets();
3930
+ const ordersRequests = this.createOrdersRequest(orders, params);
3931
+ const firstOrder = orders[0];
3932
+ const market = this.market(firstOrder['symbol']);
3918
3933
  let response = undefined;
3919
3934
  if (market['spot']) {
3920
3935
  response = await this.privateSpotPostBatchOrders(ordersRequests);
@@ -4197,23 +4212,7 @@ class gate extends gate$1 {
4197
4212
  params['createMarketBuyOrderRequiresPrice'] = false;
4198
4213
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
4199
4214
  }
4200
- async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4201
- /**
4202
- * @method
4203
- * @name gate#editOrder
4204
- * @description edit a trade order, gate currently only supports the modification of the price or amount fields
4205
- * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order
4206
- * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order-2
4207
- * @param {string} id order id
4208
- * @param {string} symbol unified symbol of the market to create an order in
4209
- * @param {string} type 'market' or 'limit'
4210
- * @param {string} side 'buy' or 'sell'
4211
- * @param {float} amount how much of the currency you want to trade in units of the base currency
4212
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
4213
- * @param {object} [params] extra parameters specific to the exchange API endpoint
4214
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4215
- */
4216
- await this.loadMarkets();
4215
+ editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4217
4216
  const market = this.market(symbol);
4218
4217
  const [marketType, query] = this.handleMarketTypeAndParams('editOrder', market, params);
4219
4218
  const account = this.convertTypeToAccount(marketType);
@@ -4225,7 +4224,7 @@ class gate extends gate$1 {
4225
4224
  }
4226
4225
  }
4227
4226
  const request = {
4228
- 'order_id': id,
4227
+ 'order_id': id.toString(),
4229
4228
  'currency_pair': market['id'],
4230
4229
  'account': account,
4231
4230
  };
@@ -4245,13 +4244,36 @@ class gate extends gate$1 {
4245
4244
  if (price !== undefined) {
4246
4245
  request['price'] = this.priceToPrecision(symbol, price);
4247
4246
  }
4247
+ if (!market['spot']) {
4248
+ request['settle'] = market['settleId'];
4249
+ }
4250
+ return this.extend(request, query);
4251
+ }
4252
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4253
+ /**
4254
+ * @method
4255
+ * @name gate#editOrder
4256
+ * @description edit a trade order, gate currently only supports the modification of the price or amount fields
4257
+ * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order
4258
+ * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order-2
4259
+ * @param {string} id order id
4260
+ * @param {string} symbol unified symbol of the market to create an order in
4261
+ * @param {string} type 'market' or 'limit'
4262
+ * @param {string} side 'buy' or 'sell'
4263
+ * @param {float} amount how much of the currency you want to trade in units of the base currency
4264
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
4265
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4266
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4267
+ */
4268
+ await this.loadMarkets();
4269
+ const market = this.market(symbol);
4270
+ const extendedRequest = this.editOrderRequest(id, symbol, type, side, amount, price, params);
4248
4271
  let response = undefined;
4249
4272
  if (market['spot']) {
4250
- response = await this.privateSpotPatchOrdersOrderId(this.extend(request, query));
4273
+ response = await this.privateSpotPatchOrdersOrderId(extendedRequest);
4251
4274
  }
4252
4275
  else {
4253
- request['settle'] = market['settleId'];
4254
- response = await this.privateFuturesPutSettleOrdersOrderId(this.extend(request, query));
4276
+ response = await this.privateFuturesPutSettleOrdersOrderId(extendedRequest);
4255
4277
  }
4256
4278
  //
4257
4279
  // {
@@ -4565,6 +4587,25 @@ class gate extends gate$1 {
4565
4587
  'info': order,
4566
4588
  }, market);
4567
4589
  }
4590
+ fetchOrderRequest(id, symbol = undefined, params = {}) {
4591
+ const market = (symbol === undefined) ? undefined : this.market(symbol);
4592
+ const stop = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
4593
+ params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
4594
+ let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
4595
+ let orderId = id;
4596
+ if (clientOrderId !== undefined) {
4597
+ params = this.omit(params, ['text', 'clientOrderId']);
4598
+ if (clientOrderId[0] !== 't') {
4599
+ clientOrderId = 't-' + clientOrderId;
4600
+ }
4601
+ orderId = clientOrderId;
4602
+ }
4603
+ const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
4604
+ const contract = (type === 'swap') || (type === 'future') || (type === 'option');
4605
+ const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market, stop, query);
4606
+ request['order_id'] = orderId.toString();
4607
+ return [request, requestParams];
4608
+ }
4568
4609
  async fetchOrder(id, symbol = undefined, params = {}) {
4569
4610
  /**
4570
4611
  * @method
@@ -4577,29 +4618,18 @@ class gate extends gate$1 {
4577
4618
  * @param {string} id Order id
4578
4619
  * @param {string} symbol Unified market symbol, *required for spot and margin*
4579
4620
  * @param {object} [params] Parameters specified by the exchange api
4580
- * @param {bool} [params.stop] True if the order being fetched is a trigger order
4621
+ * @param {bool} [params.trigger] True if the order being fetched is a trigger order
4581
4622
  * @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
4582
4623
  * @param {string} [params.type] 'spot', 'swap', or 'future', if not provided this.options['defaultMarginMode'] is used
4583
4624
  * @param {string} [params.settle] 'btc' or 'usdt' - settle currency for perpetual swap and future - market settle currency is used if symbol !== undefined, default="usdt" for swap and "btc" for future
4584
4625
  * @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4585
4626
  */
4586
4627
  await this.loadMarkets();
4587
- const stop = this.safeValue2(params, 'is_stop_order', 'stop', false);
4588
- params = this.omit(params, ['is_stop_order', 'stop']);
4589
- let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
4590
- let orderId = id;
4591
- if (clientOrderId !== undefined) {
4592
- params = this.omit(params, ['text', 'clientOrderId']);
4593
- if (clientOrderId[0] !== 't') {
4594
- clientOrderId = 't-' + clientOrderId;
4595
- }
4596
- orderId = clientOrderId;
4597
- }
4598
4628
  const market = (symbol === undefined) ? undefined : this.market(symbol);
4599
- const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
4600
- const contract = (type === 'swap') || (type === 'future') || (type === 'option');
4601
- const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market, stop, query);
4602
- request['order_id'] = orderId;
4629
+ const result = this.handleMarketTypeAndParams('fetchOrder', market, params);
4630
+ const type = this.safeString(result, 0);
4631
+ const stop = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
4632
+ const [request, requestParams] = this.fetchOrderRequest(id, symbol, params);
4603
4633
  let response = undefined;
4604
4634
  if (type === 'spot' || type === 'margin') {
4605
4635
  if (stop) {
@@ -4673,15 +4703,14 @@ class gate extends gate$1 {
4673
4703
  */
4674
4704
  return await this.fetchOrdersByStatus('finished', symbol, since, limit, params);
4675
4705
  }
4676
- async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
4677
- await this.loadMarkets();
4706
+ fetchOrdersByStatusRequest(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
4678
4707
  let market = undefined;
4679
4708
  if (symbol !== undefined) {
4680
4709
  market = this.market(symbol);
4681
4710
  symbol = market['symbol'];
4682
4711
  }
4683
- const stop = this.safeValue(params, 'stop');
4684
- params = this.omit(params, 'stop');
4712
+ const stop = this.safeBool2(params, 'stop', 'trigger');
4713
+ params = this.omit(params, ['stop', 'trigger']);
4685
4714
  const [type, query] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
4686
4715
  const spot = (type === 'spot') || (type === 'margin');
4687
4716
  const [request, requestParams] = spot ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
@@ -4695,6 +4724,26 @@ class gate extends gate$1 {
4695
4724
  if (since !== undefined && spot) {
4696
4725
  request['from'] = this.parseToInt(since / 1000);
4697
4726
  }
4727
+ const [lastId, finalParams] = this.handleParamString2(requestParams, 'lastId', 'last_id');
4728
+ if (lastId !== undefined) {
4729
+ request['last_id'] = lastId;
4730
+ }
4731
+ return [request, finalParams];
4732
+ }
4733
+ async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
4734
+ await this.loadMarkets();
4735
+ let market = undefined;
4736
+ if (symbol !== undefined) {
4737
+ market = this.market(symbol);
4738
+ symbol = market['symbol'];
4739
+ }
4740
+ const stop = this.safeBool2(params, 'stop', 'trigger');
4741
+ params = this.omit(params, ['trigger', 'stop']);
4742
+ const res = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
4743
+ const type = this.safeString(res, 0);
4744
+ params['type'] = type;
4745
+ const [request, requestParams] = this.fetchOrdersByStatusRequest(status, symbol, since, limit, params);
4746
+ const spot = (type === 'spot') || (type === 'margin');
4698
4747
  const openSpotOrders = spot && (status === 'open') && !stop;
4699
4748
  let response = undefined;
4700
4749
  if (type === 'spot' || type === 'margin') {
@@ -4904,8 +4953,8 @@ class gate extends gate$1 {
4904
4953
  */
4905
4954
  await this.loadMarkets();
4906
4955
  const market = (symbol === undefined) ? undefined : this.market(symbol);
4907
- const stop = this.safeValue2(params, 'is_stop_order', 'stop', false);
4908
- params = this.omit(params, ['is_stop_order', 'stop']);
4956
+ const stop = this.safeBoolN(params, ['is_stop_order', 'stop', 'trigger'], false);
4957
+ params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
4909
4958
  const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
4910
4959
  const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
4911
4960
  request['order_id'] = id;
@@ -121,6 +121,8 @@ class krakenfutures extends krakenfutures$1 {
121
121
  'transfers',
122
122
  'leveragepreferences',
123
123
  'pnlpreferences',
124
+ 'assignmentprogram/current',
125
+ 'assignmentprogram/history',
124
126
  ],
125
127
  'post': [
126
128
  'sendorder',
@@ -130,7 +132,9 @@ class krakenfutures extends krakenfutures$1 {
130
132
  'batchorder',
131
133
  'cancelallorders',
132
134
  'cancelallordersafter',
133
- 'withdrawal', // for futures wallet -> kraken spot wallet
135
+ 'withdrawal',
136
+ 'assignmentprogram/add',
137
+ 'assignmentprogram/delete',
134
138
  ],
135
139
  'put': [
136
140
  'leveragepreferences',
@@ -739,16 +739,16 @@ class bingx extends bingx$1 {
739
739
  // ]
740
740
  // }
741
741
  //
742
- const data = this.safeList(message, 'data', []);
742
+ const isSwap = client.url.indexOf('swap') >= 0;
743
743
  let candles = undefined;
744
- if (Array.isArray(data)) {
745
- candles = data;
744
+ if (isSwap) {
745
+ candles = this.safeList(message, 'data', []);
746
746
  }
747
747
  else {
748
- candles = [this.safeList(data, 'K', [])];
748
+ const data = this.safeDict(message, 'data', {});
749
+ candles = [this.safeDict(data, 'K', {})];
749
750
  }
750
751
  const dataType = this.safeString(message, 'dataType');
751
- const isSwap = client.url.indexOf('swap') >= 0;
752
752
  const parts = dataType.split('@');
753
753
  const firstPart = parts[0];
754
754
  const isAllEndpoint = (firstPart === 'all');