ccxt 4.1.100 → 4.2.1

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
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
209
209
 
210
210
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
211
211
 
212
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.100/dist/ccxt.browser.js
213
- * unpkg: https://unpkg.com/ccxt@4.1.100/dist/ccxt.browser.js
212
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.1/dist/ccxt.browser.js
213
+ * unpkg: https://unpkg.com/ccxt@4.2.1/dist/ccxt.browser.js
214
214
 
215
215
  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.
216
216
 
217
217
  ```HTML
218
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.100/dist/ccxt.browser.js"></script>
218
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.1/dist/ccxt.browser.js"></script>
219
219
  ```
220
220
 
221
221
  Creates a global `ccxt` object:
@@ -43654,14 +43654,13 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43654
43654
  // "1399132.341"
43655
43655
  // ]
43656
43656
  //
43657
- const volumeIndex = (market['inverse']) ? 6 : 5;
43658
43657
  return [
43659
43658
  this.safeInteger(ohlcv, 0),
43660
43659
  this.safeNumber(ohlcv, 1),
43661
43660
  this.safeNumber(ohlcv, 2),
43662
43661
  this.safeNumber(ohlcv, 3),
43663
43662
  this.safeNumber(ohlcv, 4),
43664
- this.safeNumber(ohlcv, volumeIndex),
43663
+ this.safeNumber(ohlcv, 5),
43665
43664
  ];
43666
43665
  }
43667
43666
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
@@ -43969,10 +43968,16 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43969
43968
  // Use transferable instead of available for swap and margin https://github.com/ccxt/ccxt/pull/19127
43970
43969
  const spotAccountFree = this.safeString(entry, 'available');
43971
43970
  const contractAccountFree = this.safeString(entry, 'maxTransferOut');
43972
- account['free'] = (contractAccountFree !== undefined) ? contractAccountFree : spotAccountFree;
43973
- const frozen = this.safeString(entry, 'frozen');
43974
- const locked = this.safeString(entry, 'locked');
43975
- account['used'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(frozen, locked);
43971
+ if (contractAccountFree !== undefined) {
43972
+ account['free'] = contractAccountFree;
43973
+ account['total'] = this.safeString(entry, 'accountEquity');
43974
+ }
43975
+ else {
43976
+ account['free'] = spotAccountFree;
43977
+ const frozen = this.safeString(entry, 'frozen');
43978
+ const locked = this.safeString(entry, 'locked');
43979
+ account['used'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(frozen, locked);
43980
+ }
43976
43981
  }
43977
43982
  result[code] = account;
43978
43983
  }
@@ -86375,14 +86380,16 @@ class cex extends _abstract_cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
86375
86380
  */
86376
86381
  await this.loadMarkets();
86377
86382
  const request = {};
86378
- let method = 'privatePostOpenOrders';
86379
86383
  let market = undefined;
86384
+ let orders = undefined;
86380
86385
  if (symbol !== undefined) {
86381
86386
  market = this.market(symbol);
86382
86387
  request['pair'] = market['id'];
86383
- method += 'Pair';
86388
+ orders = await this.privatePostOpenOrdersPair(this.extend(request, params));
86389
+ }
86390
+ else {
86391
+ orders = await this.privatePostOpenOrders(this.extend(request, params));
86384
86392
  }
86385
- const orders = await this[method](this.extend(request, params));
86386
86393
  for (let i = 0; i < orders.length; i++) {
86387
86394
  orders[i] = this.extend(orders[i], { 'status': 'open' });
86388
86395
  }
@@ -86404,10 +86411,9 @@ class cex extends _abstract_cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
86404
86411
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
86405
86412
  }
86406
86413
  await this.loadMarkets();
86407
- const method = 'privatePostArchivedOrdersPair';
86408
86414
  const market = this.market(symbol);
86409
86415
  const request = { 'pair': market['id'] };
86410
- const response = await this[method](this.extend(request, params));
86416
+ const response = await this.privatePostArchivedOrdersPair(this.extend(request, params));
86411
86417
  return this.parseOrders(response, market, since, limit);
86412
86418
  }
86413
86419
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -114988,14 +114994,19 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
114988
114994
  'instrument_name': market['id'],
114989
114995
  'include_old': true,
114990
114996
  };
