ccxt 4.0.67 → 4.0.69

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/README.md +3 -3
  3. package/dist/ccxt.browser.js +193 -71
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +1 -1
  7. package/dist/cjs/src/binance.js +1 -0
  8. package/dist/cjs/src/bitget.js +18 -1
  9. package/dist/cjs/src/bybit.js +10 -0
  10. package/dist/cjs/src/lykke.js +1 -1
  11. package/dist/cjs/src/phemex.js +2 -1
  12. package/dist/cjs/src/pro/binance.js +1 -1
  13. package/dist/cjs/src/pro/bitfinex2.js +7 -6
  14. package/dist/cjs/src/pro/bitget.js +10 -7
  15. package/dist/cjs/src/pro/bitmart.js +7 -6
  16. package/dist/cjs/src/pro/bittrex.js +2 -3
  17. package/dist/cjs/src/pro/coinbasepro.js +71 -9
  18. package/dist/cjs/src/pro/huobi.js +4 -2
  19. package/dist/cjs/src/pro/idex.js +1 -1
  20. package/dist/cjs/src/pro/okx.js +22 -16
  21. package/dist/cjs/src/wavesexchange.js +34 -15
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/base/Exchange.js +1 -1
  25. package/js/src/binance.js +1 -0
  26. package/js/src/bitget.js +18 -1
  27. package/js/src/bybit.js +10 -0
  28. package/js/src/lykke.js +1 -1
  29. package/js/src/phemex.js +2 -1
  30. package/js/src/pro/binance.js +1 -1
  31. package/js/src/pro/bitfinex2.d.ts +1 -1
  32. package/js/src/pro/bitfinex2.js +7 -6
  33. package/js/src/pro/bitget.d.ts +1 -1
  34. package/js/src/pro/bitget.js +10 -7
  35. package/js/src/pro/bitmart.d.ts +1 -1
  36. package/js/src/pro/bitmart.js +7 -6
  37. package/js/src/pro/bittrex.js +2 -3
  38. package/js/src/pro/coinbasepro.d.ts +3 -1
  39. package/js/src/pro/coinbasepro.js +71 -9
  40. package/js/src/pro/huobi.js +4 -2
  41. package/js/src/pro/idex.js +1 -1
  42. package/js/src/pro/okx.d.ts +1 -0
  43. package/js/src/pro/okx.js +22 -16
  44. package/js/src/wavesexchange.d.ts +2 -1
  45. package/js/src/wavesexchange.js +34 -15
  46. package/package.json +1 -1
@@ -7841,7 +7841,7 @@ class Exchange {
7841
7841
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' fetchOrderBook() is not supported yet');
7842
7842
  }
