ccxt 4.3.13 → 4.3.15

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 (61) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/base/Exchange.js +14 -6
  5. package/dist/cjs/src/base/errors.js +8 -1
  6. package/dist/cjs/src/base/functions/misc.js +2 -2
  7. package/dist/cjs/src/base/ws/Client.js +2 -1
  8. package/dist/cjs/src/binance.js +106 -5
  9. package/dist/cjs/src/bingx.js +1 -0
  10. package/dist/cjs/src/bybit.js +105 -105
  11. package/dist/cjs/src/coinbase.js +103 -0
  12. package/dist/cjs/src/coinex.js +435 -423
  13. package/dist/cjs/src/cryptocom.js +2 -1
  14. package/dist/cjs/src/hitbtc.js +1 -0
  15. package/dist/cjs/src/luno.js +2 -0
  16. package/dist/cjs/src/okx.js +1 -1
  17. package/dist/cjs/src/phemex.js +1 -1
  18. package/dist/cjs/src/pro/hitbtc.js +1 -1
  19. package/dist/cjs/src/pro/independentreserve.js +3 -3
  20. package/dist/cjs/src/pro/poloniex.js +3 -3
  21. package/dist/cjs/src/pro/woo.js +147 -9
  22. package/js/ccxt.d.ts +3 -3
  23. package/js/ccxt.js +3 -3
  24. package/js/src/abstract/luno.d.ts +2 -0
  25. package/js/src/alpaca.d.ts +1 -1
  26. package/js/src/base/Exchange.d.ts +5 -5
  27. package/js/src/base/Exchange.js +14 -6
  28. package/js/src/base/errorHierarchy.d.ts +1 -0
  29. package/js/src/base/errorHierarchy.js +1 -0
  30. package/js/src/base/errors.d.ts +5 -1
  31. package/js/src/base/errors.js +8 -2
  32. package/js/src/base/functions/generic.d.ts +1 -1
  33. package/js/src/base/functions/misc.d.ts +5 -4
  34. package/js/src/base/functions/misc.js +2 -2
  35. package/js/src/base/functions/number.d.ts +5 -5
  36. package/js/src/base/functions/rsa.d.ts +2 -1
  37. package/js/src/base/functions/totp.d.ts +1 -1
  38. package/js/src/base/ws/Client.d.ts +8 -7
  39. package/js/src/base/ws/Client.js +2 -1
  40. package/js/src/binance.d.ts +14 -1
  41. package/js/src/binance.js +107 -6
  42. package/js/src/bingx.d.ts +1 -1
  43. package/js/src/bingx.js +1 -0
  44. package/js/src/bybit.js +105 -105
  45. package/js/src/coinbase.d.ts +5 -1
  46. package/js/src/coinbase.js +103 -0
  47. package/js/src/coinex.js +435 -423
  48. package/js/src/cryptocom.js +2 -1
  49. package/js/src/hitbtc.js +1 -0
  50. package/js/src/luno.js +2 -0
  51. package/js/src/okx.js +1 -1
  52. package/js/src/phemex.js +1 -1
  53. package/js/src/pro/hitbtc.js +1 -1
  54. package/js/src/pro/independentreserve.js +3 -3
  55. package/js/src/pro/poloniex.js +3 -3
  56. package/js/src/pro/woo.d.ts +2 -0
  57. package/js/src/pro/woo.js +147 -9
  58. package/js/src/upbit.d.ts +1 -1
  59. package/js/src/woo.d.ts +1 -1
  60. package/js/src/zonda.d.ts +1 -1
  61. package/package.json +1 -1
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2022 Igor Kroitor
3
+ Copyright © 2024 Igor Kroitor
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -213,13 +213,13 @@ console.log(version, Object.keys(exchanges));
213
213
 
214
214
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
215
215
 
216
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.13/dist/ccxt.browser.js
217
- * unpkg: https://unpkg.com/ccxt@4.3.13/dist/ccxt.browser.js
216
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.15/dist/ccxt.browser.js
217
+ * unpkg: https://unpkg.com/ccxt@4.3.15/dist/ccxt.browser.js
218
218
 
219
219
  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.
220
220
 
221
221
  ```HTML
222
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.13/dist/ccxt.browser.js"></script>
222
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.15/dist/ccxt.browser.js"></script>
223
223
  ```
224
224
 
225
225
  Creates a global `ccxt` object:
package/dist/cjs/ccxt.js CHANGED
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.3.13';
185
+ const version = '4.3.15';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -385,6 +385,7 @@ exports.InvalidAddress = errors.InvalidAddress;
385
385
  exports.InvalidNonce = errors.InvalidNonce;
