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
@@ -1,4 +1,5 @@
1
1
  import { CHash } from '../../static_dependencies/noble-hashes/utils.js';
2
+ import { Dictionary } from "../types.js";
2
3
  declare function rsa(request: string, secret: string, hash: CHash): string;
3
- declare function jwt(request: {}, secret: Uint8Array, hash: CHash, isRSA?: boolean, opts?: {}): string;
4
+ declare function jwt(request: Dictionary<any>, secret: Uint8Array, hash: CHash, isRSA?: boolean, opts?: Dictionary<any>): string;
4
5
  export { rsa, jwt };
@@ -1,3 +1,3 @@
1
- declare function totp(secret: any): string;
1
+ declare function totp(secret: string): string;
2
2
  export { totp };
3
3
  export default totp;
@@ -1,9 +1,10 @@
1
1
  import { Future } from './Future.js';
2
+ import { Dictionary, Str } from '../types.js';
2
3
  export default class Client {
3
4
  connected: Promise<any>;
4
5
  disconnected: ReturnType<typeof Future>;
5
- futures: {};
6
- rejections: {};
6
+ futures: Dictionary<any>;
7
+ rejections: Dictionary<any>;
7
8
  keepAlive: number;
8
9
  connection: any;
9
10
  connectionTimeout: any;
@@ -23,12 +24,12 @@ export default class Client {
23
24
  onErrorCallback: any;
24
25
  onCloseCallback: any;
25
26
  ping: any;
26
- subscriptions: {};
27
+ subscriptions: Dictionary<any>;
27
28
  throttle: any;
28
- constructor(url: any, onMessageCallback: any, onErrorCallback: any, onCloseCallback: any, onConnectedCallback: any, config?: {});
29
- future(messageHash: any): any;
30
- resolve(result: any, messageHash: any): any;
31
- reject(result: any, messageHash?: any): any;
29
+ constructor(url: string, onMessageCallback: Function | undefined, onErrorCallback: Function | undefined, onCloseCallback: Function | undefined, onConnectedCallback: Function | undefined, config?: {});
30
+ future(messageHash: string): any;
31
+ resolve(result: any, messageHash: Str): any;
32
+ reject(result: any, messageHash?: Str): any;
32
33
  log(...args: any[]): void;
33
34
  connect(backoffDelay?: number): void;
34
35
  isOpen(): boolean;
@@ -11,6 +11,7 @@ import { isNode, isJsonEncodedObject, deepExtend, milliseconds, } from '../../ba
11
11
  import { utf8 } from '../../static_dependencies/scure-base/index.js';
12
12
  export default class Client {
13
13
  constructor(url, onMessageCallback, onErrorCallback, onCloseCallback, onConnectedCallback, config = {}) {
14
+ this.verbose = false;
14
15
  const defaults = {
15
16
  url,
16
17
  onMessageCallback,
@@ -60,7 +61,7 @@ export default class Client {
60
61
  if (this.verbose && (messageHash === undefined)) {
61
62
  this.log(new Date(), 'resolve received undefined messageHash');
62
63
  }
63
- if (messageHash in this.futures) {
64
+ if ((messageHash !== undefined) && (messageHash in this.futures)) {
64
65
  const promise = this.futures[messageHash];
65
66
  promise.resolve(result);
66
67
  delete this.futures[messageHash];
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/binance.js';
2
- import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRates, IsolatedBorrowRate } from './base/types.js';
3
3
  /**
4
4
  * @class binance
5
5
  * @augments Exchange
@@ -304,6 +304,8 @@ export default class binance extends Exchange {
304
304
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
305
305
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
306
306
  fetchCrossBorrowRate(code: string, params?: {}): Promise<CrossBorrowRate>;
307
+ fetchIsolatedBorrowRate(symbol: string, params?: {}): Promise<IsolatedBorrowRate>;
308
+ fetchIsolatedBorrowRates(params?: {}): Promise<IsolatedBorrowRates>;
307
309
  fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
308
310
  parseBorrowRateHistory(response: any, code: any, since: any, limit: any): any;
309
311
  parseBorrowRate(info: any, currency?: Currency): {
@@ -314,6 +316,17 @@ export default class binance extends Exchange {
314
316
  datetime: string;
315
317
  info: any;
316
318
  };
319
+ parseIsolatedBorrowRate(info: any, market?: Market): {
320
+ info: any;
321
+ symbol: string;
322
+ base: string;
323
+ baseRate: number;
324
+ quote: string;
325
+ quoteRate: number;
326
+ period: number;
327
+ timestamp: any;
328
+ datetime: any;
329
+ };
317
330
  createGiftCode(code: string, amount: any, params?: {}): Promise<{
318
331
  info: any;
319
332
  id: string;
package/js/src/binance.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/binance.js';
9
- import { ExchangeError, ArgumentsRequired, OperationFailed, OperationRejected, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable, OnMaintenance, BadResponse, RequestTimeout, OrderNotFillable, MarginModeAlreadySet } from './base/errors.js';
9
+ import { ExchangeError, ArgumentsRequired, OperationFailed, OperationRejected, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable, OnMaintenance, BadResponse, RequestTimeout, OrderNotFillable, MarginModeAlreadySet, MarketClosed } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { TRUNCATE, DECIMAL_PLACES } from './base/functions/number.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
@@ -96,8 +96,8 @@ export default class binance extends Exchange {
96
96
  'fetchFundingRates': true,
97
97
  'fetchGreeks': true,
98
98
  'fetchIndexOHLCV': true,
99
- 'fetchIsolatedBorrowRate': false,
100
- 'fetchIsolatedBorrowRates': false,
99
+ 'fetchIsolatedBorrowRate': 'emulated',
100
+ 'fetchIsolatedBorrowRates': true,
101
101
  'fetchL3OrderBook': false,
102
102
  'fetchLastPrices': true,
103
103
  'fetchLedger': true,
@@ -2399,7 +2399,7 @@ export default class binance extends Exchange {
2399
2399
  'Rest API trading is not enabled.': PermissionDenied,
2400
2400
  'This account may not place or cancel orders.': PermissionDenied,
2401
2401
  "You don't have permission.": PermissionDenied,
2402
- 'Market is closed.': OperationRejected,
2402
+ 'Market is closed.': MarketClosed,
2403
2403
  'Too many requests. Please try again later.': RateLimitExceeded,
2404
2404
  'This action is disabled on this account.': AccountSuspended,
2405
2405
  'Limit orders require GTC for this phase.': BadRequest,
@@ -4002,8 +4002,8 @@ export default class binance extends Exchange {
4002
4002
  * @name binance#fetchLastPrices
4003
4003
  * @description fetches the last price for multiple markets
4004
4004
  * @see https://binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker // spot
4005
- * @see https://binance-docs.github.io/apidocs/future/en/#symbol-price-ticker // swap
4006
- * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
4005
+ * @see https://binance-docs.github.io/apidocs/futures/en/#symbol-price-ticker // swap
4006
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-tickers // future
4007
4007
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
4008
4008
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4009
4009
  * @param {string} [params.subType] "linear" or "inverse"
@@ -11340,6 +11340,70 @@ export default class binance extends Exchange {
11340
11340
  const rate = this.safeDict(response, 0);
11341
11341
  return this.parseBorrowRate(rate);
11342
11342
  }
11343
+ async fetchIsolatedBorrowRate(symbol, params = {}) {
11344
+ /**
11345
+ * @method
11346
+ * @name binance#fetchIsolatedBorrowRate
11347
+ * @description fetch the rate of interest to borrow a currency for margin trading
11348
+ * @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-fee-data-user_data
11349
+ * @param {string} symbol unified market symbol
11350
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
11351
+ *
11352
+ * EXCHANGE SPECIFIC PARAMETERS
11353
+ * @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
11354
+ * @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure}
11355
+ */
11356
+ const request = {
11357
+ 'symbol': symbol,
11358
+ };
11359
+ const borrowRates = await this.fetchIsolatedBorrowRates(this.extend(request, params));
11360
+ return this.safeDict(borrowRates, symbol);
11361
+ }
11362
+ async fetchIsolatedBorrowRates(params = {}) {
11363
+ /**
11364
+ * @method
11365
+ * @name binance#fetchIsolatedBorrowRates
11366
+ * @description fetch the borrow interest rates of all currencies
11367
+ * @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-fee-data-user_data
11368
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
11369
+ * @param {object} [params.symbol] unified market symbol
11370
+ *
11371
+ * EXCHANGE SPECIFIC PARAMETERS
11372
+ * @param {object} [params.vipLevel] user's current specific margin data will be returned if viplevel is omitted
11373
+ * @returns {object} a [borrow rate structure]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
11374
+ */
11375
+ await this.loadMarkets();
11376
+ const request = {};
11377
+ const symbol = this.safeString(params, 'symbol');
11378
+ params = this.omit(params, 'symbol');
11379
+ if (symbol !== undefined) {
11380
+ const market = this.market(symbol);
11381
+ request['symbol'] = market['id'];
11382
+ }
11383
+ const response = await this.sapiGetMarginIsolatedMarginData(this.extend(request, params));
11384
+ //
11385
+ // [
11386
+ // {
11387
+ // "vipLevel": 0,
11388
+ // "symbol": "BTCUSDT",
11389
+ // "leverage": "10",
11390
+ // "data": [
11391
+ // {
11392
+ // "coin": "BTC",
11393
+ // "dailyInterest": "0.00026125",
11394
+ // "borrowLimit": "270"
11395
+ // },
11396
+ // {
11397
+ // "coin": "USDT",
11398
+ // "dailyInterest": "0.000475",
11399
+ // "borrowLimit": "2100000"
11400
+ // }
11401
+ // ]
11402
+ // }
11403
+ // ]
11404
+ //
11405
+ return this.parseIsolatedBorrowRates(response);
11406
+ }
11343
11407
  async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
11344
11408
  /**
11345
11409
  * @method
@@ -11414,6 +11478,43 @@ export default class binance extends Exchange {
11414
11478
  'info': info,
11415
11479
  };
11416
11480
  }
11481
+ parseIsolatedBorrowRate(info, market = undefined) {
11482
+ //
11483
+ // {
11484
+ // "vipLevel": 0,
11485
+ // "symbol": "BTCUSDT",
11486
+ // "leverage": "10",
11487
+ // "data": [
11488
+ // {
11489
+ // "coin": "BTC",
11490
+ // "dailyInterest": "0.00026125",
11491
+ // "borrowLimit": "270"
11492
+ // },
11493
+ // {
11494
+ // "coin": "USDT",
11495
+ // "dailyInterest": "0.000475",
11496
+ // "borrowLimit": "2100000"
11497
+ // }
11498
+ // ]
11499
+ // }
11500
+ //
11501
+ const marketId = this.safeString(info, 'symbol');
11502
+ market = this.safeMarket(marketId, market, undefined, 'spot');
11503
+ const data = this.safeList(info, 'data');
11504
+ const baseInfo = this.safeDict(data, 0);
11505
+ const quoteInfo = this.safeDict(data, 1);
11506
+ return {
11507
+ 'info': info,
11508
+ 'symbol': this.safeString(market, 'symbol'),
11509
+ 'base': this.safeString(baseInfo, 'coin'),
11510
+ 'baseRate': this.safeNumber(baseInfo, 'dailyInterest'),
11511
+ 'quote': this.safeString(quoteInfo, 'coin'),
11512
+ 'quoteRate': this.safeNumber(quoteInfo, 'dailyInterest'),
11513
+ 'period': 86400000,
11514
+ 'timestamp': undefined,
11515
+ 'datetime': undefined,
11516
+ };
11517
+ }
11417
11518
  async createGiftCode(code, amount, params = {}) {
11418
11519
  /**
11419
11520
  * @method
package/js/src/bingx.d.ts CHANGED
@@ -147,7 +147,7 @@ export default class bingx extends Exchange {
147
147
  fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
148
148
  parseMarginMode(marginMode: any, market?: any): MarginMode;
149
149
  sign(path: any, section?: string, method?: string, params?: {}, headers?: any, body?: any): {
150
- url: any;
150
+ url: string;
151
151
  method: string;
152
152
  body: any;
153
153
  headers: any;
package/js/src/bingx.js CHANGED
@@ -389,6 +389,7 @@ export default class bingx extends Exchange {
389
389
  '100202': InsufficientFunds,
390
390
  '100204': BadRequest,
391
391
  '100400': BadRequest,
392
+ '100410': OperationFailed,
392
393
  '100421': BadSymbol,
393
394
  '100440': ExchangeError,
394
395
  '100500': OperationFailed,