ccxt 4.0.106 → 4.0.107

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
@@ -179,7 +179,7 @@ var woo$1 = require('./src/pro/woo.js');
179
179
 
180
180
  //-----------------------------------------------------------------------------
181
181
  // this is updated by vss.js when building
182
- const version = '4.0.106';
182
+ const version = '4.0.107';
183
183
  Exchange["default"].ccxtVersion = version;
184
184
  const exchanges = {
185
185
  'ace': ace,
@@ -34,7 +34,7 @@ class binance extends binance$1 {
34
34
  'borrowMargin': true,
35
35
  'cancelAllOrders': true,
36
36
  'cancelOrder': true,
37
- 'cancelOrders': undefined,
37
+ 'cancelOrders': true,
38
38
  'createDepositAddress': false,
39
39
  'createOrder': true,
40
40
  'createPostOnlyOrder': true,
@@ -4996,6 +4996,75 @@ class binance extends binance$1 {
4996
4996
  return response;
4997
4997
  }
4998
4998
  }
4999
+ async cancelOrders(ids, symbol = undefined, params = {}) {
5000
+ /**
5001
+ * @method
5002
+ * @name binance#cancelOrders
5003
+ * @description cancel multiple orders
5004
+ * @see https://binance-docs.github.io/apidocs/futures/en/#cancel-multiple-orders-trade
5005
+ * @param {[string]} ids order ids
5006
+ * @param {string} [symbol] unified market symbol
5007
+ * @param {object} [params] extra parameters specific to the bingx api endpoint
5008
+ *
5009
+ * EXCHANGE SPECIFIC PARAMETERS
5010
+ * @param {[string]} [params.origClientOrderIdList] max length 10 e.g. ["my_id_1","my_id_2"], encode the double quotes. No space after comma
5011
+ * @param {[int]} [params.recvWindow]
5012
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5013
+ */
5014
+ this.checkRequiredSymbol('cancelOrders', symbol);
5015
+ await this.loadMarkets();
5016
+ const market = this.market(symbol);
5017
+ if (!market['contract']) {
5018
+ throw new errors.BadRequest(this.id + ' cancelOrders is only supported for swap markets.');
5019
+ }
5020
+ const request = {
5021
+ 'symbol': market['id'],
5022
+ 'orderidlist': ids,
5023
+ };
5024
+ let response = undefined;
5025
+ if (market['linear']) {
5026
+ response = await this.fapiPrivateDeleteBatchOrders(this.extend(request, params));
5027
+ }
5028
+ else if (market['inverse']) {
5029
+ response = await this.dapiPrivateDeleteBatchOrders(this.extend(request, params));
5030
+ }
5031
+ //
5032
+ // [
5033
+ // {
5034
+ // "clientOrderId": "myOrder1",
5035
+ // "cumQty": "0",
5036
+ // "cumQuote": "0",
5037
+ // "executedQty": "0",
5038
+ // "orderId": 283194212,
5039
+ // "origQty": "11",
5040
+ // "origType": "TRAILING_STOP_MARKET",
5041
+ // "price": "0",
5042
+ // "reduceOnly": false,
5043
+ // "side": "BUY",
5044
+ // "positionSide": "SHORT",
5045
+ // "status": "CANCELED",
5046
+ // "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
5047
+ // "closePosition": false, // if Close-All
5048
+ // "symbol": "BTCUSDT",
5049
+ // "timeInForce": "GTC",
5050
+ // "type": "TRAILING_STOP_MARKET",
5051
+ // "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
5052
+ // "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
5053
+ // "updateTime": 1571110484038,
5054
+ // "workingType": "CONTRACT_PRICE",
5055
+ // "priceProtect": false, // if conditional order trigger is protected
5056
+ // "priceMatch": "NONE", // price match mode
5057
+ // "selfTradePreventionMode": "NONE", // self trading preventation mode
5058
+ // "goodTillDate": 0 // order pre-set auot cancel time for TIF GTD order
5059
+ // },
5060
+ // {
5061
+ // "code": -2011,
5062
+ // "msg": "Unknown order sent."
5063
+ // }
5064
+ // ]
5065
+ //
5066
+ return this.parseOrders(response, market);
5067
+ }
4999
5068
  async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
5000
5069
  /**
5001
5070
  * @method
@@ -8169,7 +8238,7 @@ class binance extends binance$1 {
8169
8238
  }
8170
8239
  let query = undefined;
8171
8240
  const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
8172
- const extendedParams = this.extend({
8241
+ let extendedParams = this.extend({
8173
8242
  'timestamp': this.nonce(),
8174
8243
  }, params);
8175
8244
  if (defaultRecvWindow !== undefined) {
@@ -8183,7 +8252,23 @@ class binance extends binance$1 {
8183
8252
  query = this.urlencodeWithArrayRepeat(extendedParams);
8184
8253
  }
8185
8254
  else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path.indexOf('staking') >= 0)) {
8186
- query = this.rawencode(extendedParams);
8255
+ if ((method === 'DELETE') && (path === 'batchOrders')) {
8256
+ const orderidlist = this.safeValue(extendedParams, 'orderidlist', []);
8257
+ const origclientorderidlist = this.safeValue(extendedParams, 'origclientorderidlist', []);
8258
+ extendedParams = this.omit(extendedParams, ['orderidlist', 'origclientorderidlist']);
8259
+ query = this.rawencode(extendedParams);
8260
+ const orderidlistLength = orderidlist.length;
8261
+ const origclientorderidlistLength = orderidlist.length;
8262
+ if (orderidlistLength > 0) {
8263
+ query = query + '&orderidlist=[' + orderidlist.join(',') + ']';
8264
+ }
8265
+ if (origclientorderidlistLength > 0) {
8266
+ query = query + '&origclientorderidlist=[' + origclientorderidlist.join(',') + ']';
8267
+ }
8268
+ }
8269
+ else {
8270
+ query = this.rawencode(extendedParams);
8271
+ }
8187
8272
  }
8188
8273
  else {
8189
8274
  query = this.urlencode(extendedParams);
@@ -8288,6 +8373,17 @@ class binance extends binance$1 {
8288
8373
  if (!success) {
8289
8374
  throw new errors.ExchangeError(this.id + ' ' + body);
8290
8375
  }
8376
+ if (Array.isArray(response)) {
8377
+ // cancelOrders returns an array like this: [{"code":-2011,"msg":"Unknown order sent."}]
8378
+ const numElements = response.length;
8379
+ if (numElements > 0) {
8380
+ const firstElement = response[0];
8381
+ const error = this.safeString(firstElement, 'code');
8382
+ if (error !== undefined) {
8383
+ this.throwExactlyMatchedException(this.exceptions['exact'], error, this.id + ' ' + body);
8384
+ }
8385
+ }
8386
+ }
8291
8387
  return undefined;
8292
8388
  }
8293
8389
  calculateRateLimiterCost(api, method, path, params, config = {}) {