7843
7843
  async fetchRestOrderBookSafe(symbol, limit = undefined, params = {}) {
7844
- const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'snapshotMaxRetries', 3);
7844
+ const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'maxRetries', 3);
7845
7845
  for (let i = 0; i < fetchSnapshotMaxRetries; i++) {
7846
7846
  try {
7847
7847
  const orderBook = await this.fetchOrderBook(symbol, limit, params);
@@ -17020,6 +17020,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17020
17020
  '-4045': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
17021
17021
  '-4046': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
17022
17022
  '-4047': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
17023
+ '-4054': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
17023
17024
  '-5001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
17024
17025
  '-5002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
17025
17026
  '-5003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
@@ -39095,6 +39096,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39095
39096
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
39096
39097
  * @param {int} [limit] the maximum amount of trades to fetch
39097
39098
  * @param {object} [params] extra parameters specific to the bitget api endpoint
39099
+ * @param {int} [params.until] the latest time in ms to fetch deposits for
39098
39100
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
39099
39101
  */
39100
39102
  await this.loadMarkets();
@@ -39105,9 +39107,19 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39105
39107
  if (limit !== undefined) {
39106
39108
  request['limit'] = limit;
39107
39109
  }
39110
+ const until = this.safeInteger2(params, 'until', 'endTime');
39108
39111
  if (since !== undefined) {
39109
39112
  request['startTime'] = since;
39113
+ if (until === undefined) {
39114
+ const now = this.milliseconds();
39115
+ request['endTime'] = now;
39116
+ }
39110
39117
  }
39118
+ if (until !== undefined) {
39119
+ this.checkRequiredArgument('fetchTrades', since, 'since');
39120
+ request['endTime'] = until;
39121
+ }
39122
+ params = this.omit(params, 'until');
39111
39123
  const options = this.safeValue(this.options, 'fetchTrades', {});
39112
39124
  let response = undefined;
39113
39125
  if (market['spot']) {
@@ -41464,8 +41476,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41464
41476
  */
41465
41477
  this.checkRequiredSymbol('setMarginMode', symbol);
41466
41478
  marginMode = marginMode.toLowerCase();
41479
+ if (marginMode === 'isolated') {
41480
+ marginMode = 'fixed';
41481
+ }
41482
+ if (marginMode === 'cross') {
41483
+ marginMode = 'crossed';
41484
+ }
41467
41485
  if ((marginMode !== 'fixed') && (marginMode !== 'crossed')) {
41468
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be "fixed" or "crossed"');
41486
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either fixed (isolated) or crossed (cross)');
41469
41487
  }
41470
41488
  await this.loadMarkets();
41471
41489
  const market = this.market(symbol);
@@ -72418,6 +72436,16 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
72418
72436
  }
72419
72437
  else if (symbol in this.markets_by_id) {
72420
72438
  const markets = this.markets_by_id[symbol];
72439
+ let defaultType = this.safeString2(this.options, 'defaultType', 'defaultSubType', 'spot');
72440
+ if (defaultType === 'future') {
72441
+ defaultType = 'contract';
72442
+ }
72443
+ for (let i = 0; i < markets.length; i++) {
72444
+ const market = markets[i];
72445
+ if (market[defaultType]) {
72446
+ return market;
72447
+ }
72448
+ }
72421
72449
  return markets[0];
72422
72450
  }
72423
72451
  else if ((symbol.indexOf('-C') > -1) || (symbol.indexOf('-P') > -1)) {
@@ -159694,7 +159722,7 @@ class lykke extends _abstract_lykke_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
159694
159722
  'fetchMarkets': true,
159695
159723
  'fetchMarkOHLCV': false,
159696
159724
  'fetchMyTrades': true,
159697
- 'fetchOHLCV': 'emulated',
159725
+ 'fetchOHLCV': undefined,
159698
159726
  'fetchOpenInterestHistory': false,
159699
159727
  'fetchOpenOrders': true,
159700
159728
  'fetchOrder': true,
@@ -186958,6 +186986,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
186958
186986
  }
186959
186987
  const unrealizedPnl = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(priceDiff, contracts), contractSizeString);
186960
186988
  const marginRatio = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(maintenanceMarginString, collateral);
186989
+ const isCross = this.safeValue(position, 'crossMargin');
186961
186990
  return this.safePosition({
186962
186991
  'info': position,
186963
186992
  'id': undefined,
@@ -186980,7 +187009,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
186980
187009
  'maintenanceMarginPercentage': this.parseNumber(maintenanceMarginPercentageString),
186981
187010
  'marginRatio': this.parseNumber(marginRatio),
186982
187011
  'datetime': undefined,
186983
- 'marginMode': undefined,
187012
+ 'marginMode': isCross ? 'cross' : 'isolated',
186984
187013
  'side': side,
186985
187014
  'hedged': false,
186986
187015
  'percentage': undefined,
@@ -193637,7 +193666,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193637
193666
  'name': 'kline', // or indexPriceKline or markPriceKline (coin-m futures)
193638
193667
  },
193639
193668
  'watchOrderBook': {
193640
- 'snapshotMaxRetries': 3,
193669
+ 'maxRetries': 3,
193641
193670
  },
193642
193671
  'watchBalance': {
193643
193672
  'fetchBalanceSnapshot': false,
@@ -197669,12 +197698,13 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
197669
197698
  client.subscriptions[channelId] = message;
197670
197699
  return message;
197671
197700
  }
197672
- authenticate(params = {}) {
197701
+ async authenticate(params = {}) {
197673
197702
  const url = this.urls['api']['ws']['private'];
197674
197703
  const client = this.client(url);
197675
197704
  const messageHash = 'authenticated';
197676
- let future = this.safeValue(client.subscriptions, messageHash);
197677
- if (future === undefined) {
197705
+ const future = client.future(messageHash);
197706
+ const authenticated = this.safeValue(client.subscriptions, messageHash);
197707
+ if (authenticated === undefined) {
197678
197708
  const nonce = this.milliseconds();
197679
197709
  const payload = 'AUTH' + nonce.toString();
197680
197710
  const signature = this.hmac(this.encode(payload), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__/* .sha384 */ .iC, 'hex');
@@ -197687,8 +197717,7 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
197687
197717
  'event': event,
197688
197718
  };
197689
197719
  const message = this.extend(request, params);
197690
- future = this.watch(url, messageHash, message);
197691
- client.subscriptions[messageHash] = future;
197720
+ this.watch(url, messageHash, message, messageHash);
197692
197721
  }
197693
197722
  return future;
197694
197723
  }
@@ -197697,7 +197726,8 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
197697
197726
  const status = this.safeString(message, 'status');
197698
197727
  if (status === 'OK') {
197699
197728
  // we resolve the future here permanently so authentication only happens once
197700
- client.resolve(message, messageHash);
197729
+ const future = this.safeValue(client.futures, messageHash);
197730
+ future.resolve(true);
197701
197731
  }
197702
197732
  else {
197703
197733
  const error = new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.AuthenticationError(this.json(message));
@@ -198053,7 +198083,9 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
198053
198083
  'ws': {
198054
198084
  'exact': {
198055
198085
  '30001': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
198056
- '30015': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError, // { event: 'error', code: 30015, msg: 'Invalid sign' }
198086
+ '30015': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError,
198087
+ '30016': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
198088
+ '30011': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError, // { event: 'error', code: 30011, msg: 'Invalid ACCESS_KEY' }
198057
198089
  },
198058
198090
  },
198059
198091
  },
@@ -199087,13 +199119,14 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
199087
199119
  const message = this.extend(request, params);
199088
199120
  return await this.watch(url, messageHash, message, messageHash);
199089
199121
  }
199090
- authenticate(params = {}) {
199122
+ async authenticate(params = {}) {
199091
199123
  this.checkRequiredCredentials();
199092
199124
  const url = this.urls['api']['ws'];
199093
199125
  const client = this.client(url);
199094
199126
  const messageHash = 'authenticated';
199095
- let future = this.safeValue(client.subscriptions, messageHash);
199096
- if (future === undefined) {
199127
+ const future = client.future(messageHash);
199128
+ const authenticated = this.safeValue(client.subscriptions, messageHash);
199129
+ if (authenticated === undefined) {
199097
199130
  const timestamp = this.seconds().toString();
199098
199131
  const auth = timestamp + 'GET' + '/user/verify';
199099
199132
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J, 'base64');
@@ -199110,8 +199143,7 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
199110
199143
  ],
199111
199144
  };
199112
199145
  const message = this.extend(request, params);
199113
- future = this.watch(url, messageHash, message);
199114
- client.subscriptions[messageHash] = future;
199146
+ this.watch(url, messageHash, message, messageHash);
199115
199147
  }
199116
199148
  return future;
199117
199149
  }
@@ -199130,7 +199162,8 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
199130
199162
  // { event: 'login', code: 0 }
199131
199163
  //
199132
199164
  const messageHash = 'authenticated';
199133
- client.resolve(message, messageHash);
199165
+ const future = this.safeValue(client.futures, messageHash);
199166
+ future.resolve(true);
199134
199167
  }
