ccxt 4.1.22 → 4.1.24

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/README.md CHANGED
@@ -210,13 +210,13 @@ console.log(version, Object.keys(exchanges));
210
210
 
211
211
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
212
212
 
213
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.22/dist/ccxt.browser.js
214
- * unpkg: https://unpkg.com/ccxt@4.1.22/dist/ccxt.browser.js
213
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.24/dist/ccxt.browser.js
214
+ * unpkg: https://unpkg.com/ccxt@4.1.24/dist/ccxt.browser.js
215
215
 
216
216
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
217
217
 
218
218
  ```HTML
219
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.22/dist/ccxt.browser.js"></script>
219
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.24/dist/ccxt.browser.js"></script>
220
220
  ```
221
221
 
222
222
  Creates a global `ccxt` object:
@@ -561,6 +561,10 @@ Thank you!
561
561
  - [CCXT Channel on Telegram](https://t.me/ccxt_announcements) (important announcements)
562
562
  - [CCXT Chat on Telegram](https://t.me/ccxt_chat) (technical support)
563
563
 
564
+ ## Star History
565
+
566
+ [![Star History Chart](https://api.star-history.com/svg?repos=ccxt/ccxt&type=Date)](https://star-history.com/#ccxt/ccxt&Date)
567
+
564
568
  ## Contact Us
565
569
 
566
570
  For business inquiries: info@ccxt.trade
@@ -3601,6 +3601,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
3601
3601
  'futures/position': 1,
3602
3602
  'futures/free-margin': 1,
3603
3603
  'futures/order/hist/current': 1,
3604
+ 'futures/funding-payments': 1,
3604
3605
  'futures/order/open': 1,
3605
3606
  'futures/order/status': 1,
3606
3607
  },
@@ -13968,14 +13969,22 @@ class IndexedOrderBookSide extends Array {
13968
13969
  // in case price is not sent
13969
13970
  delta[0] = Math.abs(index_price);
13970
13971
  if (index_price === old_price) {
13971
- const index = bisectLeft(this.index, index_price);
13972
+ // find index by price and advance till the id is found
13973
+ let index = bisectLeft(this.index, index_price);
13974
+ while (this[index][2] !== id) {
13975
+ index++;
13976
+ }
13972
13977
  this.index[index] = index_price;
13973
13978
  this[index] = delta;
13974
13979
  return;
13975
13980
  }
13976
13981
  else {
13977
13982
  // remove old price from index
13978
- const old_index = bisectLeft(this.index, old_price);
13983
+ // find index by price and advance till the id is found
13984
+ let old_index = bisectLeft(this.index, old_price);
13985
+ while (this[old_index][2] !== id) {
13986
+ old_index++;
13987
+ }
13979
13988
  this.index.copyWithin(old_index, old_index + 1, this.index.length);
13980
13989
  this.index[this.length - 1] = Number.MAX_VALUE;
13981
13990
  this.copyWithin(old_index, old_index + 1, this.length);
@@ -13984,7 +13993,12 @@ class IndexedOrderBookSide extends Array {
13984
13993
  }
13985
13994
  // insert new price level
13986
13995
  this.hashmap.set(id, index_price);
13987
- const index = bisectLeft(this.index, index_price);
13996
+ // find index by price to insert
13997
+ let index = bisectLeft(this.index, index_price);
13998
+ // if several with the same price order by id
13999
+ while (index < this.length && this.index[index] === index_price && this[index][2] < id) {
14000
+ index++;
14001
+ }
13988
14002
  // insert new price level into index
13989
14003
  this.length++;
13990
14004
  this.index.copyWithin(index + 1, index, this.index.length);
@@ -14001,7 +14015,10 @@ class IndexedOrderBookSide extends Array {
14001
14015
  }
14002
14016
  else if (this.hashmap.has(id)) {
14003
14017
  const old_price = this.hashmap.get(id);
14004
- const index = bisectLeft(this.index, old_price);
14018
+ let index = bisectLeft(this.index, old_price);
14019
+ while (this[index][2] !== id) {
14020
+ index++;
14021
+ }
14005
14022
  this.index.copyWithin(index, index + 1, this.index.length);
14006
14023
  this.index[this.length - 1] = Number.MAX_VALUE;
14007
14024
  this.copyWithin(index, index + 1, this.length);
@@ -16271,7 +16288,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16271
16288
  'v1': 'https://testnet.binance.vision/api/v1',
16272
16289
  },
16273
16290
  'api': {
16274
- 'wapi': 'https://api.binance.com/wapi/v3',
16275
16291
  'sapi': 'https://api.binance.com/sapi/v1',
16276
16292
  'sapiV2': 'https://api.binance.com/sapi/v2',
16277
16293
  'sapiV3': 'https://api.binance.com/sapi/v3',
@@ -16715,27 +16731,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16715
16731
  'sub-account/assets': 0.40002, // Weight(UID): 60 => cost = 0.006667 * 60 = 0.40002
16716
16732
  },
16717
16733
  },
16718
- // deprecated
16719
- 'wapi': {
16720
- 'post': {
16721
- 'withdraw': 1,
16722
- 'sub-account/transfer': 1,
16723
- },
16724
- 'get': {
16725
- 'depositHistory': 1,
16726
- 'withdrawHistory': 1,
16727
- 'depositAddress': 1,
16728
- 'accountStatus': 1,
16729
- 'systemStatus': 1,
16730
- 'apiTradingStatus': 1,
16731
- 'userAssetDribbletLog': 1,
16732
- 'tradeFee': 1,
16733
- 'assetDetail': 1,
16734
- 'sub-account/list': 1,
16735
- 'sub-account/transfer/history': 1,
16736
- 'sub-account/assets': 1,
16737
- },
16738
- },
16739
16734
  'dapiPublic': {
16740
16735
  'get': {
16741
16736
  'ping': 1,
@@ -16849,6 +16844,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16849
16844
  },
16850
16845
  'fapiData': {
16851
16846
  'get': {
16847
+ 'delivery-price': 1,
16852
16848
  'openInterestHist': 1,
16853
16849
  'topLongShortAccountRatio': 1,
16854
16850
  'topLongShortPositionRatio': 1,
@@ -24529,9 +24525,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24529
24525
  }
24530
24526
  let url = this.urls['api'][api];
24531
24527
  url += '/' + path;
24532
- if (api === 'wapi') {
24533
- url += '.html';
24534
- }
24535
24528
  if (path === 'historicalTrades') {
24536
24529
  if (this.apiKey) {
24537
24530
  headers = {
@@ -24558,7 +24551,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24558
24551
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError(this.id + ' userDataStream endpoint requires `apiKey` credential');
24559
24552
  }
24560
24553
  }
24561
- else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi')) {
24554
+ else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi')) {
24562
24555
  this.checkRequiredCredentials();
24563
24556
  if (method === 'POST' && ((path === 'order') || (path === 'sor/order'))) {
24564
24557
  // inject in implicit API calls
@@ -24620,7 +24613,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24620
24613
  headers = {
24621
24614
  'X-MBX-APIKEY': this.apiKey,
24622
24615
  };
24623
- if ((method === 'GET') || (method === 'DELETE') || (api === 'wapi')) {
24616
+ if ((method === 'GET') || (method === 'DELETE')) {
24624
24617
  url += '?' + query;
24625
24618
  }
24626
24619
  else {
@@ -24656,7 +24649,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24656
24649
  if (response === undefined) {
24657
24650
  return undefined; // fallback to default error handler
24658
24651
  }
24659
- // check success value for wapi endpoints
24660
24652
  // response in format {'msg': 'The coin does not exist.', 'success': true/false}
24661
24653
  const success = this.safeValue(response, 'success', true);
24662
24654
  if (!success) {
@@ -24747,7 +24739,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24747
24739
  async request(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined, config = {}, context = {}) {
24748
24740
  const response = await this.fetch2(path, api, method, params, headers, body, config);
24749
24741
  // a workaround for {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
24750
- if ((api === 'private') || (api === 'wapi')) {
24742
+ if (api === 'private') {
24751
24743
  this.options['hasAlreadyAuthenticatedSuccessfully'] = true;
24752
24744
  }
24753
24745
  return response;
@@ -47910,7 +47902,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
47910
47902
  '7': 'canceling',
47911
47903
  '8': 'canceled',
47912
47904
  'new': 'open',
47913
- 'partially_filled': 'filled',
47905
+ 'partially_filled': 'open',
47914
47906
  'filled': 'filled',
47915
47907
  'partially_canceled': 'canceled',
47916
47908
  },
@@ -76302,8 +76294,10 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76302
76294
  request['accountType'] = unifiedType;
76303
76295
  response = await this.privateGetV5AssetTransferQueryAccountCoinsBalance(this.extend(request, params));
76304
76296
  }
76305
- request['accountType'] = unifiedType;
76306
- response = await this.privateGetV5AccountWalletBalance(this.extend(request, params));
76297
+ else {
76298
+ request['accountType'] = unifiedType;
76299
+ response = await this.privateGetV5AccountWalletBalance(this.extend(request, params));
76300
+ }
76307
76301
  //
76308
76302
  // cross
76309
76303
  // {
@@ -146222,6 +146216,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
146222
146216
  'option': false,
146223
146217
  'cancelAllOrders': true,
146224
146218
  'cancelOrder': true,
146219
+ 'cancelOrders': true,
146225
146220
  'createMarketOrder': false,
146226
146221
  'createOrder': true,
146227
146222
  'editOrder': true,
@@ -147152,6 +147147,70 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
147152
147147
  }
147153
147148
  return this.extend({ 'info': response }, order);
147154
147149
  }
147150
+ async cancelOrders(ids, symbol = undefined, params = {}) {
147151
+ /**
147152
+ * @method
147153
+ * @name krakenfutures#cancelOrders
147154
+ * @description cancel multiple orders
147155
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-batch-order-management
147156
+ * @param {[string]} ids order ids
147157
+ * @param {string} [symbol] unified market symbol
147158
+ * @param {object} [params] extra parameters specific to the bingx api endpoint
147159
+ *
147160
+ * EXCHANGE SPECIFIC PARAMETERS
147161
+ * @param {[string]} [params.clientOrderIds] max length 10 e.g. ["my_id_1","my_id_2"]
147162
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
147163
+ */
147164
+ await this.loadMarkets();
147165
+ const orders = [];
147166
+ const clientOrderIds = this.safeValue(params, 'clientOrderIds', []);
147167
+ const clientOrderIdsLength = clientOrderIds.length;
147168
+ if (clientOrderIdsLength > 0) {
147169
+ for (let i = 0; i < clientOrderIds.length; i++) {
147170
+ orders.push({ 'order': 'cancel', 'cliOrdId': clientOrderIds[i] });
147171
+ }
147172
+ }
147173
+ else {
147174
+ for (let i = 0; i < ids.length; i++) {
147175
+ orders.push({ 'order': 'cancel', 'order_id': ids[i] });
147176
+ }
147177
+ }
147178
+ const request = {
147179
+ 'batchOrder': orders,
147180
+ };
147181
+ const response = await this.privatePostBatchorder(this.extend(request, params));
147182
+ // {
147183
+ // result: 'success',
147184
+ // serverTime: '2023-10-23T16:36:51.327Z',
147185
+ // batchStatus: [
147186
+ // {
147187
+ // status: 'cancelled',
147188
+ // order_id: '101c2327-f12e-45f2-8445-7502b87afc0b',
147189
+ // orderEvents: [
147190
+ // {
147191
+ // uid: '101c2327-f12e-45f2-8445-7502b87afc0b',
147192
+ // order: {
147193
+ // orderId: '101c2327-f12e-45f2-8445-7502b87afc0b',
147194
+ // cliOrdId: null,
147195
+ // type: 'lmt',
147196
+ // symbol: 'PF_LTCUSD',
147197
+ // side: 'buy',
147198
+ // quantity: '0.10000000000',
147199
+ // filled: '0E-11',
147200
+ // limitPrice: '50.00000000000',
147201
+ // reduceOnly: false,
147202
+ // timestamp: '2023-10-20T10:29:13.005Z',
147203
+ // lastUpdateTimestamp: '2023-10-20T10:29:13.005Z'
147204
+ // },
147205
+ // type: 'CANCEL'
147206
+ // }
147207
+ // ]
147208
+ // }
147209
+ // ]
147210
+ // }
147211
+ const batchStatus = this.safeValue(response, 'batchStatus', []);
147212
+ return this.parseOrders(batchStatus);
147213
+ }
147155
147214
  async cancelAllOrders(symbol = undefined, params = {}) {
147156
147215
  /**
147157
147216
  * @method
@@ -148338,7 +148397,11 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
148338
148397
  params = this.omit(params, this.extractParams(path));
148339
148398
  let query = endpoint;
148340
148399
  let postData = '';
148341
- if (Object.keys(params).length) {
148400
+ if (path === 'batchorder') {
148401
+ postData = 'json=' + this.json(params);
148402
+ body = postData;
148403
+ }
148404
+ else if (Object.keys(params).length) {
148342
148405
  postData = this.urlencode(params);
148343
148406
  query += '?' + postData;
148344
148407
  }
@@ -148353,7 +148416,8 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
148353
148416
  const secret = this.base64ToBinary(this.secret); // 3
148354
148417
  const signature = this.hmac(hash, secret, _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_5__/* .sha512 */ .o, 'base64'); // 4-5
148355
148418
  headers = {
148356
- 'Content-Type': 'application/json',
148419
+ 'Content-Type': 'application/x-www-form-urlencoded',
148420
+ 'Accept': 'application/json',
148357
148421
  'APIKey': this.apiKey,
148358
148422
  'Authent': signature,
148359
148423
  };
@@ -200955,7 +201019,6 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
200955
201019
  const messageHash = channel + ':' + marketId;
200956
201020
  const prec = this.safeString(subscription, 'prec', 'P0');
200957
201021
  const isRaw = (prec === 'R0');
200958
- const id = this.safeString(message, 0);
200959
201022
  // if it is an initial snapshot
200960
201023
  let orderbook = this.safeValue(this.orderbooks, symbol);
200961
201024
  if (orderbook === undefined) {
@@ -200994,6 +201057,7 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
200994
201057
  bookside.store(price, size, counter);
200995
201058
  }
200996
201059
  }
201060
+ orderbook['symbol'] = symbol;
200997
201061
  client.resolve(orderbook, messageHash);
200998
201062
  }
200999
201063
  else {
@@ -201006,7 +201070,8 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
201006
201070
  const bookside = orderbookItem[side];
201007
201071
  // price = 0 means that you have to remove the order from your book
201008
201072
  const amount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringGt */ .O.stringGt(price, '0') ? size : '0';
201009
- bookside.store(this.parseNumber(price), this.parseNumber(amount), id);
201073
+ const idString = this.safeString(deltas, 0);
201074
+ bookside.store(this.parseNumber(price), this.parseNumber(amount), idString);
201010
201075
  }
201011
201076
  else {
201012
201077
  const amount = this.safeString(deltas, 2);
@@ -201036,16 +201101,19 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
201036
201101
  const stringArray = [];
201037
201102
  const bids = book['bids'];
201038
201103
  const asks = book['asks'];
201104
+ const prec = this.safeString(subscription, 'prec', 'P0');
201105
+ const isRaw = (prec === 'R0');
201106
+ const idToCheck = isRaw ? 2 : 0;
201039
201107
  // pepperoni pizza from bitfinex
201040
201108
  for (let i = 0; i < depth; i++) {
201041
201109
  const bid = this.safeValue(bids, i);
201042
201110
  const ask = this.safeValue(asks, i);
201043
201111
  if (bid !== undefined) {
201044
- stringArray.push(this.numberToString(bids[i][0]));
201112
+ stringArray.push(this.numberToString(bids[i][idToCheck]));
201045
201113
  stringArray.push(this.numberToString(bids[i][1]));
201046
201114
  }
201047
201115
  if (ask !== undefined) {
201048
- stringArray.push(this.numberToString(asks[i][0]));
201116
+ stringArray.push(this.numberToString(asks[i][idToCheck]));
201049
201117
  stringArray.push(this.numberToString(-asks[i][1]));
201050
201118
  }
201051
201119
  }
@@ -277678,7 +277746,7 @@ SOFTWARE.
277678
277746
 
277679
277747
  //-----------------------------------------------------------------------------
277680
277748
  // this is updated by vss.js when building
277681
- const version = '4.1.22';
277749
+ const version = '4.1.24';
277682
277750
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
277683
277751
  //-----------------------------------------------------------------------------
277684
277752