114991
- const method = (since === undefined) ? 'publicGetGetLastTradesByInstrument' : 'publicGetGetLastTradesByInstrumentAndTime';
114992
114997
  if (since !== undefined) {
114993
114998
  request['start_timestamp'] = since;
114994
114999
  }
114995
115000
  if (limit !== undefined) {
114996
115001
  request['count'] = Math.min(limit, 1000); // default 10
114997
115002
  }
114998
- const response = await this[method](this.extend(request, params));
115003
+ let response = undefined;
115004
+ if (since === undefined) {
115005
+ response = await this.publicGetGetLastTradesByInstrument(this.extend(request, params));
115006
+ }
115007
+ else {
115008
+ response = await this.publicGetGetLastTradesByInstrumentAndTime(this.extend(request, params));
115009
+ }
114999
115010
  //
115000
115011
  // {
115001
115012
  // "jsonrpc":"2.0",
@@ -115492,9 +115503,14 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
115492
115503
  request['time_in_force'] = 'fill_or_kill';
115493
115504
  }
115494
115505
  }
115495
- const method = 'privateGet' + this.capitalize(side);
115496
115506
  params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly']);
115497
- const response = await this[method](this.extend(request, params));
115507
+ let response = undefined;
115508
+ if (this.capitalize(side) === 'Buy') {
115509
+ response = await this.privateGetBuy(this.extend(request, params));
115510
+ }
115511
+ else {
115512
+ response = await this.privateGetSell(this.extend(request, params));
115513
+ }
115498
115514
  //
115499
115515
  // {
115500
115516
  // "jsonrpc": "2.0",
@@ -115609,16 +115625,15 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
115609
115625
  */
115610
115626
  await this.loadMarkets();
115611
115627
  const request = {};
115612
- let method = undefined;
115628
+ let response = undefined;
115613
115629
  if (symbol === undefined) {
115614
- method = 'privateGetCancelAll';
115630
+ response = await this.privateGetCancelAll(this.extend(request, params));
115615
115631
  }
115616
115632
  else {
115617
- method = 'privateGetCancelAllByInstrument';
115618
115633
  const market = this.market(symbol);
115619
115634
  request['instrument_name'] = market['id'];
115635
+ response = await this.privateGetCancelAllByInstrument(this.extend(request, params));
115620
115636
  }
115621
- const response = await this[method](this.extend(request, params));
115622
115637
  return response;
115623
115638
  }
115624
115639
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -115635,19 +115650,18 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
115635
115650
  await this.loadMarkets();
115636
115651
  const request = {};
115637
115652
  let market = undefined;
115638
- let method = undefined;
115653
+ let response = undefined;
115639
115654
  if (symbol === undefined) {
115640
115655
  const code = this.codeFromOptions('fetchOpenOrders', params);
115641
115656
  const currency = this.currency(code);
115642
115657
  request['currency'] = currency['id'];
115643
- method = 'privateGetGetOpenOrdersByCurrency';
115658
+ response = await this.privateGetGetOpenOrdersByCurrency(this.extend(request, params));
115644
115659
  }
115645
115660
  else {
115646
115661
  market = this.market(symbol);
115647
115662
  request['instrument_name'] = market['id'];
115648
- method = 'privateGetGetOpenOrdersByInstrument';
115663
+ response = await this.privateGetGetOpenOrdersByInstrument(this.extend(request, params));
115649
115664
  }
115650
- const response = await this[method](this.extend(request, params));
115651
115665
  const result = this.safeValue(response, 'result', []);
115652
115666
  return this.parseOrders(result, market, since, limit);
115653
115667
  }
@@ -115665,19 +115679,18 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
115665
115679
  await this.loadMarkets();
115666
115680
  const request = {};
115667
115681
  let market = undefined;
115668
- let method = undefined;
115682
+ let response = undefined;
115669
115683
  if (symbol === undefined) {
115670
115684
  const code = this.codeFromOptions('fetchClosedOrders', params);
115671
115685
  const currency = this.currency(code);
115672
115686
  request['currency'] = currency['id'];
115673
- method = 'privateGetGetOrderHistoryByCurrency';
115687
+ response = await this.privateGetGetOrderHistoryByCurrency(this.extend(request, params));
115674
115688
  }