199135
199168
  handleErrorMessage(client, message) {
199136
199169
  //
@@ -199744,13 +199777,14 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
199744
199777
  }
199745
199778
  return message;
199746
199779
  }
199747
- authenticate(params = {}) {
199780
+ async authenticate(params = {}) {
199748
199781
  this.checkRequiredCredentials();
199749
199782
  const url = this.implodeHostname(this.urls['api']['ws']['private']);
199750
199783
  const messageHash = 'authenticated';
199751
199784
  const client = this.client(url);
199752
- let future = this.safeValue(client.subscriptions, messageHash);
199753
- if (future === undefined) {
199785
+ const future = client.future(messageHash);
199786
+ const authenticated = this.safeValue(client.subscriptions, messageHash);
199787
+ if (authenticated === undefined) {
199754
199788
  const timestamp = this.milliseconds().toString();
199755
199789
  const memo = this.uid;
199756
199790
  const path = 'bitmart.WebSocket';
@@ -199766,8 +199800,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
199766
199800
  ],
199767
199801
  };
199768
199802
  const message = this.extend(request, params);
199769
- future = this.watch(url, messageHash, message);
199770
- client.subscriptions[messageHash] = future;
199803
+ this.watch(url, messageHash, message, messageHash);
199771
199804
  }
199772
199805
  return future;
199773
199806
  }
