ccxt 4.2.19 → 4.2.21

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 (64) hide show
  1. package/README.md +98 -98
  2. package/dist/ccxt.browser.js +1119 -364
  3. package/dist/ccxt.browser.min.js +6 -6
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +47 -4
  6. package/dist/cjs/src/base/ws/WsClient.js +3 -1
  7. package/dist/cjs/src/binance.js +2 -1
  8. package/dist/cjs/src/binanceus.js +17 -0
  9. package/dist/cjs/src/bingx.js +2 -1
  10. package/dist/cjs/src/bitget.js +25 -31
  11. package/dist/cjs/src/bitteam.js +1 -1
  12. package/dist/cjs/src/bitvavo.js +271 -172
  13. package/dist/cjs/src/blockchaincom.js +3 -1
  14. package/dist/cjs/src/bybit.js +0 -28
  15. package/dist/cjs/src/delta.js +0 -18
  16. package/dist/cjs/src/gate.js +32 -26
  17. package/dist/cjs/src/kucoinfutures.js +9 -9
  18. package/dist/cjs/src/novadax.js +26 -22
  19. package/dist/cjs/src/okx.js +0 -18
  20. package/dist/cjs/src/phemex.js +2 -1
  21. package/dist/cjs/src/pro/bitopro.js +7 -3
  22. package/dist/cjs/src/pro/bitvavo.js +668 -22
  23. package/dist/cjs/src/pro/lbank.js +1 -1
  24. package/js/ccxt.d.ts +1 -1
  25. package/js/ccxt.js +1 -1
  26. package/js/src/abstract/binance.d.ts +1 -0
  27. package/js/src/abstract/binancecoinm.d.ts +1 -0
  28. package/js/src/abstract/binanceus.d.ts +1 -0
  29. package/js/src/abstract/binanceusdm.d.ts +1 -0
  30. package/js/src/abstract/bitpanda.js +11 -0
  31. package/js/src/abstract/gate.d.ts +1 -0
  32. package/js/src/abstract/gateio.d.ts +1 -0
  33. package/js/src/abstract/novadax.d.ts +5 -1
  34. package/js/src/abstract/phemex.d.ts +1 -0
  35. package/js/src/base/Exchange.d.ts +15 -1
  36. package/js/src/base/Exchange.js +47 -4
  37. package/js/src/base/ws/WsClient.js +3 -2
  38. package/js/src/binance.js +2 -1
  39. package/js/src/binanceus.js +17 -0
  40. package/js/src/bingx.js +2 -1
  41. package/js/src/bitget.d.ts +1 -1
  42. package/js/src/bitget.js +25 -31
  43. package/js/src/bitteam.js +1 -1
  44. package/js/src/bitvavo.d.ts +14 -2
  45. package/js/src/bitvavo.js +271 -172
  46. package/js/src/blockchaincom.js +3 -1
  47. package/js/src/bybit.d.ts +0 -1
  48. package/js/src/bybit.js +1 -29
  49. package/js/src/delta.d.ts +0 -1
  50. package/js/src/delta.js +0 -18
  51. package/js/src/gate.d.ts +1 -1
  52. package/js/src/gate.js +32 -26
  53. package/js/src/kucoinfutures.d.ts +6 -6
  54. package/js/src/kucoinfutures.js +9 -9
  55. package/js/src/novadax.js +26 -22
  56. package/js/src/okx.d.ts +0 -1
  57. package/js/src/okx.js +0 -18
  58. package/js/src/phemex.js +2 -1
  59. package/js/src/pro/bitopro.js +7 -3
  60. package/js/src/pro/bitvavo.d.ts +35 -2
  61. package/js/src/pro/bitvavo.js +669 -23
  62. package/js/src/pro/lbank.js +1 -1
  63. package/package.json +1 -1
  64. package/skip-tests.json +2 -1
@@ -1248,34 +1248,6 @@ class bybit extends bybit$1 {
1248
1248
  'info': undefined,
1249
1249
  };
1250
1250
  }
