ccxt 4.0.94 → 4.0.96

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
@@ -215,13 +215,13 @@ console.log(version, Object.keys(exchanges));
215
215
 
216
216
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
217
217
 
218
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.94/dist/ccxt.browser.js
219
- * unpkg: https://unpkg.com/ccxt@4.0.94/dist/ccxt.browser.js
218
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.96/dist/ccxt.browser.js
219
+ * unpkg: https://unpkg.com/ccxt@4.0.96/dist/ccxt.browser.js
220
220
 
221
221
  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.
222
222
 
223
223
  ```HTML
224
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.94/dist/ccxt.browser.js"></script>
224
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.96/dist/ccxt.browser.js"></script>
225
225
  ```
226
226
 
227
227
  Creates a global `ccxt` object:
@@ -43429,6 +43429,8 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
43429
43429
  'fetchMarkets': true,
43430
43430
  'fetchMyTrades': true,
43431
43431
  'fetchOHLCV': true,
43432
+ 'fetchOpenInterest': true,
43433
+ 'fetchOpenInterestHistory': false,
43432
43434
  'fetchOpenOrders': true,
43433
43435
  'fetchOrder': true,
43434
43436
  'fetchOrderBook': true,
@@ -46515,6 +46517,61 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
46515
46517
  'info': info,
46516
46518
  };
46517
46519
  }