@@ -199782,7 +199815,8 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
199782
199815
  // { event: 'login' }
199783
199816
  //
199784
199817
  const messageHash = 'authenticated';
199785
- client.resolve(message, messageHash);
199818
+ const future = this.safeValue(client.futures, messageHash);
199819
+ future.resolve(true);
199786
199820
  }
199787
199821
  handleErrorMessage(client, message) {
199788
199822
  //
@@ -204017,7 +204051,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
204017
204051
  'hub': 'c3',
204018
204052
  'I': this.milliseconds(),
204019
204053
  'watchOrderBook': {
204020
- 'snapshotMaxRetries': 3,
204054
+ 'maxRetries': 3,
204021
204055
  },
204022
204056
  },
204023
204057
  });
@@ -204603,8 +204637,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
204603
204637
  // then we cannot align it with the cached deltas and we need to
204604
204638
  // retry synchronizing in maxAttempts
204605
204639
  if ((sequence !== undefined) && (nonce < sequence)) {
204606
- const options = this.safeValue(this.options, 'fetchOrderBookSnapshot', {});
204607
- const maxAttempts = this.safeInteger(options, 'maxAttempts', 3);
204640
+ const maxAttempts = this.handleOption('watchOrderBook', 'maxRetries', 3);
204608
204641
  let numAttempts = this.safeInteger(subscription, 'numAttempts', 0);
204609
204642
  // retry to syncrhonize if we haven't reached maxAttempts yet
204610
204643
  if (numAttempts < maxAttempts) {
@@ -209833,7 +209866,7 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
209833
209866
  'watchOHLCV': false,
209834
209867
  'watchOrderBook': true,
209835
209868
  'watchTicker': true,
209836
- 'watchTickers': false,
209869
+ 'watchTickers': true,
209837
209870
  'watchTrades': true,
209838
209871
  'watchBalance': false,
209839
209872
  'watchStatus': false,
@@ -209868,10 +209901,16 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
209868
209901
  'passphrase': this.password,
209869
209902
  };
209870
209903
  }
