ccxt 4.3.73 → 4.3.74

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/js/src/woo.js CHANGED
@@ -147,7 +147,7 @@ export default class woo extends Exchange {
147
147
  'https://support.woo.org/hc/en-001/articles/4404611795353--Trading-Fees',
148
148
  ],
149
149
  'referral': {
150
- 'url': 'https://x.woo.org/register?ref=YWOWC96B',
150
+ 'url': 'https://x.woo.org/register?ref=DIJT0CNL',
151
151
  'discount': 0.35,
152
152
  },
153
153
  },
package/js/src/yobit.d.ts CHANGED
@@ -12,6 +12,7 @@ export default class yobit extends Exchange {
12
12
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
13
13
  fetchOrderBooks(symbols?: Strings, limit?: Int, params?: {}): Promise<Dictionary<OrderBook>>;
14
14
  parseTicker(ticker: Dict, market?: Market): Ticker;
15
+ fetchTickersHelper(idsString: string, params?: {}): Promise<Tickers>;
15
16
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
16
17
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
17
18
  parseTrade(trade: Dict, market?: Market): Trade;
package/js/src/yobit.js CHANGED
@@ -550,6 +550,22 @@ export default class yobit extends Exchange {
550
550
  'info': ticker,
551
551
  }, market);
552
552
  }
553
+ async fetchTickersHelper(idsString, params = {}) {
554
+ const request = {
555
+ 'pair': idsString,
556
+ };
557
+ const tickers = await this.publicGetTickerPair(this.extend(request, params));
558
+ const result = {};
559
+ const keys = Object.keys(tickers);
560
+ for (let k = 0; k < keys.length; k++) {
561
+ const id = keys[k];
562
+ const ticker = tickers[id];
563
+ const market = this.safeMarket(id);
564
+ const symbol = market['symbol'];
565
+ result[symbol] = this.parseTicker(ticker, market);
566
+ }
567
+ return result;
568
+ }
553
569
  async fetchTickers(symbols = undefined, params = {}) {
554
570
  /**
555
571
  * @method
@@ -558,43 +574,53 @@ export default class yobit extends Exchange {
558
574
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
559
575
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
560
576
  * @param {object} [params] extra parameters specific to the exchange API endpoint
577
+ * @param {object} [params.all] you can set to `true` for convenience to fetch all tickers from this exchange by sending multiple requests
561
578
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
562
579
  */
563
- if (symbols === undefined) {
564
- throw new ArgumentsRequired(this.id + ' fetchTickers() requires "symbols" argument');
580
+ let allSymbols = undefined;
581
+ [allSymbols, params] = this.handleParamBool(params, 'all', false);
582
+ if (symbols === undefined && !allSymbols) {
583
+ throw new ArgumentsRequired(this.id + ' fetchTickers() requires "symbols" argument or use `params["all"] = true` to send multiple requests for all markets');
565
584
  }
566
585
  await this.loadMarkets();
567
- symbols = this.marketSymbols(symbols);
568
- let ids = undefined;
569
- if (symbols === undefined) {
570
- ids = this.ids;
571
- }
572
- else {
573
- ids = this.marketIds(symbols);
574
- }
575
- const idsLength = ids.length;
576
- const idsString = ids.join('-');
586
+ const promises = [];
577
587
  const maxLength = this.safeInteger(this.options, 'maxUrlLength', 2048);
578
588
  // max URL length is 2048 symbols, including http schema, hostname, tld, etc...
579
- const lenghtOfBaseUrl = 30; // the url including api-base and endpoint dir is 30 chars
580
- const actualLength = idsString.length + lenghtOfBaseUrl;
581
- if (actualLength > maxLength) {
582
- throw new ArgumentsRequired(this.id + ' fetchTickers() is being requested for ' + idsLength.toString() + ' markets (which has an URL length of ' + actualLength.toString() + ' characters), but it exceedes max URL length (' + maxLength.toString() + '), please pass limisted symbols array to fetchTickers to fit in one request');
589
+ const lenghtOfBaseUrl = 40; // safe space for the url including api-base and endpoint dir is 30 chars
590
+ if (allSymbols) {
591
+ symbols = this.symbols;
592
+ let ids = '';
593
+ for (let i = 0; i < this.ids.length; i++) {
594
+ const id = this.ids[i];
595
+ const prefix = (ids === '') ? '' : '-';
596
+ ids += prefix + id;
597
+ if (ids.length > maxLength) {
598
+ promises.push(this.fetchTickersHelper(ids, params));
599
+ ids = '';
600
+ }
601
+ }
602
+ if (ids !== '') {
603
+ promises.push(this.fetchTickersHelper(ids, params));
604
+ }
583
605
  }
584
- const request = {
585
- 'pair': idsString,
586
- };
587
- const tickers = await this.publicGetTickerPair(this.extend(request, params));
588
- const result = {};
589
- const keys = Object.keys(tickers);
590
- for (let k = 0; k < keys.length; k++) {
591
- const id = keys[k];
592
- const ticker = tickers[id];
593
- const market = this.safeMarket(id);
594
- const symbol = market['symbol'];
595
- result[symbol] = this.parseTicker(ticker, market);
606
+ else {
607
+ symbols = this.marketSymbols(symbols);
608
+ const ids = this.marketIds(symbols);
609
+ const idsLength = ids.length;
610
+ const idsString = ids.join('-');
611
+ const actualLength = idsString.length + lenghtOfBaseUrl;
612
+ if (actualLength > maxLength) {
613
+ throw new ArgumentsRequired(this.id + ' fetchTickers() is being requested for ' + idsLength.toString() + ' markets (which has an URL length of ' + actualLength.toString() + ' characters), but it exceedes max URL length (' + maxLength.toString() + '), please pass limisted symbols array to fetchTickers to fit in one request');
614
+ }
615
+ promises.push(this.fetchTickersHelper(idsString, params));
616
+ }
617
+ const resultAll = await Promise.all(promises);
618
+ let finalResult = {};
619
+ for (let i = 0; i < resultAll.length; i++) {
620
+ const result = this.filterByArrayTickers(resultAll[i], 'symbol', symbols);
621
+ finalResult = this.extend(finalResult, result);
596
622
  }
597
- return this.filterByArrayTickers(result, 'symbol', symbols);
623
+ return finalResult;
598
624
  }
599
625
  async fetchTicker(symbol, params = {}) {
600
626
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.73",
3
+ "version": "4.3.74",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",