1251
- market(symbol) {
1252
- if (this.markets === undefined) {
1253
- throw new errors.ExchangeError(this.id + ' markets not loaded');
1254
- }
1255
- if (typeof symbol === 'string') {
1256
- if (symbol in this.markets) {
1257
- return this.markets[symbol];
1258
- }
1259
- else if (symbol in this.markets_by_id) {
1260
- const markets = this.markets_by_id[symbol];
1261
- let defaultType = this.safeString2(this.options, 'defaultType', 'defaultSubType', 'spot');
1262
- if (defaultType === 'future') {
1263
- defaultType = 'contract';
1264
- }
1265
- for (let i = 0; i < markets.length; i++) {
1266
- const market = markets[i];
1267
- if (market[defaultType]) {
1268
- return market;
1269
- }
1270
- }
1271
- return markets[0];
1272
- }
1273
- else if ((symbol.indexOf('-C') > -1) || (symbol.indexOf('-P') > -1)) {
1274
- return this.createExpiredOptionMarket(symbol);
1275
- }
1276
- }
1277
- throw new errors.BadSymbol(this.id + ' does not have market symbol ' + symbol);
1278
- }
1279
1251
  safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
1280
1252
  const isOption = (marketId !== undefined) && ((marketId.indexOf('-C') > -1) || (marketId.indexOf('-P') > -1));
1281
1253
  if (isOption && !(marketId in this.markets_by_id)) {
@@ -315,24 +315,6 @@ class delta extends delta$1 {
315
315
  'info': undefined,
316
316
  };
317
317
  }
318
- market(symbol) {
319
- if (this.markets === undefined) {
320
- throw new errors.ExchangeError(this.id + ' markets not loaded');
321
- }
322
- if (typeof symbol === 'string') {
323
- if (symbol in this.markets) {
324
- return this.markets[symbol];
325
- }
326
- else if (symbol in this.markets_by_id) {
327
- const markets = this.markets_by_id[symbol];
328
- return markets[0];
329
- }
330
- else if ((symbol.endsWith('-C')) || (symbol.endsWith('-P')) || (symbol.startsWith('C-')) || (symbol.startsWith('P-'))) {
331
- return this.createExpiredOptionMarket(symbol);
332
- }
333
- }
334
- throw new errors.BadSymbol(this.id + ' does not have market symbol ' + symbol);
335
- }
336
318
  safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
337
319
  const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')) || (marketId.startsWith('C-')) || (marketId.startsWith('P-')));