386
386
  exports.InvalidOrder = errors.InvalidOrder;
387
387
  exports.MarginModeAlreadySet = errors.MarginModeAlreadySet;
388
+ exports.MarketClosed = errors.MarketClosed;
388
389
  exports.NetworkError = errors.NetworkError;
389
390
  exports.NoChange = errors.NoChange;
390
391
  exports.NotSupported = errors.NotSupported;
@@ -347,6 +347,10 @@ class Exchange {
347
347
  }
348
348
  this.newUpdates = (this.options.newUpdates !== undefined) ? this.options.newUpdates : true;
349
349
  this.afterConstruct();
350
+ const isSandbox = this.safeBool2(this.options, 'sandbox', 'testnet', false);
351
+ if (isSandbox) {
352
+ this.setSandboxMode(isSandbox);
353
+ }
350
354
  }
351
355
  describe() {
352
356
  return {
@@ -800,6 +804,10 @@ class Exchange {
800
804
  }
801
805
  setProxyAgents(httpProxy, httpsProxy, socksProxy) {
802
806
  let chosenAgent = undefined;
807
+ // in browser-side, proxy modules are not supported in 'fetch/ws' methods
808
+ if (!isNode && (httpProxy || httpsProxy || socksProxy)) {
809
+ throw new errors.NotSupported(this.id + ' - proxies in browser-side projects are not supported. You have several choices: [A] Use `exchange.proxyUrl` property to redirect requests through local/remote cors-proxy server (find sample file named "sample-local-proxy-server-with-cors" in https://github.com/ccxt/ccxt/tree/master/examples/ folder, which can be used for REST requests only) [B] override `exchange.fetch` && `exchange.watch` methods to send requests through your custom proxy');
810
+ }
803
811
  if (httpProxy) {
804
812
  if (this.httpProxyAgentModule === undefined) {
805
813
  throw new errors.NotSupported(this.id + ' you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies');
@@ -3050,15 +3058,15 @@ class Exchange {
3050
3058
  // timestamp and symbol operations don't belong in safeTicker
3051
3059
  // they should be done in the derived classes
3052
3060
  return this.extend(ticker, {
3053
- 'bid': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'bid'))),
3061
+ 'bid': this.parseNumber(this.omitZero(this.safeString(ticker, 'bid'))),
3054
3062
  'bidVolume': this.safeNumber(ticker, 'bidVolume'),
3055
- 'ask': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'ask'))),
3063
+ 'ask': this.parseNumber(this.omitZero(this.safeString(ticker, 'ask'))),
3056
3064
  'askVolume': this.safeNumber(ticker, 'askVolume'),
3057
3065
  'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high'))),
3058
- 'low': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'low'))),
3059
- 'open': this.parseNumber(this.omitZero(this.parseNumber(open))),
3060
- 'close': this.parseNumber(this.omitZero(this.parseNumber(close))),
3061
- 'last': this.parseNumber(this.omitZero(this.parseNumber(last))),
3066
+ 'low': this.parseNumber(this.omitZero(this.safeString(ticker, 'low'))),
3067
+ 'open': this.parseNumber(this.omitZero(open)),
3068
+ 'close': this.parseNumber(this.omitZero(close)),
3069
+ 'last': this.parseNumber(this.omitZero(last)),
3062
3070
  'change': this.parseNumber(change),
3063
3071
  'percentage': this.parseNumber(percentage),
3064
3072
  'average': this.parseNumber(average),
@@ -75,6 +75,12 @@ class MarginModeAlreadySet extends NoChange {
75
75
  this.name = 'MarginModeAlreadySet';
76
76
  }
77
77
  }
