ccxt 4.2.76 → 4.2.78

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 (74) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1181 -643
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +502 -443
  7. package/dist/cjs/src/bingx.js +1 -1
  8. package/dist/cjs/src/blofin.js +14 -2
  9. package/dist/cjs/src/bybit.js +106 -60
  10. package/dist/cjs/src/coinbase.js +23 -10
  11. package/dist/cjs/src/delta.js +66 -49
  12. package/dist/cjs/src/gate.js +1 -0
  13. package/dist/cjs/src/htx.js +36 -27
  14. package/dist/cjs/src/hyperliquid.js +7 -5
  15. package/dist/cjs/src/kraken.js +8 -8
  16. package/dist/cjs/src/kucoin.js +204 -5
  17. package/dist/cjs/src/okcoin.js +27 -1
  18. package/dist/cjs/src/okx.js +18 -0
  19. package/dist/cjs/src/pro/ascendex.js +1 -1
  20. package/dist/cjs/src/pro/bitvavo.js +1 -1
  21. package/dist/cjs/src/pro/coinex.js +20 -14
  22. package/dist/cjs/src/pro/deribit.js +1 -1
  23. package/dist/cjs/src/pro/exmo.js +1 -1
  24. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  25. package/dist/cjs/src/pro/phemex.js +1 -1
  26. package/dist/cjs/src/pro/poloniex.js +1 -1
  27. package/dist/cjs/src/pro/probit.js +1 -1
  28. package/dist/cjs/src/pro/woo.js +61 -6
  29. package/dist/cjs/src/woo.js +72 -3
  30. package/js/ccxt.d.ts +1 -1
  31. package/js/ccxt.js +1 -1
  32. package/js/src/abstract/kucoin.d.ts +1 -0
  33. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  34. package/js/src/base/Exchange.d.ts +3 -3
  35. package/js/src/base/Exchange.js +6 -0
  36. package/js/src/base/types.d.ts +3 -3
  37. package/js/src/binance.d.ts +2 -2
  38. package/js/src/binance.js +502 -443
  39. package/js/src/bingx.js +1 -1
  40. package/js/src/bitflyer.d.ts +2 -2
  41. package/js/src/bithumb.d.ts +2 -2
  42. package/js/src/blofin.js +14 -2
  43. package/js/src/bybit.d.ts +1 -1
  44. package/js/src/bybit.js +106 -60
  45. package/js/src/coinbase.d.ts +2 -2
  46. package/js/src/coinbase.js +23 -10
  47. package/js/src/delta.d.ts +2 -1
  48. package/js/src/delta.js +66 -49
  49. package/js/src/deribit.d.ts +1 -1
  50. package/js/src/gate.d.ts +1 -1
  51. package/js/src/gate.js +1 -0
  52. package/js/src/htx.js +36 -27
  53. package/js/src/hyperliquid.js +7 -5
  54. package/js/src/kraken.js +8 -8
  55. package/js/src/kucoin.d.ts +4 -1
  56. package/js/src/kucoin.js +204 -5
  57. package/js/src/okcoin.js +27 -1
  58. package/js/src/okx.d.ts +1 -1
  59. package/js/src/okx.js +18 -0
  60. package/js/src/pro/ascendex.js +1 -1
  61. package/js/src/pro/bitvavo.js +1 -1
  62. package/js/src/pro/coinex.js +20 -14
  63. package/js/src/pro/deribit.js +1 -1
  64. package/js/src/pro/exmo.js +1 -1
  65. package/js/src/pro/krakenfutures.js +1 -1
  66. package/js/src/pro/phemex.js +1 -1
  67. package/js/src/pro/poloniex.js +1 -1
  68. package/js/src/pro/probit.js +1 -1
  69. package/js/src/pro/woo.d.ts +1 -0
  70. package/js/src/pro/woo.js +61 -6
  71. package/js/src/woo.d.ts +2 -0
  72. package/js/src/woo.js +72 -3
  73. package/package.json +1 -1
  74. package/skip-tests.json +6 -3