115675
115689
  else {
115676
115690
  market = this.market(symbol);
115677
115691
  request['instrument_name'] = market['id'];
115678
- method = 'privateGetGetOrderHistoryByInstrument';
115692
+ response = await this.privateGetGetOrderHistoryByInstrument(this.extend(request, params));
115679
115693
  }
115680
- const response = await this[method](this.extend(request, params));
115681
115694
  const result = this.safeValue(response, 'result', []);
115682
115695
  return this.parseOrders(result, market, since, limit);
115683
115696
  }
@@ -115750,34 +115763,33 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
115750
115763
  'include_old': true,
115751
115764
  };
115752
115765
  let market = undefined;
115753
- let method = undefined;
115766
+ if (limit !== undefined) {
115767
+ request['count'] = limit; // default 10
115768
+ }
115769
+ let response = undefined;
115754
115770
  if (symbol === undefined) {
115755
115771
  const code = this.codeFromOptions('fetchMyTrades', params);
115756
115772
  const currency = this.currency(code);
115757
115773
  request['currency'] = currency['id'];
115758
115774
  if (since === undefined) {
115759
- method = 'privateGetGetUserTradesByCurrency';
115775
+ response = await this.privateGetGetUserTradesByCurrency(this.extend(request, params));
115760
115776
  }
115761
115777
  else {
115762
- method = 'privateGetGetUserTradesByCurrencyAndTime';
115763
115778
  request['start_timestamp'] = since;
115779
+ response = await this.privateGetGetUserTradesByCurrencyAndTime(this.extend(request, params));
115764
115780
  }
115765
115781
  }
115766
115782
  else {
115767
115783
  market = this.market(symbol);
115768
115784
  request['instrument_name'] = market['id'];
115769
115785
  if (since === undefined) {
115770
- method = 'privateGetGetUserTradesByInstrument';
115786
+ response = await this.privateGetGetUserTradesByInstrument(this.extend(request, params));
115771
115787
  }
115772
115788
  else {
115773
- method = 'privateGetGetUserTradesByInstrumentAndTime';
115774
115789
  request['start_timestamp'] = since;
115790
+ response = await this.privateGetGetUserTradesByInstrumentAndTime(this.extend(request, params));
115775
115791
  }
115776
115792
  }
115777
- if (limit !== undefined) {
115778
- request['count'] = limit; // default 10
115779
- }
115780
- const response = await this[method](this.extend(request, params));
115781
115793
  //
115782
115794
  // {
115783
115795
  // "jsonrpc": "2.0",
@@ -116311,7 +116323,13 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
116311
116323
  const transferOptions = this.safeValue(this.options, 'transfer', {});
116312
116324
  method = this.safeString(transferOptions, 'method', 'privateGetSubmitTransferToSubaccount');
116313
116325
  }
116314
- const response = await this[method](this.extend(request, params));
116326
+ let response = undefined;
116327
+ if (method === 'privateGetSubmitTransferToUser') {
116328
+ response = await this.privateGetSubmitTransferToUser(this.extend(request, params));
116329
+ }
116330
+ else {
116331
+ response = await this.privateGetSubmitTransferToSubaccount(this.extend(request, params));
116332
+ }
116315
116333
  //
116316
116334
  // {
116317
116335
  // "jsonrpc": "2.0",
@@ -164355,14 +164373,18 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
164355
164373
  const cancelExist = this.safeValue(order, 'cancelExist', false);
164356
164374
  let status = isActive ? 'open' : 'closed';
164357
164375
  status = cancelExist ? 'canceled' : status;
164358
- const fee = {
164359
- 'currency': feeCurrency,
164360
- 'cost': feeCost,
164361
- };
164376
+ let fee = undefined;
164377
+ if (feeCost !== undefined) {
164378
+ fee = {
164379
+ 'currency': feeCurrency,
164380
+ 'cost': feeCost,
164381
+ };
164382
+ }
164362
164383
  const clientOrderId = this.safeString(order, 'clientOid');
164363
164384
  const timeInForce = this.safeString(order, 'timeInForce');
164364
164385
  const stopPrice = this.safeNumber(order, 'stopPrice');
164365
164386
  const postOnly = this.safeValue(order, 'postOnly');