209871
- async subscribe(name, symbol, messageHashStart, params = {}) {
209904
+ async subscribe(name, symbol = undefined, messageHashStart = undefined, params = {}) {
209872
209905
  await this.loadMarkets();
209873
- const market = this.market(symbol);
209874
- const messageHash = messageHashStart + ':' + market['id'];
209906
+ let market = undefined;
209907
+ let messageHash = messageHashStart;
209908
+ const productIds = [];
209909
+ if (symbol !== undefined) {
209910
+ market = this.market(symbol);
209911
+ messageHash += ':' + market['id'];
209912
+ productIds.push(market['id']);
209913
+ }
209875
209914
  let url = this.urls['api']['ws'];
209876
209915
  if ('signature' in params) {
209877
209916
  // need to distinguish between public trades and user trades
@@ -209879,9 +209918,33 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
209879
209918
  }
209880
209919
  const subscribe = {
209881
209920
  'type': 'subscribe',
209882
- 'product_ids': [
209883
- market['id'],
209921
+ 'product_ids': productIds,
209922
+ 'channels': [
209923
+ name,
209884
209924
  ],
209925
+ };
209926
+ const request = this.extend(subscribe, params);
209927
+ return await this.watch(url, messageHash, request, messageHash);
209928
+ }
209929
+ async subscribeMultiple(name, symbols = [], messageHashStart = undefined, params = {}) {
209930
+ await this.loadMarkets();
209931
+ let market = undefined;
209932
+ symbols = this.marketSymbols(symbols);
209933
+ const messageHash = messageHashStart + symbols.join(',');
209934
+ const productIds = [];
209935
+ for (let i = 0; i < symbols.length; i++) {
209936
+ const symbol = symbols[i];
209937
+ market = this.market(symbol);
209938
+ productIds.push(market['id']);
209939
+ }
209940
+ let url = this.urls['api']['ws'];
209941
+ if ('signature' in params) {
209942
+ // need to distinguish between public trades and user trades
209943
+ url = url + '?';
209944
+ }
209945
+ const subscribe = {
209946
+ 'type': 'subscribe',
209947
+ 'product_ids': productIds,
209885
209948
  'channels': [
209886
209949
  name,
209887
209950
  ],
@@ -209901,6 +209964,30 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
209901
209964
  const name = 'ticker';
209902
209965
  return await this.subscribe(name, symbol, name, params);
209903
209966
  }
209967
+ async watchTickers(symbols = undefined, params = {}) {
209968
+ /**
209969
+ * @method
209970
+ * @name okx#watchTickers
209971
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel
209972
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
209973
+ * @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
209974
+ * @param {object} [params] extra parameters specific to the okx api endpoint
209975
+ * @param {string} [params.channel] the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
209976
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
209977
+ */
209978
+ await this.loadMarkets();
209979
+ const symbolsLength = symbols.length;
209980
+ if (symbolsLength === 0) {
209981
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' watchTickers requires a non-empty symbols array');
209982
+ }
209983
+ const channel = 'ticker';
209984
+ const messageHash = 'tickers::';
209985
+ const newTickers = await this.subscribeMultiple(channel, symbols, messageHash, params);
209986
+ if (this.newUpdates) {
209987
+ return newTickers;
209988
+ }
209989
+ return this.filterByArray(this.tickers, 'symbol', symbols);
209990
+ }
209904
209991
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
209905
209992
  /**
209906
209993
  * @method
@@ -209932,9 +210019,7 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
209932
210019
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
209933
210020
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
209934
210021
  */
209935
- if (symbol === undefined) {
209936
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' watchMyTrades requires a symbol');
209937
- }
210022
+ this.checkRequiredSymbol('watchMyTrades', symbol);
209938
210023
  await this.loadMarkets();
209939
210024
  symbol = this.symbol(symbol);
209940
210025
  const name = 'user';
@@ -210390,6 +210475,16 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
210390
210475
  const type = this.safeString(message, 'type');
210391
210476
  const messageHash = type + ':' + marketId;
210392
210477
  client.resolve(ticker, messageHash);
210478
+ const messageHashes = this.findMessageHashes(client, 'tickers::');
210479
+ for (let i = 0; i < messageHashes.length; i++) {
210480
+ const messageHash = messageHashes[i];
210481
+ const parts = messageHash.split('::');
210482
+ const symbolsString = parts[1];
210483
+ const symbols = symbolsString.split(',');
210484
+ if (this.inArray(symbol, symbols)) {
210485
+ client.resolve(ticker, messageHash);
210486
+ }
210487
+ }
210393
210488
  }
210394
210489
  return message;
210395
210490
  }
@@ -217428,7 +217523,9 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
217428
217523
  'tradesLimit': 1000,