@@ -55,6 +55,13 @@ class woo extends woo$1 {
55
55
  'ping': this.ping,
56
56
  'keepAlive': 10000,
57
57
  },
58
+ 'exceptions': {
59
+ 'ws': {
60
+ 'exact': {
61
+ 'Auth is needed.': errors.AuthenticationError,
62
+ },
63
+ },
64
+ },
58
65
  });
59
66
  }
60
67
  requestId(url) {
@@ -416,8 +423,9 @@ class woo extends woo$1 {
416
423
  const client = this.client(url);
417
424
  const messageHash = 'authenticated';
418
425
  const event = 'auth';
419
- let future = this.safeValue(client.subscriptions, messageHash);
420
- if (future === undefined) {
426
+ const future = client.future(messageHash);
427
+ const authenticated = this.safeValue(client.subscriptions, messageHash);
428
+ if (authenticated === undefined) {
421
429
  const ts = this.nonce().toString();
422
430
  const auth = '|' + ts;
423
431
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
@@ -430,10 +438,9 @@ class woo extends woo$1 {
430
438
  },
431
439
  };
432
440
  const message = this.extend(request, params);
433
- future = this.watch(url, messageHash, message);
434
- client.subscriptions[messageHash] = future;
441
+ this.watch(url, messageHash, message, messageHash);
435
442
  }
436
- return future;
443
+ return await future;
437
444
  }
438
445
  async watchPrivate(messageHash, message, params = {}) {
439
446
  await this.authenticate(params);
@@ -446,6 +453,16 @@ class woo extends woo$1 {
446
453
  return await this.watch(url, messageHash, request, messageHash, subscribe);
447
454
  }
448
455
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
456
+ /**
457
+ * @method
458
+ * @name woo#watchOrders
459
+ * @description watches information on multiple orders made by the user
460
+ * @param {string} symbol unified market symbol of the market orders were made in
461
+ * @param {int} [since] the earliest time in ms to fetch orders for
462
+ * @param {int} [limit] the maximum number of order structures to retrieve
463
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
464
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
465
+ */
449
466
  await this.loadMarkets();
450
467
  const topic = 'executionreport';
451
468
  let messageHash = topic;
@@ -798,7 +815,43 @@ class woo extends woo$1 {
798
815
  this.balance = this.safeBalance(this.balance);
799
816
  client.resolve(this.balance, 'balance');
800
817
  }
818
+ handleErrorMessage(client, message) {
819
+ //
820
+ // {"id":"1","event":"subscribe","success":false,"ts":1710780997216,"errorMsg":"Auth is needed."}
821
+ //
822
+ if (!('success' in message)) {
823
+ return false;
824
+ }
825
+ const success = this.safeBool(message, 'success');
826
+ if (success) {
827
+ return false;
828
+ }
829
+ const errorMessage = this.safeString(message, 'errorMsg');
830
+ try {
831
+ if (errorMessage !== undefined) {
832
+ const feedback = this.id + ' ' + this.json(message);
833
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorMessage, feedback);
834
+ }
835
+ return false;
836
+ }
837
+ catch (error) {
838
+ if (error instanceof errors.AuthenticationError) {
839
+ const messageHash = 'authenticated';
840
+ client.reject(error, messageHash);
841
+ if (messageHash in client.subscriptions) {
842
+ delete client.subscriptions[messageHash];
843
+ }
844
+ }
845
+ else {
846
+ client.reject(error);
847
+ }
848
+ return true;
849
+ }
850
+ }
801
851
  handleMessage(client, message) {
852
+ if (this.handleErrorMessage(client, message)) {
853
+ return;
854
+ }
802
855
  const methods = {
803
856
  'ping': this.handlePing,
804
857
  'pong': this.handlePong,
@@ -881,7 +934,9 @@ class woo extends woo$1 {
881
934
  const messageHash = 'authenticated';
882
935
  const success = this.safeValue(message, 'success');
883
936
  if (success) {
884
- client.resolve(message, messageHash);
937
+ // client.resolve (message, messageHash);
938
+ const future = this.safeValue(client.futures, 'authenticated');
939
+ future.resolve(true);
885
940
  }
886
941
  else {
887
942
  const error = new errors.AuthenticationError(this.json(message));
@@ -56,7 +56,7 @@ class woo extends woo$1 {
56
56
  'fetchBalance': true,
57
57
  'fetchCanceledOrders': false,
58
58
  'fetchClosedOrder': false,
59
- 'fetchClosedOrders': false,
59
+ 'fetchClosedOrders': true,
60
60
  'fetchCurrencies': true,
61
61
  'fetchDepositAddress': true,
62
62
  'fetchDeposits': true,
@@ -75,7 +75,7 @@ class woo extends woo$1 {
75
75
  'fetchOHLCV': true,
76
76
  'fetchOpenInterestHistory': false,
77
77
  'fetchOpenOrder': false,
78
- 'fetchOpenOrders': false,
78
+ 'fetchOpenOrders': true,
79
79
  'fetchOrder': true,
80
80
  'fetchOrderBook': true,
81
81
  'fetchOrders': true,
@@ -1367,9 +1367,15 @@ class woo extends woo$1 {
1367
1367
  * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1368
1368
  * @param {string} [params.side] 'buy' or 'sell'
1369
1369
  * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1370
+ * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
1370
1371
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1371
1372
  */
1372
1373
  await this.loadMarkets();
1374
+ let paginate = false;
1375
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
1376
+ if (paginate) {
1377
+ return await this.fetchPaginatedCallIncremental('fetchOrders', symbol, since, limit, params, 'page', 500);
1378
+ }
1373
1379
  const request = {};
1374
1380
  let market = undefined;
1375
1381
  const stop = this.safeBool2(params, 'stop', 'trigger');
@@ -1387,6 +1393,12 @@ class woo extends woo$1 {
1387
1393
  request['start_t'] = since;
1388
1394
  }
1389
1395
  }
1396
+ if (limit !== undefined) {
1397
+ request['size'] = limit;
1398
+ }
1399
+ else {
1400
+ request['size'] = 500;
1401
+ }
1390
1402
  if (stop) {
1391
1403
  request['algoType'] = 'stop';
1392
1404
  }
@@ -1433,7 +1445,51 @@ class woo extends woo$1 {
1433
1445
  //
1434
1446
  const data = this.safeValue(response, 'data', response);
1435
1447
  const orders = this.safeList(data, 'rows');
1436
- return this.parseOrders(orders, market, since, limit, params);
1448
+ return this.parseOrders(orders, market, since, limit);
1449
+ }
1450
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1451
+ /**
1452
+ * @method
1453
+ * @name woo#fetchOpenOrders
1454
+ * @description fetches information on multiple orders made by the user
1455
+ * @see https://docs.woo.org/#get-orders
1456
+ * @see https://docs.woo.org/#get-algo-orders
1457
+ * @param {string} symbol unified market symbol of the market orders were made in
1458
+ * @param {int} [since] the earliest time in ms to fetch orders for
1459
+ * @param {int} [limit] the maximum number of order structures to retrieve
1460
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1461
+ * @param {boolean} [params.stop] whether the order is a stop/algo order
1462
+ * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1463
+ * @param {string} [params.side] 'buy' or 'sell'
1464
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1465
+ * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
1466
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1467
+ */
1468
+ await this.loadMarkets();
1469
+ const extendedParams = this.extend(params, { 'status': 'INCOMPLETE' });
1470
+ return await this.fetchOrders(symbol, since, limit, extendedParams);
1471
+ }
1472
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1473
+ /**
1474
+ * @method
1475
+ * @name woo#fetchClosedOrders
1476
+ * @description fetches information on multiple orders made by the user
1477
+ * @see https://docs.woo.org/#get-orders
1478
+ * @see https://docs.woo.org/#get-algo-orders
1479
+ * @param {string} symbol unified market symbol of the market orders were made in
1480
+ * @param {int} [since] the earliest time in ms to fetch orders for
1481
+ * @param {int} [limit] the maximum number of order structures to retrieve
1482
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1483
+ * @param {boolean} [params.stop] whether the order is a stop/algo order
1484
+ * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1485
+ * @param {string} [params.side] 'buy' or 'sell'
1486
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1487
+ * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
1488
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1489
+ */
1490
+ await this.loadMarkets();
1491
+ const extendedParams = this.extend(params, { 'status': 'COMPLETED' });
1492
+ return await this.fetchOrders(symbol, since, limit, extendedParams);
1437
1493
  }
1438
1494
  parseTimeInForce(timeInForce) {
1439
1495
  const timeInForces = {
@@ -1752,14 +1808,21 @@ class woo extends woo$1 {
1752
1808
  /**
1753
1809
  * @method
1754
1810
  * @name woo#fetchMyTrades
1811
+ * @see https://docs.woo.org/#get-trades
1755
1812
  * @description fetch all trades made by the user
1756
1813
  * @param {string} symbol unified market symbol
1757
1814
  * @param {int} [since] the earliest time in ms to fetch trades for
1758
1815
  * @param {int} [limit] the maximum number of trades structures to retrieve
1759
1816
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1817
+ * @param {boolean} [params.paginate] set to true if you want to fetch trades with pagination
1760
1818
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1761
1819
  */
1762
1820
  await this.loadMarkets();
1821
+ let paginate = false;
1822
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1823
+ if (paginate) {
1824
+ return await this.fetchPaginatedCallIncremental('fetchMyTrades', symbol, since, limit, params, 'page', 500);
1825
+ }
1763
1826
  const request = {};
1764
1827
  let market = undefined;
1765
1828
  if (symbol !== undefined) {
@@ -1769,6 +1832,12 @@ class woo extends woo$1 {
1769
1832
  if (since !== undefined) {
1770
1833
  request['start_t'] = since;
1771
1834
  }
1835
+ if (limit !== undefined) {
1836
+ request['size'] = limit;
1837
+ }
1838
+ else {
1839
+ request['size'] = 500;
1840
+ }
1772
1841
  const response = await this.v1PrivateGetClientTrades(this.extend(request, params));
1773
1842
  // {
1774
1843
  // "success": true,
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.75";
7
+ declare const version = "4.2.77";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.76';
41
+ const version = '4.2.78';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -78,6 +78,7 @@ interface Exchange {
78
78
  privateGetIsolatedAccountSymbol(params?: {}): Promise<implicitReturnType>;
79
79
  privateGetMarginBorrow(params?: {}): Promise<implicitReturnType>;
80
80
  privateGetMarginRepay(params?: {}): Promise<implicitReturnType>;
81
+ privateGetMarginInterest(params?: {}): Promise<implicitReturnType>;
81
82
  privateGetProjectList(params?: {}): Promise<implicitReturnType>;
82
83
  privateGetProjectMarketInterestRate(params?: {}): Promise<implicitReturnType>;
83
84
  privateGetRedeemOrders(params?: {}): Promise<implicitReturnType>;
@@ -78,6 +78,7 @@ interface kucoin {
78
78
  privateGetIsolatedAccountSymbol(params?: {}): Promise<implicitReturnType>;
79
79
  privateGetMarginBorrow(params?: {}): Promise<implicitReturnType>;
80
80
  privateGetMarginRepay(params?: {}): Promise<implicitReturnType>;
81
+ privateGetMarginInterest(params?: {}): Promise<implicitReturnType>;
81
82
  privateGetProjectList(params?: {}): Promise<implicitReturnType>;
82
83
  privateGetProjectMarketInterestRate(params?: {}): Promise<implicitReturnType>;
83
84
  privateGetRedeemOrders(params?: {}): Promise<implicitReturnType>;
@@ -704,7 +704,7 @@ export default class Exchange {
704
704
  fetchPaymentMethods(params?: {}): Promise<{}>;
705
705
  parseToInt(number: any): number;
706
706
  parseToNumeric(number: any): number;
707
- isRoundNumber(value: any): boolean;
707
+ isRoundNumber(value: number): boolean;
708
708
  afterConstruct(): void;
709
709
  createNetworksByIdObject(): void;
710
710
  getDefaultOptions(): {
@@ -765,8 +765,8 @@ export default class Exchange {
765
765
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
766
766
  fetchOHLCVWs(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
767
767
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
768
- convertTradingViewToOHLCV(ohlcvs: any, timestamp?: string, open?: string, high?: string, low?: string, close?: string, volume?: string, ms?: boolean): any[];
769
- convertOHLCVToTradingView(ohlcvs: any, timestamp?: string, open?: string, high?: string, low?: string, close?: string, volume?: string, ms?: boolean): {};
768
+ convertTradingViewToOHLCV(ohlcvs: number[][], timestamp?: string, open?: string, high?: string, low?: string, close?: string, volume?: string, ms?: boolean): any[];
769
+ convertOHLCVToTradingView(ohlcvs: number[][], timestamp?: string, open?: string, high?: string, low?: string, close?: string, volume?: string, ms?: boolean): {};
770
770
  fetchWebEndpoint(method: any, endpointMethod: any, returnAsJson: any, startRegex?: any, endRegex?: any): Promise<any>;
771
771
  marketIds(symbols: any): any;
772
772
  marketSymbols(symbols: any, type?: Str, allowEmpty?: boolean, sameTypeOnly?: boolean, sameSubTypeOnly?: boolean): any;
@@ -3824,6 +3824,12 @@ export default class Exchange {
3824
3824
  return result;
3825
3825
  }
3826
3826
  checkRequiredCredentials(error = true) {
3827
+ /**
3828
+ * @ignore
3829
+ * @method
3830
+ * @param {boolean} error throw an error that a credential is required if true
3831
+ * @returns {boolean} true if all required credentials have been set, otherwise false or an error is thrown is param error=true
3832
+ */
3827
3833
  const keys = Object.keys(this.requiredCredentials);
3828
3834
  for (let i = 0; i < keys.length; i++) {
3829
3835
  const key = keys[i];
@@ -6,7 +6,7 @@ export declare type Bool = boolean | undefined;
6
6
  export declare type IndexType = number | string;
7
7
  export declare type OrderSide = 'buy' | 'sell' | string;
8
8
  export declare type OrderType = 'limit' | 'market' | string;
9
- export declare type MarketType = 'spot' | 'margin' | 'swap' | 'future' | 'option';
9
+ export declare type MarketType = 'spot' | 'margin' | 'swap' | 'future' | 'option' | 'delivery' | 'index';
10
10
  export declare type SubType = 'linear' | 'inverse' | undefined;
11
11
  export interface Dictionary<T> {
12
12
  [key: string]: T;
@@ -357,8 +357,8 @@ export interface Liquidation {
357
357
  }
358
358
  export interface OrderRequest {
359
359
  symbol: string;
360
- type: Str;
361
- side: Str;
360
+ type: OrderType;
361
+ side: OrderSide;
362
362
  amount?: number;
363
363
  price?: number | undefined;
364
364
  params?: any;
@@ -11,8 +11,8 @@ export default class binance extends Exchange {
11
11
  setSandboxMode(enable: boolean): void;
12
12
  convertExpireDate(date: any): string;
13
13
  createExpiredOptionMarket(symbol: string): MarketInterface;
14
- market(symbol: any): any;
15
- safeMarket(marketId?: any, market?: any, delimiter?: any, marketType?: any): MarketInterface;
14
+ market(symbol: string): MarketInterface;
15
+ safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
16
16
  costToPrecision(symbol: any, cost: any): any;
17
17
  currencyToPrecision(code: any, fee: any, networkCode?: any): any;
18
18
  nonce(): number;