164387
+ const reduceOnly = this.safeValue(order, 'reduceOnly');
164366
164388
  const lastUpdateTimestamp = this.safeInteger(order, 'updatedAt');
164367
164389
  return this.safeOrder({
164368
164390
  'id': orderId,
@@ -164371,6 +164393,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
164371
164393
  'type': type,
164372
164394
  'timeInForce': timeInForce,
164373
164395
  'postOnly': postOnly,
164396
+ 'reduceOnly': reduceOnly,
164374
164397
  'side': side,
164375
164398
  'amount': amount,
164376
164399
  'price': price,
@@ -215711,7 +215734,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
215711
215734
  'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
215712
215735
  },
215713
215736
  'watchOrderBook': {
215714
- 'depth': 'depth50', // depth5, depth20, depth50
215737
+ 'depth': 'depth/increase100', // depth/increase100, depth5, depth20, depth50
215715
215738
  },
215716
215739
  'ws': {
215717
215740
  'inflate': true,
@@ -216729,6 +216752,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
216729
216752
  * @method
216730
216753
  * @name bitmart#watchOrderBook
216731
216754
  * @see https://developer-pro.bitmart.com/en/spot/#public-depth-all-channel
216755
+ * @see https://developer-pro.bitmart.com/en/spot/#public-depth-increase-channel
216732
216756
  * @see https://developer-pro.bitmart.com/en/futures/#public-depth-channel
216733
216757
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
216734
216758
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -216738,11 +216762,14 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
216738
216762
  */
216739
216763
  await this.loadMarkets();
216740
216764
  const options = this.safeValue(this.options, 'watchOrderBook', {});
216741
- const depth = this.safeString(options, 'depth', 'depth50');
216765
+ let depth = this.safeString(options, 'depth', 'depth/increase100');
216742
216766
  symbol = this.symbol(symbol);
216743
216767
  const market = this.market(symbol);
216744
216768
  let type = 'spot';
216745
216769
  [type, params] = this.handleMarketTypeAndParams('watchOrderBook', market, params);
216770
+ if (type === 'swap' && depth === 'depth/increase100') {
216771
+ depth = 'depth50';
216772
+ }
216746
216773
  const orderbook = await this.subscribe(depth, symbol, type, params);
216747
216774
  return orderbook.limit();
216748
216775
  }
@@ -216791,46 +216818,72 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
216791
216818
  }