78
+ class MarketClosed extends OperationRejected {
79
+ constructor(message) {
80
+ super(message);
81
+ this.name = 'MarketClosed';
82
+ }
83
+ }
78
84
  class BadResponse extends ExchangeError {
79
85
  constructor(message) {
80
86
  super(message);
@@ -219,7 +225,7 @@ class RequestTimeout extends NetworkError {
219
225
  this.name = 'RequestTimeout';
220
226
  }
221
227
  }
222
- var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
228
+ var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
223
229
 
224
230
  exports.AccountNotEnabled = AccountNotEnabled;
225
231
  exports.AccountSuspended = AccountSuspended;
@@ -242,6 +248,7 @@ exports.InvalidAddress = InvalidAddress;
242
248
  exports.InvalidNonce = InvalidNonce;
243
249
  exports.InvalidOrder = InvalidOrder;
244
250
  exports.MarginModeAlreadySet = MarginModeAlreadySet;
251
+ exports.MarketClosed = MarketClosed;
245
252
  exports.NetworkError = NetworkError;
246
253
  exports.NoChange = NoChange;
247
254
  exports.NotSupported = NotSupported;
@@ -81,10 +81,10 @@ function aggregate(bidasks) {
81
81
  for (let i = 0; i < bidasks.length; i++) {
82
82
  const [price, volume] = bidasks[i];
83
83
  if (volume > 0) {
84
- result[price] = (result[price] || 0) + volume;
84
+ result[price] = (result[price] || 0) + volume; // TODO: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.ts(7053)
85
85
  }
86
86
  }
87
- return Object.keys(result).map((price) => [parseFloat(price), parseFloat(result[price])]);
87
+ return Object.keys(result).map((price) => [parseFloat(price), parseFloat(result[price])]); // TODO: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}', No index signature with a parameter of type 'string' was found on type '{}'.ts(7053)
88
88
  }
89
89
  /* ------------------------------------------------------------------------ */
90
90
 
@@ -12,6 +12,7 @@ var index = require('../../static_dependencies/scure-base/index.js');
12
12
 
13
13
  class Client {
14
14
  constructor(url, onMessageCallback, onErrorCallback, onCloseCallback, onConnectedCallback, config = {}) {
15
+ this.verbose = false;
15
16
  const defaults = {
16
17
  url,
17
18
  onMessageCallback,
@@ -61,7 +62,7 @@ class Client {
61
62
  if (this.verbose && (messageHash === undefined)) {
62
63
  this.log(new Date(), 'resolve received undefined messageHash');
63
64
  }
64
- if (messageHash in this.futures) {
65
+ if ((messageHash !== undefined) && (messageHash in this.futures)) {
65
66
  const promise = this.futures[messageHash];
66
67
  promise.resolve(result);
67
68
  delete this.futures[messageHash];
@@ -93,8 +93,8 @@ class binance extends binance$1 {
93
93
  'fetchFundingRates': true,
94
94
  'fetchGreeks': true,
95
95
  'fetchIndexOHLCV': true,
96
- 'fetchIsolatedBorrowRate': false,
97
- 'fetchIsolatedBorrowRates': false,
96
+ 'fetchIsolatedBorrowRate': 'emulated',
97
+ 'fetchIsolatedBorrowRates': true,
98
98
  'fetchL3OrderBook': false,
99
99
  'fetchLastPrices': true,
100
100
  'fetchLedger': true,
@@ -2396,7 +2396,7 @@ class binance extends binance$1 {
2396
2396
  'Rest API trading is not enabled.': errors.PermissionDenied,
2397
2397
  'This account may not place or cancel orders.': errors.PermissionDenied,
2398
2398
  "You don't have permission.": errors.PermissionDenied,
2399
- 'Market is closed.': errors.OperationRejected,
2399
+ 'Market is closed.': errors.MarketClosed,
2400
2400
  'Too many requests. Please try again later.': errors.RateLimitExceeded,
2401
2401
  'This action is disabled on this account.': errors.AccountSuspended,
2402
2402
  'Limit orders require GTC for this phase.': errors.BadRequest,
@@ -3999,8 +3999,8 @@ class binance extends binance$1 {
3999
3999
  * @name binance#fetchLastPrices
4000
4000
  * @description fetches the last price for multiple markets
4001
4001
  * @see https://binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker // spot
4002
- * @see https://binance-docs.github.io/apidocs/future/en/#symbol-price-ticker // swap
4003
- * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
4002
+ * @see https://binance-docs.github.io/apidocs/futures/en/#symbol-price-ticker // swap
4003
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-tickers // future
4004
4004
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
4005
4005
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4006
4006
  * @param {string} [params.subType] "linear" or "inverse"
@@ -11337,6 +11337,70 @@ class binance extends binance$1 {
11337
11337
  const rate = this.safeDict(response, 0);
11338
11338
  return this.parseBorrowRate(rate);
11339
11339
  }
11340
+ async fetchIsolatedBorrowRate(symbol, params = {}) {
11341
+ /**
11342
+ * @method
11343
+ * @name binance#fetchIsolatedBorrowRate
11344
+ * @description fetch the rate of interest to borrow a currency for margin trading
11345
+ * @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-fee-data-user_data
11346
+ * @param {string} symbol unified market symbol
11347
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
11348
+ *
11349
+ * EXCHANGE SPECIFIC PARAMETERS
11350
+ * @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
11351
+ * @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure}
11352
+ */
11353
+ const request = {
11354
+ 'symbol': symbol,
11355
+ };
11356
+ const borrowRates = await this.fetchIsolatedBorrowRates(this.extend(request, params));
11357
+ return this.safeDict(borrowRates, symbol);
11358
+ }
11359
+ async fetchIsolatedBorrowRates(params = {}) {
11360
+ /**
11361
+ * @method
11362
+ * @name binance#fetchIsolatedBorrowRates
11363
+ * @description fetch the borrow interest rates of all currencies
11364
+ * @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-fee-data-user_data
11365
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
11366
+ * @param {object} [params.symbol] unified market symbol
11367
+ *
11368
+ * EXCHANGE SPECIFIC PARAMETERS
11369
+ * @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
11370
+ * @returns {object} a [borrow rate structure]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
11371
+ */
11372
+ await this.loadMarkets();
11373
+ const request = {};
11374
+ const symbol = this.safeString(params, 'symbol');
11375
+ params = this.omit(params, 'symbol');
11376
+ if (symbol !== undefined) {
11377
+ const market = this.market(symbol);
11378
+ request['symbol'] = market['id'];
11379
+ }
11380
+ const response = await this.sapiGetMarginIsolatedMarginData(this.extend(request, params));
11381
+ //
11382
+ // [
11383
+ // {
11384
+ // "vipLevel": 0,
11385
+ // "symbol": "BTCUSDT",
11386
+ // "leverage": "10",
11387
+ // "data": [
11388
+ // {
11389
+ // "coin": "BTC",
11390
+ // "dailyInterest": "0.00026125",
11391
+ // "borrowLimit": "270"
11392
+ // },
11393
+ // {
11394
+ // "coin": "USDT",
11395
+ // "dailyInterest": "0.000475",
11396
+ // "borrowLimit": "2100000"
11397
+ // }
11398
+ // ]
11399
+ // }
11400
+ // ]
11401
+ //
11402
+ return this.parseIsolatedBorrowRates(response);
11403
+ }
11340
11404
  async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
11341
11405
  /**
11342
11406
  * @method
@@ -11411,6 +11475,43 @@ class binance extends binance$1 {
11411
11475
  'info': info,
11412
11476
  };
11413
11477
  }
11478
+ parseIsolatedBorrowRate(info, market = undefined) {
11479
+ //
11480
+ // {
11481
+ // "vipLevel": 0,
11482
+ // "symbol": "BTCUSDT",
11483
+ // "leverage": "10",
11484
+ // "data": [
11485
+ // {
11486
+ // "coin": "BTC",
11487
+ // "dailyInterest": "0.00026125",
11488
+ // "borrowLimit": "270"
11489
+ // },
11490
+ // {
11491
+ // "coin": "USDT",
11492
+ // "dailyInterest": "0.000475",
11493
+ // "borrowLimit": "2100000"
11494
+ // }
11495
+ // ]
11496
+ // }
11497
+ //
11498
+ const marketId = this.safeString(info, 'symbol');
11499
+ market = this.safeMarket(marketId, market, undefined, 'spot');
11500
+ const data = this.safeList(info, 'data');
11501
+ const baseInfo = this.safeDict(data, 0);
11502
+ const quoteInfo = this.safeDict(data, 1);
11503
+ return {
11504
+ 'info': info,
11505
+ 'symbol': this.safeString(market, 'symbol'),
11506
+ 'base': this.safeString(baseInfo, 'coin'),
11507
+ 'baseRate': this.safeNumber(baseInfo, 'dailyInterest'),
11508
+ 'quote': this.safeString(quoteInfo, 'coin'),
11509
+ 'quoteRate': this.safeNumber(quoteInfo, 'dailyInterest'),
11510
+ 'period': 86400000,
11511
+ 'timestamp': undefined,
11512
+ 'datetime': undefined,
11513
+ };
11514
+ }
11414
11515
  async createGiftCode(code, amount, params = {}) {
11415
11516
  /**
11416
11517
  * @method
@@ -386,6 +386,7 @@ class bingx extends bingx$1 {
386
386
  '100202': errors.InsufficientFunds,
387
387
  '100204': errors.BadRequest,
388
388
  '100400': errors.BadRequest,
389
+ '100410': errors.OperationFailed,
389
390
  '100421': errors.BadSymbol,
390
391
  '100440': errors.ExchangeError,
391
392
  '100500': errors.OperationFailed,