46520
+ async fetchOpenInterest(symbol, params = {}) {
46521
+ /**
46522
+ * @method
46523
+ * @name bitmart#fetchOpenInterest
46524
+ * @description Retrieves the open interest of a currency
46525
+ * @see https://developer-pro.bitmart.com/en/futures/#get-futures-openinterest
46526
+ * @param {string} symbol Unified CCXT market symbol
46527
+ * @param {object} [params] exchange specific parameters
46528
+ * @returns {object} an open interest structure{@link https://github.com/ccxt/ccxt/wiki/Manual#interest-history-structure}
46529
+ */
46530
+ await this.loadMarkets();
46531
+ const market = this.market(symbol);
46532
+ if (!market['contract']) {
46533
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
46534
+ }
46535
+ const request = {
46536
+ 'symbol': market['id'],
46537
+ };
46538
+ const response = await this.publicGetContractPublicOpenInterest(this.extend(request, params));
46539
+ //
46540
+ // {
46541
+ // "code": 1000,
46542
+ // "message": "Ok",
46543
+ // "data": {
46544
+ // "timestamp": 1694657502415,
46545
+ // "symbol": "BTCUSDT",
46546
+ // "open_interest": "265231.721368593081729069",
46547
+ // "open_interest_value": "7006353.83988919"
46548
+ // },
46549
+ // "trace": "7f9c94e10f9d4513bc08a7bfc2a5559a.72.16946575108274991"
46550
+ // }
46551
+ //
46552
+ const data = this.safeValue(response, 'data', {});
46553
+ return this.parseOpenInterest(data, market);
46554
+ }
46555
+ parseOpenInterest(interest, market = undefined) {
46556
+ //
46557
+ // {
46558
+ // "timestamp": 1694657502415,
46559
+ // "symbol": "BTCUSDT",
46560
+ // "open_interest": "265231.721368593081729069",
46561
+ // "open_interest_value": "7006353.83988919"
46562
+ // }
46563
+ //
46564
+ const timestamp = this.safeInteger(interest, 'timestamp');
46565
+ const id = this.safeString(interest, 'symbol');
46566
+ return {
46567
+ 'symbol': this.safeSymbol(id, market),
46568
+ 'openInterestAmount': this.safeNumber(interest, 'open_interest'),
46569
+ 'openInterestValue': this.safeNumber(interest, 'open_interest_value'),
46570
+ 'timestamp': timestamp,
46571
+ 'datetime': this.iso8601(timestamp),
46572
+ 'info': interest,
46573
+ };
46574
+ }
46518
46575
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
46519
46576
  /**
46520
46577
  * @ignore
@@ -55823,14 +55880,24 @@ class bitso extends _abstract_bitso_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
55823
55880
  const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
55824
55881
  const marketId = this.safeString(trade, 'book');
55825
55882
  const symbol = this.safeSymbol(marketId, market, '_');
55826
- const side = this.safeString2(trade, 'side', 'maker_side');
55883
+ let side = this.safeString(trade, 'side');
55827
55884
  const makerSide = this.safeString(trade, 'maker_side');
55828
55885
  let takerOrMaker = undefined;
55829
- if (side === makerSide) {
55830
- takerOrMaker = 'maker';
55886
+ if (side !== undefined) {
55887
+ if (side === makerSide) {
55888
+ takerOrMaker = 'maker';
55889
+ }
55890
+ else {
55891
+ takerOrMaker = 'taker';
55892
+ }
55831
55893
  }
55832
55894
  else {
55833
- takerOrMaker = 'taker';
55895
+ if (makerSide === 'buy') {
55896
+ side = 'sell';
55897
+ }
55898
+ else {
55899
+ side = 'buy';
55900
+ }
55834
55901
  }
55835
55902
  let amount = this.safeString2(trade, 'amount', 'major');
55836
55903
  if (amount !== undefined) {
@@ -70292,6 +70359,21 @@ class btctradeua extends _abstract_btctradeua_js__WEBPACK_IMPORTED_MODULE_0__/*
70292
70359
  return timestamp - 10800000;
70293
70360
  }
70294
70361
  parseTrade(trade, market = undefined) {
70362
+ //
70363
+ // fetchTrades
70364
+ //
70365
+ // {
70366
+ // "amnt_base": "2220.1204701750",
70367
+ // "order_id": 247644861,
70368
+ // "unixtime": 1694340398,
70369
+ // "price": "1019739.3229211044",
70370
+ // "amnt_trade": "0.0021771451",
70371
+ // "user": "Vasily1989",
70372
+ // "type": "sell",
70373
+ // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
70374
+ // "id": 7498807
70375
+ // }
70376
+ //
70295
70377
  const timestamp = this.parseExchangeSpecificDatetime(this.safeString(trade, 'pub_date'));
70296
70378
  const id = this.safeString(trade, 'id');
70297
70379
  const type = 'limit';
@@ -70332,6 +70414,21 @@ class btctradeua extends _abstract_btctradeua_js__WEBPACK_IMPORTED_MODULE_0__/*
70332
70414
  'symbol': market['id'],
70333
70415
  };
70334
70416
  const response = await this.publicGetDealsSymbol(this.extend(request, params));
70417
+ //
70418
+ // [
70419
+ // {
70420
+ // "amnt_base": "2220.1204701750",
70421
+ // "order_id": 247644861,
70422
+ // "unixtime": 1694340398,
70423
+ // "price": "1019739.3229211044",
70424
+ // "amnt_trade": "0.0021771451",
70425
+ // "user": "Vasily1989",
70426
+ // "type": "sell",
70427
+ // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
70428
+ // "id": 7498807
70429
+ // },
70430
+ // ]
70431
+ //
70335
70432
  // they report each trade twice (once for both of the two sides of the fill)
70336
70433
  // deduplicate trades for that reason
70337
70434
  const trades = [];
@@ -110749,7 +110846,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
110749
110846
  request['symbol'] = market['id'];
110750
110847
  }
110751
110848
  if (limit !== undefined) {
110752
- request['limit'] = limit;
110849
+ request['limit'] = market['swap'] ? Math.min(limit, 100) : limit;
110753
110850
  }
110754
110851
  const response = await this[method](this.extend(request, params));
110755
110852
  //
@@ -124827,7 +124924,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
124827
124924
  request['symbols'] = market['id'];
124828
124925
  }
124829
124926
  if (limit !== undefined) {
124830
- request['limit'] = limit;
124927
+ request['limit'] = Math.min(limit, 1000);
124831
124928
  }
124832
124929
  if (since !== undefined) {
124833
124930
  request['from'] = since;
@@ -155512,10 +155609,10 @@ class latoken extends _abstract_latoken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
155512
155609
  'currency': market['baseId'],
155513
155610
  'quote': market['quoteId'],
155514
155611
  // 'from': since.toString (), // milliseconds
155515
- // 'limit': limit, // default 100, max 1000
155612
+ // 'limit': limit, // default 100, limit 100
155516
155613
  };
155517
155614
  if (limit !== undefined) {
155518
- request['limit'] = limit; // default 100, max 1000
155615
+ request['limit'] = Math.min(limit, 100); // default 100, limit 100
155519
155616
  }
155520
155617
  const response = await this.publicGetTradeHistoryCurrencyQuote(this.extend(request, params));
155521
155618
  //
@@ -240578,7 +240675,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
240578
240675
  request['start_time'] = this.iso8601(since);
240579
240676
  }
240580
240677
  if (limit !== undefined) {
240581
- request['limit'] = limit;
240678
+ request['limit'] = Math.min(limit, 10000);
240582
240679
  }
240583
240680
  const response = await this.publicGetTrade(this.extend(request, params));
240584
240681
  //
@@ -260639,7 +260736,7 @@ class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
260639
260736
  'symbol': market['id'],
260640
260737
  };
260641
260738
  if (limit !== undefined) {
260642
- request['limit'] = limit; // Default 500; max 1000.
260739
+ request['limit'] = Math.min(limit, 1000); // Default 500; max 1000.
260643
260740
  }
260644
260741
  const method = this.safeString(this.options, 'fetchTradesMethod', 'publicGetTrades');
260645
260742
  const response = await this[method](this.extend(request, params));
@@ -275536,7 +275633,7 @@ SOFTWARE.
275536
275633
 
275537
275634
  //-----------------------------------------------------------------------------
275538
275635
  // this is updated by vss.js when building
275539
- const version = '4.0.94';
275636
+ const version = '4.0.96';
275540
275637
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
275541
275638
  //-----------------------------------------------------------------------------
275542
275639