216792
216819
  handleOrderBook(client, message) {
216793
216820
  //
216794
- // spot
216795
- // {
216796
- // "data": [
216797
- // {
216798
- // "asks": [
216799
- // [ '46828.38', "0.21847" ],
216800
- // [ '46830.68', "0.08232" ],
216801
- // ...
216802
- // ],
216803
- // "bids": [
216804
- // [ '46820.78', "0.00444" ],
216805
- // [ '46814.33', "0.00234" ],
216806
- // ...
216821
+ // spot depth-all
216822
+ // {
216823
+ // "data": [
216824
+ // {
216825
+ // "asks": [
216826
+ // [ '46828.38', "0.21847" ],
216827
+ // [ '46830.68', "0.08232" ],
216828
+ // ...
216829
+ // ],
216830
+ // "bids": [
216831
+ // [ '46820.78', "0.00444" ],
216832
+ // [ '46814.33', "0.00234" ],
216833
+ // ...
216834
+ // ],
216835
+ // "ms_t": 1631044962431,
216836
+ // "symbol": "BTC_USDT"
216837
+ // }
216838
+ // ],
216839
+ // "table": "spot/depth5"
216840
+ // }
216841
+ // spot increse depth snapshot
216842
+ // {
216843
+ // "data":[
216844
+ // {
216845
+ // "asks":[
216846
+ // [
216847
+ // "43652.52",
216848
+ // "0.02039"
216807
216849
  // ],
216808
- // "ms_t": 1631044962431,
216809
- // "symbol": "BTC_USDT"
216810
- // }
216811
- // ],
216812
- // "table": "spot/depth5"
216813
- // }
216850
+ // ...
216851
+ // ],
216852
+ // "bids":[
216853
+ // [
216854
+ // "43652.51",
216855
+ // "0.00500"
216856
+ // ],
216857
+ // ...
216858
+ // ],
216859
+ // "ms_t":1703376836487,
216860
+ // "symbol":"BTC_USDT",
216861
+ // "type":"snapshot", // or update
216862
+ // "version":2141731
216863
+ // }
216864
+ // ],
216865
+ // "table":"spot/depth/increase100"
216866
+ // }
216814
216867
  // swap
216815
- // {
216816
- // "group":"futures/depth50:BTCUSDT",
216817
- // "data":{
216818
- // "symbol":"BTCUSDT",
216819
- // "way":1,
216820
- // "depths":[
216821
- // {
216822
- // "price":"39509.8",
216823
- // "vol":"2379"
216824
- // },
216825
- // {
216826
- // "price":"39509.6",
216827
- // "vol":"6815"
216828
- // },
216829
- // ...
216830
- // ],
216831
- // "ms_t":1701566021194
216832
- // }
216833
- // }
216868
+ // {
216869
+ // "group":"futures/depth50:BTCUSDT",
216870
+ // "data":{
216871
+ // "symbol":"BTCUSDT",
216872
+ // "way":1,
216873
+ // "depths":[
216874
+ // {
216875
+ // "price":"39509.8",
216876
+ // "vol":"2379"
216877
+ // },
216878
+ // {
216879
+ // "price":"39509.6",
216880
+ // "vol":"6815"
216881
+ // },
216882
+ // ...
216883
+ // ],
216884
+ // "ms_t":1701566021194
216885
+ // }
216886
+ // }
216834
216887
  //
216835
216888
  const data = this.safeValue(message, 'data');
216836
216889
  if (data === undefined) {
@@ -216839,12 +216892,16 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
216839
216892
  const depths = this.safeValue(data, 'depths');
216840
216893
  const isSpot = (depths === undefined);
216841
216894
  const table = this.safeString2(message, 'table', 'group');
216842
- const parts = table.split('/');
216843
- const lastPart = this.safeString(parts, 1);
216844
- let limitString = lastPart.replace('depth', '');
216845
- const dotsIndex = limitString.indexOf(':');
216846
- limitString = limitString.slice(0, dotsIndex);
216847
- const limit = this.parseToInt(limitString);
216895
+ // find limit subscribed to
216896
+ const limitsToCheck = ['100', '50', '20', '10', '5'];
216897
+ let limit = 0;
216898
+ for (let i = 0; i < limitsToCheck.length; i++) {
216899
+ const limitString = limitsToCheck[i];
216900
+ if (table.indexOf(limitString) >= 0) {
216901
+ limit = this.parseToInt(limitString);
216902
+ break;
216903
+ }
216904
+ }
216848
216905
  if (isSpot) {
216849
216906
  for (let i = 0; i < data.length; i++) {
216850
216907
  const update = data[i];
@@ -216856,7 +216913,10 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
216856
216913
  orderbook['symbol'] = symbol;
216857
216914
  this.orderbooks[symbol] = orderbook;
216858
216915
  }
216859
- orderbook.reset({});
216916
+ const type = this.safeValue(update, 'type');
216917
+ if ((type === 'snapshot') || (!(table.indexOf('increase') >= 0))) {
216918
+ orderbook.reset({});
216919
+ }
216860
216920
  this.handleOrderBookMessage(client, update, orderbook);
216861
216921
  const timestamp = this.safeInteger(update, 'ms_t');
216862
216922
  orderbook['timestamp'] = timestamp;
@@ -217048,9 +217108,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
217048
217108
  }
217049
217109
  else {
217050
217110
  const methods = {
217051
- 'depth5': this.handleOrderBook,
217052
- 'depth20': this.handleOrderBook,
217053
- 'depth50': this.handleOrderBook,
217111
+ 'depth': this.handleOrderBook,
217054
217112
  'ticker': this.handleTicker,
217055
217113
  'trade': this.handleTrade,
217056
217114
  'kline': this.handleOHLCV,
@@ -291254,7 +291312,7 @@ SOFTWARE.
291254
291312
 
291255
291313
  //-----------------------------------------------------------------------------
291256
291314
  // this is updated by vss.js when building
291257
- const version = '4.1.100';
291315
+ const version = '4.2.1';
291258
291316
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
291259
291317
  //-----------------------------------------------------------------------------
291260
291318