217429
217524
  'OHLCVLimit': 1000,
217430
217525
  'api': 'api',
217431
- 'maxOrderBookSyncAttempts': 3,
217526
+ 'watchOrderBook': {
217527
+ 'maxRetries': 3,
217528
+ },
217432
217529
  'ws': {
217433
217530
  'gunzip': true,
217434
217531
  },
@@ -217726,7 +217823,7 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
217726
217823
  const snapshotOrderBook = this.orderBook(snapshot, snapshotLimit);
217727
217824
  client.resolve(snapshotOrderBook, id);
217728
217825
  if ((sequence !== undefined) && (nonce < sequence)) {
217729
- const maxAttempts = this.safeInteger(this.options, 'maxOrderBookSyncAttempts', 3);
217826
+ const maxAttempts = this.handleOption('watchOrderBook', 'maxRetries', 3);
217730
217827
  let numAttempts = this.safeInteger(subscription, 'numAttempts', 0);
217731
217828
  // retry to synchronize if we have not reached maxAttempts yet
217732
217829
  if (numAttempts < maxAttempts) {
@@ -220205,7 +220302,7 @@ class idex extends _idex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
220205
220302
  'orderBookSubscriptions': {},
220206
220303
  'token': undefined,
220207
220304
  'watchOrderBook': {
220208
- 'snapshotMaxRetries': 3,
220305
+ 'maxRetries': 3,
220209
220306
  },
220210
220307
  'fetchOrderBookSnapshotMaxAttempts': 10,
220211
220308
  'fetchOrderBookSnapshotMaxDelay': 10000, // throw if there are no orders in 10 seconds
@@ -228346,16 +228443,10 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
228346
228443
  },
228347
228444
  'urls': {
228348
228445
  'api': {
228349
- 'ws': {
228350
- 'public': 'wss://ws.okx.com:8443/ws/v5/public',
228351
- 'private': 'wss://ws.okx.com:8443/ws/v5/private', // wss://wsaws.okx.com:8443/ws/v5/private
228352
- },
228446
+ 'ws': 'wss://ws.okx.com:8443/ws/v5',
228353
228447
  },
228354
228448
  'test': {
228355
- 'ws': {
228356
- 'public': 'wss://wspap.okx.com:8443/ws/v5/public?brokerId=9999',
228357
- 'private': 'wss://wspap.okx.com:8443/ws/v5/private?brokerId=9999',
228358
- },
228449
+ 'ws': 'wss://wspap.okx.com:8443/ws/v5',
228359
228450
  },
228360
228451
  },
228361
228452
  'options': {
@@ -228417,13 +228508,25 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
228417
228508
  },
228418
228509
  });
228419
228510
  }
228511
+ getUrl(channel, access = 'public') {
228512
+ // for context: https://www.okx.com/help-center/changes-to-v5-api-websocket-subscription-parameter-and-url
228513
+ const isPublic = (access === 'public');
228514
+ const url = this.urls['api']['ws'];
228515
+ if ((channel.indexOf('candle') > -1) || (channel === 'orders-algo')) {
228516
+ return url + '/business';
228517
+ }
228518
+ else if (isPublic) {
228519
+ return url + '/public';
228520
+ }
228521
+ return url + '/private';
228522
+ }
228420
228523
  async subscribeMultiple(access, channel, symbols = undefined, params = {}) {
228421
228524
  await this.loadMarkets();
228422
228525
  if (symbols === undefined) {
228423
228526
  symbols = this.symbols;
228424
228527
  }
228425
228528
  symbols = this.marketSymbols(symbols);
228426
- const url = this.urls['api']['ws'][access];
228529
+ const url = this.getUrl(channel, access);
228427
228530
  let messageHash = channel;
228428
228531
  const args = [];
228429
228532
  messageHash += '::' + symbols.join(',');
@@ -228443,7 +228546,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
228443
228546
  }