338
320
  if (isOption && !(marketId in this.markets_by_id)) {
@@ -529,6 +529,7 @@ class gate extends gate$1 {
529
529
  'multi_collateral/currency_quota': 20 / 15,
530
530
  'multi_collateral/currencies': 20 / 15,
531
531
  'multi_collateral/ltv': 20 / 15,
532
+ 'multi_collateral/fixed_rate': 20 / 15,
532
533
  },
533
534
  'post': {
534
535
  'collateral/orders': 20 / 15,
@@ -933,31 +934,6 @@ class gate extends gate$1 {
933
934
  'info': undefined,
934
935
  };
935
936
  }
936
- market(symbol) {
937
- if (this.markets === undefined) {
938
- throw new errors.ExchangeError(this.id + ' markets not loaded');
939
- }
940
- if (typeof symbol === 'string') {
941
- if (symbol in this.markets) {
942
- return this.markets[symbol];
943
- }
944
- else if (symbol in this.markets_by_id) {
945
- const markets = this.markets_by_id[symbol];
946
- const defaultType = this.safeString2(this.options, 'defaultType', 'defaultSubType', 'spot');
947
- for (let i = 0; i < markets.length; i++) {
948
- const market = markets[i];
949
- if (market[defaultType]) {
950
- return market;
951
- }
952
- }
953
- return markets[0];
954
- }
955
- else if ((symbol.indexOf('-C') > -1) || (symbol.indexOf('-P') > -1)) {
956
- return this.createExpiredOptionMarket(symbol);
957
- }
958
- }
959
- throw new errors.BadSymbol(this.id + ' does not have market symbol ' + symbol);
960
- }
961
937
  safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
962
938
  const isOption = (marketId !== undefined) && ((marketId.indexOf('-C') > -1) || (marketId.indexOf('-P') > -1));
963
939
  if (isOption && !(marketId in this.markets_by_id)) {
@@ -5583,7 +5559,7 @@ class gate extends gate$1 {
5583
5559
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
5584
5560
  * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
5585
5561
  * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts-2
5586
- * @param {string[]|undefined} symbols list of unified market symbols
5562
+ * @param {string[]} [symbols] list of unified market symbols
5587
5563
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5588
5564
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
5589
5565
  */
@@ -5728,6 +5704,33 @@ class gate extends gate$1 {
5728
5704
  //
5729
5705
  return this.parseMarketLeverageTiers(response, market);
5730
5706
  }
5707
+ parseEmulatedLeverageTiers(info, market = undefined) {
5708
+ const maintenanceMarginUnit = this.safeString(info, 'maintenance_rate'); // '0.005',
5709
+ const leverageMax = this.safeString(info, 'leverage_max'); // '100',
5710
+ const riskLimitStep = this.safeString(info, 'risk_limit_step'); // '1000000',
5711
+ const riskLimitMax = this.safeString(info, 'risk_limit_max'); // '16000000',
5712
+ const initialMarginUnit = Precise["default"].stringDiv('1', leverageMax);
5713
+ let maintenanceMarginRate = maintenanceMarginUnit;
5714
+ let initialMarginRatio = initialMarginUnit;
5715
+ let floor = '0';
5716
+ const tiers = [];
5717
+ while (Precise["default"].stringLt(floor, riskLimitMax)) {
5718
+ const cap = Precise["default"].stringAdd(floor, riskLimitStep);
5719
+ tiers.push({
5720
+ 'tier': this.parseNumber(Precise["default"].stringDiv(cap, riskLimitStep)),
5721
+ 'currency': this.safeString(market, 'settle'),
5722
+ 'minNotional': this.parseNumber(floor),
5723
+ 'maxNotional': this.parseNumber(cap),
5724
+ 'maintenanceMarginRate': this.parseNumber(maintenanceMarginRate),
5725
+ 'maxLeverage': this.parseNumber(Precise["default"].stringDiv('1', initialMarginRatio)),
5726
+ 'info': info,
5727
+ });
5728
+ maintenanceMarginRate = Precise["default"].stringAdd(maintenanceMarginRate, maintenanceMarginUnit);
5729
+ initialMarginRatio = Precise["default"].stringAdd(initialMarginRatio, initialMarginUnit);
5730
+ floor = cap;
5731
+ }
5732
+ return tiers;
5733
+ }
5731
5734
  parseMarketLeverageTiers(info, market = undefined) {
5732
5735
  //
5733
5736
  // [
@@ -5740,6 +5743,9 @@ class gate extends gate$1 {
5740
5743
  // }
5741
5744
  // ]
5742
5745
  //
5746
+ if (!Array.isArray(info)) {
5747
+ return this.parseEmulatedLeverageTiers(info, market);
5748
+ }
5743
5749
  let minNotional = 0;
5744
5750
  const tiers = [];
5745
5751
  for (let i = 0; i < info.length; i++) {
@@ -1831,7 +1831,7 @@ class kucoinfutures extends kucoinfutures$1 {
1831
1831
  * @method
1832
1832
  * @name kucoinfutures#fetchFundingRate
1833
1833
  * @description fetch the current funding rate
1834
- * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-funding-rate
1834
+ * @see https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate
1835
1835
  * @param {string} symbol unified market symbol
1836
1836
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1837
1837
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -1855,7 +1855,7 @@ class kucoinfutures extends kucoinfutures$1 {
1855
1855
  // }
1856
1856
  //
1857
1857
  const data = this.safeValue(response, 'data');
1858
- const fundingTimestamp = this.safeNumber(data, 'timePoint');
1858
+ const fundingTimestamp = this.safeInteger(data, 'timePoint');
1859
1859
  // the website displayes the previous funding rate as "funding rate"
1860
1860
  return {
1861
1861
  'info': data,
@@ -1866,15 +1866,15 @@ class kucoinfutures extends kucoinfutures$1 {
1866
1866
  'estimatedSettlePrice': undefined,
1867
1867
  'timestamp': undefined,
1868
1868
  'datetime': undefined,
1869
- 'fundingRate': this.safeNumber(data, 'predictedValue'),
1870
- 'fundingTimestamp': undefined,
1871
- 'fundingDatetime': undefined,
1872
- 'nextFundingRate': undefined,
1869
+ 'fundingRate': this.safeNumber(data, 'value'),
1870
+ 'fundingTimestamp': fundingTimestamp,
1871
+ 'fundingDatetime': this.iso8601(fundingTimestamp),
1872
+ 'nextFundingRate': this.safeNumber(data, 'predictedValue'),
1873
1873
  'nextFundingTimestamp': undefined,
1874
1874
  'nextFundingDatetime': undefined,
1875
- 'previousFundingRate': this.safeNumber(data, 'value'),
1876
- 'previousFundingTimestamp': fundingTimestamp,
1877
- 'previousFundingDatetime': this.iso8601(fundingTimestamp),
1875
+ 'previousFundingRate': undefined,
1876
+ 'previousFundingTimestamp': undefined,
1877
+ 'previousFundingDatetime': undefined,
1878
1878
  };
1879
1879
  }
1880
1880
  parseBalance(response) {
@@ -19,9 +19,9 @@ class novadax extends novadax$1 {
19
19
  'id': 'novadax',
20
20
  'name': 'NovaDAX',
21
21
  'countries': ['BR'],
22
- // 60 requests per second = 1000ms / 60 = 16.6667ms between requests (public endpoints, limited by IP address)
23
- // 20 requests per second => cost = 60 / 20 = 3 (private endpoints, limited by API Key)
24
- 'rateLimit': 16.6667,
22
+ // 6000 weight per min => 100 weight per second => min weight = 1
23
+ // 100 requests per second => ( 1000ms / 100 ) = 10 ms between requests on average
24
+ 'rateLimit': 10,
25
25
  'version': 'v1',
26
26
  // new metainfo interface
27
27
  'has': {
@@ -119,33 +119,37 @@ class novadax extends novadax$1 {
119
119
  'api': {
120
120
  'public': {
121
121
  'get': {
122
- 'common/symbol': 1.2,
123
- 'common/symbols': 1.2,
124
- 'common/timestamp': 1.2,
125
- 'market/tickers': 1.2,
126
- 'market/ticker': 1.2,
127
- 'market/depth': 1.2,
128
- 'market/trades': 1.2,
129
- 'market/kline/history': 1.2,
122
+ 'common/symbol': 1,
123
+ 'common/symbols': 1,
124
+ 'common/timestamp': 1,
125
+ 'market/tickers': 5,
126
+ 'market/ticker': 1,
127
+ 'market/depth': 1,
128
+ 'market/trades': 5,
129
+ 'market/kline/history': 5,
130
130
  },
131
131
  },
132
132
  'private': {
133
133
  'get': {
134
- 'orders/get': 3,
135
- 'orders/list': 3,
134
+ 'orders/get': 1,
135
+ 'orders/list': 10,
136
136
  'orders/fill': 3,
137
- 'orders/fills': 3,
138
- 'account/getBalance': 3,
139
- 'account/subs': 3,
140
- 'account/subs/balance': 3,
141
- 'account/subs/transfer/record': 3,
137
+ 'orders/fills': 10,
138
+ 'account/getBalance': 1,
139
+ 'account/subs': 1,
140
+ 'account/subs/balance': 1,
141
+ 'account/subs/transfer/record': 10,
142
142
  'wallet/query/deposit-withdraw': 3,
143
143
  },
144
144
  'post': {
145
- 'orders/create': 3,
146
- 'orders/cancel': 3,
147
- 'account/withdraw/coin': 3,
148
- 'account/subs/transfer': 3,
145
+ 'orders/create': 5,
146
+ 'orders/batch-create': 50,
147
+ 'orders/cancel': 1,
148
+ 'orders/batch-cancel': 10,
149
+ 'orders/cancel-by-symbol': 10,
150
+ 'account/subs/transfer': 5,
151
+ 'wallet/withdraw/coin': 3,
152
+ 'account/withdraw/coin': 3, // not found in doc
149
153
  },
150
154
  },
151
155
  },
@@ -1152,24 +1152,6 @@ class okx extends okx$1 {
1152
1152
  'info': undefined,
1153
1153
  };
1154
1154
  }
1155
- market(symbol) {
1156
- if (this.markets === undefined) {
1157
- throw new errors.ExchangeError(this.id + ' markets not loaded');
1158
- }
1159
- if (typeof symbol === 'string') {
1160
- if (symbol in this.markets) {
1161
- return this.markets[symbol];
1162
- }
1163
- else if (symbol in this.markets_by_id) {
1164
- const markets = this.markets_by_id[symbol];
1165
- return markets[0];
1166
- }
1167
- else if ((symbol.indexOf('-C') > -1) || (symbol.indexOf('-P') > -1)) {
1168
- return this.createExpiredOptionMarket(symbol);
1169
- }
1170
- }
1171
- throw new errors.BadSymbol(this.id + ' does not have market symbol ' + symbol);
1172
- }
1173
1155
  safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
1174
1156
  const isOption = (marketId !== undefined) && ((marketId.indexOf('-C') > -1) || (marketId.indexOf('-P') > -1));
1175
1157
  if (isOption && !(marketId in this.markets_by_id)) {
@@ -190,6 +190,7 @@ class phemex extends phemex$1 {
190
190
  'api-data/g-futures/trades': 5,
191
191
  'api-data/futures/trading-fees': 5,
192
192
  'api-data/g-futures/trading-fees': 5,
193
+ 'api-data/futures/v2/tradeAccountDetail': 5,
193
194
  'g-orders/activeList': 1,
194
195
  'orders/activeList': 1,
195
196
  'exchange/order/list': 5,
@@ -2767,7 +2768,7 @@ class phemex extends phemex$1 {
2767
2768
  }
2768
2769
  else if (amount !== undefined) {
2769
2770
  if (isUSDTSettled) {
2770
- request['baseQtyEV'] = this.amountToPrecision(market['symbol'], amount);
2771
+ request['orderQtyRq'] = this.amountToPrecision(market['symbol'], amount);
2771
2772
  }
2772
2773
  else {
2773
2774
  request['baseQtyEV'] = this.toEv(amount, market);
@@ -23,8 +23,8 @@ class bitopro extends bitopro$1 {
23
23
  },
24
24
  'urls': {
25
25
  'ws': {
26
- 'public': 'wss://stream.bitopro.com:9443/ws/v1/pub',
27
- 'private': 'wss://stream.bitopro.com:9443/ws/v1/pub/auth',
26
+ 'public': 'wss://stream.bitopro.com:443/ws/v1/pub',
27
+ 'private': 'wss://stream.bitopro.com:443/ws/v1/pub/auth',
28
28
  },
29
29
  },
30
30
  'requiredCredentials': {
@@ -53,6 +53,7 @@ class bitopro extends bitopro$1 {
53
53
  * @method
54
54
  * @name bitopro#watchOrderBook
55
55
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
56
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/public/order_book_stream.md
56
57
  * @param {string} symbol unified symbol of the market to fetch the order book for
57
58
  * @param {int} [limit] the maximum amount of order book entries to return
58
59
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -118,6 +119,7 @@ class bitopro extends bitopro$1 {
118
119
  * @method
119
120
  * @name bitopro#watchTrades
120
121
  * @description get the list of most recent trades for a particular symbol
122
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/public/trade_stream.md
121
123
  * @param {string} symbol unified symbol of the market to fetch trades for
122
124
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
123
125
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -177,6 +179,7 @@ class bitopro extends bitopro$1 {
177
179
  * @method
178
180
  * @name bitopro#watchTicker
179
181
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
182
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/public/ticker_stream.md
180
183
  * @param {string} symbol unified symbol of the market to fetch the ticker for
181
184
  * @param {object} [params] extra parameters specific to the exchange API endpoint
182
185
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -230,7 +233,7 @@ class bitopro extends bitopro$1 {
230
233
  'identity': this.login,
231
234
  });
232
235
  const payload = this.stringToBase64(rawData);
233
- const signature = this.hmac(payload, this.encode(this.secret), sha512.sha384);
236
+ const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha512.sha384);
234
237
  const defaultOptions = {
235
238
  'ws': {
236
239
  'options': {
@@ -256,6 +259,7 @@ class bitopro extends bitopro$1 {
256
259
  * @method
257
260
  * @name bitopro#watchBalance
258
261
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
262
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/private/user_balance_stream.md
259
263
  * @param {object} [params] extra parameters specific to the exchange API endpoint
260
264
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
261
265
  */