228444
228547
  async subscribe(access, messageHash, channel, symbol, params = {}) {
228445
228548
  await this.loadMarkets();
228446
- const url = this.urls['api']['ws'][access];
228549
+ const url = this.getUrl(channel, access);
228447
228550
  const firstArgument = {
228448
228551
  'channel': channel,
228449
228552
  };
@@ -228915,7 +229018,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
228915
229018
  this.checkRequiredCredentials();
228916
229019
  const access = this.safeString(params, 'access', 'private');
228917
229020
  params = this.omit(params, ['access']);
228918
- const url = this.urls['api']['ws'][access];
229021
+ const url = this.getUrl('users', access);
228919
229022
  const messageHash = 'authenticated';
228920
229023
  const client = this.client(url);
228921
229024
  let future = this.safeValue(client.subscriptions, messageHash);
@@ -229306,7 +229409,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
229306
229409
  */
229307
229410
  await this.loadMarkets();
229308
229411
  await this.authenticate();
229309
- const url = this.urls['api']['ws']['private'];
229412
+ const url = this.getUrl('private', 'private');
229310
229413
  const messageHash = this.nonce().toString();
229311
229414
  let op = undefined;
229312
229415
  [op, params] = this.handleOptionAndParams(params, 'createOrderWs', 'op', 'batch-orders');
@@ -229375,7 +229478,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
229375
229478
  */
229376
229479
  await this.loadMarkets();
229377
229480
  await this.authenticate();
229378
- const url = this.urls['api']['ws']['private'];
229481
+ const url = this.getUrl('private', 'private');
229379
229482
  const messageHash = this.nonce().toString();
229380
229483
  let op = undefined;
229381
229484
  [op, params] = this.handleOptionAndParams(params, 'editOrderWs', 'op', 'amend-order');
@@ -229404,7 +229507,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
229404
229507
  }
229405
229508
  await this.loadMarkets();
229406
229509
  await this.authenticate();
229407
- const url = this.urls['api']['ws']['private'];
229510
+ const url = this.getUrl('private', 'private');
229408
229511
  const messageHash = this.nonce().toString();
229409
229512
  const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
229410
229513
  params = this.omit(params, ['clientOrderId', 'clOrdId']);
@@ -229444,7 +229547,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
229444
229547
  }
229445
229548
  await this.loadMarkets();
229446
229549
  await this.authenticate();
229447
- const url = this.urls['api']['ws']['private'];
229550
+ const url = this.getUrl('private', 'private');
229448
229551
  const messageHash = this.nonce().toString();
229449
229552
  const args = [];
229450
229553
  for (let i = 0; i < idsLength; i++) {
@@ -229480,7 +229583,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
229480
229583
  if (market['type'] !== 'option') {
229481
229584
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + 'cancelAllOrdersWs is only applicable to Option in Portfolio Margin mode, and MMP privilege is required.');
229482
229585
  }
229483
- const url = this.urls['api']['ws']['private'];
229586
+ const url = this.getUrl('private', 'private');
229484
229587
  const messageHash = this.nonce().toString();
229485
229588
  const request = {
229486
229589
  'id': messageHash,
@@ -254915,19 +255018,32 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
254915
255018
  }
254916
255019
  parseOrderBookSide(bookSide, market = undefined, limit = undefined) {
254917
255020
  const precision = market['precision'];
254918
- const wavesPrecision = this.safeInteger(this.options, 'wavesPrecision', 8);
254919
- const amountPrecision = Math.pow(10, precision['amount']);
254920
- const difference = precision['amount'] - precision['price'];
254921
- const pricePrecision = Math.pow(10, wavesPrecision - difference);
255021
+ const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
255022
+ const amountPrecision = '1e' + this.numberToString(precision['amount']);
255023
+ const amountPrecisionString = this.numberToString(precision['amount']);
255024
+ const pricePrecisionString = this.numberToString(precision['price']);
255025
+ const difference = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(amountPrecisionString, pricePrecisionString);
255026
+ const pricePrecision = '1e' + _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(wavesPrecision, difference);
254922
255027
  const result = [];
254923
255028
  for (let i = 0; i < bookSide.length; i++) {
254924
255029
  const entry = bookSide[i];
254925
- const price = this.safeInteger(entry, 'price', 0) / pricePrecision;
254926
- const amount = this.safeInteger(entry, 'amount', 0) / amountPrecision;
255030
+ const entryPrice = this.safeString(entry, 'price', '0');
255031
+ const entryAmount = this.safeString(entry, 'amount', '0');
255032
+ let price = undefined;
255033
+ let amount = undefined;
255034
+ if ((pricePrecision !== undefined) && (entryPrice !== undefined)) {
255035
+ price = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(entryPrice, pricePrecision);
255036
+ }
255037
+ if ((amountPrecision !== undefined) && (entryAmount !== undefined)) {
255038
+ amount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(entryAmount, amountPrecision);
255039
+ }
254927
255040
  if ((limit !== undefined) && (i > limit)) {
254928
255041
  break;
254929
255042
  }
254930
- result.push([price, amount]);
255043
+ result.push([
255044
+ this.parseNumber(price),
255045
+ this.parseNumber(amount),
255046
+ ]);
254931
255047
  }
254932
255048
  return result;
254933
255049
  }
@@ -255507,15 +255623,21 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
255507
255623
  }
255508
255624
  customPriceToPrecision(symbol, price) {
255509
255625
  const market = this.markets[symbol];
255510
- const wavesPrecision = this.safeInteger(this.options, 'wavesPrecision', 8);
255511
- const difference = market['precision']['amount'] - market['precision']['price'];
255512
- return this.parseToInt(parseFloat(this.toPrecision(price, wavesPrecision - difference)));
255626
+ const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
255627
+ const amount = this.numberToString(market['precision']['amount']);
255628
+ const precisionPrice = this.numberToString(market['precision']['price']);
255629
+ const difference = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(amount, precisionPrice);
255630
+ const precision = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(wavesPrecision, difference);
255631
+ const pricePrecision = this.toPrecision(price, precision).toString();
255632
+ return this.parseToInt(parseFloat(pricePrecision));
255513
255633
  }
255514
255634
  customAmountToPrecision(symbol, amount) {
255515
- return this.parseToInt(parseFloat(this.toPrecision(amount, this.markets[symbol]['precision']['amount'])));
255635
+ const amountPrecision = this.numberToString(this.toPrecision(amount, this.numberToString(this.markets[symbol]['precision']['amount'])));
255636
+ return this.parseToInt(parseFloat(amountPrecision));
255516
255637
  }
255517
255638
  currencyToPrecision(code, amount, networkCode = undefined) {
255518
- return this.parseToInt(parseFloat(this.toPrecision(amount, this.currencies[code]['precision'])));
255639
+ const amountPrecision = this.numberToString(this.toPrecision(amount, this.currencies[code]['precision']));
255640
+ return this.parseToInt(parseFloat(amountPrecision));
255519
255641
  }
255520
255642
  fromPrecision(amount, scale) {
255521
255643
  if (amount === undefined) {
@@ -255527,11 +255649,11 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
255527
255649
  return precise.toString();
255528
255650
  }
255529
255651
  toPrecision(amount, scale) {
255530
- const amountString = amount.toString();
255652
+ const amountString = this.numberToString(amount);
255531
255653
  const precise = new _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O(amountString);
255532
- precise.decimals = precise.decimals - scale;
255654
+ precise.decimals = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(precise.decimals, scale);
255533
255655
  precise.reduce();
255534
- return precise.toString();
255656
+ return precise;
255535
255657
  }
255536
255658
  currencyFromPrecision(currency, amount) {
255537
255659
  const scale = this.currencies[currency]['precision'];
@@ -272226,7 +272348,7 @@ SOFTWARE.
272226
272348
 
272227
272349
  //-----------------------------------------------------------------------------
272228
272350
  // this is updated by vss.js when building
272229
- const version = '4.0.67';
272351
+ const version = '4.0.69';
272230
272352
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
272231
272353
  //-----------------------------------------------------------------------------
272232
272354