ccxt 4.3.15 → 4.3.17

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 (82) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/alpaca.js +1 -0
  4. package/dist/cjs/src/ascendex.js +1 -0
  5. package/dist/cjs/src/base/Exchange.js +24 -15
  6. package/dist/cjs/src/base/Precise.js +3 -2
  7. package/dist/cjs/src/base/ws/WsClient.js +4 -0
  8. package/dist/cjs/src/binance.js +10 -9
  9. package/dist/cjs/src/bingx.js +1 -0
  10. package/dist/cjs/src/bitmex.js +1 -0
  11. package/dist/cjs/src/bybit.js +11 -7
  12. package/dist/cjs/src/coinbaseinternational.js +1 -0
  13. package/dist/cjs/src/coinmetro.js +1 -0
  14. package/dist/cjs/src/cryptocom.js +1 -0
  15. package/dist/cjs/src/currencycom.js +1 -0
  16. package/dist/cjs/src/deribit.js +1 -0
  17. package/dist/cjs/src/gate.js +1 -0
  18. package/dist/cjs/src/gemini.js +1 -0
  19. package/dist/cjs/src/hitbtc.js +1 -0
  20. package/dist/cjs/src/hollaex.js +1 -0
  21. package/dist/cjs/src/hyperliquid.js +5 -0
  22. package/dist/cjs/src/idex.js +1 -0
  23. package/dist/cjs/src/krakenfutures.js +1 -0
  24. package/dist/cjs/src/ndax.js +1 -0
  25. package/dist/cjs/src/okx.js +18 -0
  26. package/dist/cjs/src/phemex.js +1 -0
  27. package/dist/cjs/src/poloniex.js +1 -0
  28. package/dist/cjs/src/pro/bitfinex2.js +2 -0
  29. package/dist/cjs/src/pro/bitget.js +3 -0
  30. package/dist/cjs/src/pro/bybit.js +3 -3
  31. package/dist/cjs/src/pro/htx.js +2 -0
  32. package/dist/cjs/src/pro/independentreserve.js +2 -0
  33. package/dist/cjs/src/pro/kraken.js +2 -0
  34. package/dist/cjs/src/pro/okx.js +22 -22
  35. package/dist/cjs/src/probit.js +1 -0
  36. package/dist/cjs/src/wavesexchange.js +1 -0
  37. package/dist/cjs/src/woo.js +1 -0
  38. package/dist/cjs/src/zaif.js +1 -1
  39. package/js/ccxt.d.ts +1 -1
  40. package/js/ccxt.js +1 -1
  41. package/js/src/alpaca.js +1 -0
  42. package/js/src/ascendex.js +1 -0
  43. package/js/src/base/Exchange.d.ts +1 -0
  44. package/js/src/base/Exchange.js +24 -15
  45. package/js/src/base/Precise.d.ts +19 -19
  46. package/js/src/base/Precise.js +3 -2
  47. package/js/src/base/errors.d.ts +37 -37
  48. package/js/src/base/ws/WsClient.d.ts +1 -1
  49. package/js/src/base/ws/WsClient.js +4 -0
  50. package/js/src/binance.js +10 -9
  51. package/js/src/bingx.js +1 -0
  52. package/js/src/bitmex.js +1 -0
  53. package/js/src/bybit.js +11 -7
  54. package/js/src/coinbaseinternational.js +1 -0
  55. package/js/src/coinmetro.js +1 -0
  56. package/js/src/cryptocom.js +1 -0
  57. package/js/src/currencycom.js +1 -0
  58. package/js/src/deribit.js +1 -0
  59. package/js/src/gate.js +1 -0
  60. package/js/src/gemini.js +1 -0
  61. package/js/src/hitbtc.js +1 -0
  62. package/js/src/hollaex.js +1 -0
  63. package/js/src/hyperliquid.js +5 -0
  64. package/js/src/idex.js +1 -0
  65. package/js/src/krakenfutures.js +1 -0
  66. package/js/src/kuna.d.ts +1 -1
  67. package/js/src/ndax.js +1 -0
  68. package/js/src/okx.js +19 -1
  69. package/js/src/phemex.js +1 -0
  70. package/js/src/poloniex.js +1 -0
  71. package/js/src/pro/bitfinex2.js +2 -0
  72. package/js/src/pro/bitget.js +3 -0
  73. package/js/src/pro/bybit.js +3 -3
  74. package/js/src/pro/htx.js +2 -0
  75. package/js/src/pro/independentreserve.js +2 -0
  76. package/js/src/pro/kraken.js +2 -0
  77. package/js/src/pro/okx.js +23 -23
  78. package/js/src/probit.js +1 -0
  79. package/js/src/wavesexchange.js +1 -0
  80. package/js/src/woo.js +1 -0
  81. package/js/src/zaif.js +1 -1
  82. package/package.json +1 -1
@@ -450,10 +450,12 @@ class okx extends okx$1 {
450
450
  /**
451
451
  * @method
452
452
  * @name okx#watchOrderBook
453
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel
453
454
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
454
455
  * @param {string} symbol unified symbol of the market to fetch the order book for
455
456
  * @param {int} [limit] the maximum amount of order book entries to return
456
457
  * @param {object} [params] extra parameters specific to the exchange API endpoint
458
+ * @param {string} [params.depth] okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
457
459
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
458
460
  */
459
461
  //
@@ -485,16 +487,18 @@ class okx extends okx$1 {
485
487
  /**
486
488
  * @method
487
489
  * @name okx#watchOrderBookForSymbols
490
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel
488
491
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
489
492
  * @param {string[]} symbols unified array of symbols
490
493
  * @param {int} [limit] 1,5, 400, 50 (l2-tbt, vip4+) or 40000 (vip5+) the maximum amount of order book entries to return
491
494
  * @param {object} [params] extra parameters specific to the exchange API endpoint
495
+ * @param {string} [params.depth] okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
492
496
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
493
497
  */
494
498
  await this.loadMarkets();
495
499
  symbols = this.marketSymbols(symbols);
496
- const options = this.safeValue(this.options, 'watchOrderBook', {});
497
- let depth = this.safeString(options, 'depth', 'books');
500
+ let depth = undefined;
501
+ [depth, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'depth', 'books');
498
502
  if (limit !== undefined) {
499
503
  if (limit === 1) {
500
504
  depth = 'bbo-tbt';
@@ -502,17 +506,17 @@ class okx extends okx$1 {
502
506
  else if (limit > 1 && limit <= 5) {
503
507
  depth = 'books5';
504
508
  }
505
- else if (limit === 400) {
506
- depth = 'books';
507
- }
508
509
  else if (limit === 50) {
509
510
  depth = 'books50-l2-tbt'; // Make sure you have VIP4 and above
510
511
  }
511
- else if (limit === 4000) {
512
- depth = 'books-l2-tbt'; // Make sure you have VIP5 and above
512
+ else if (limit === 400) {
513
+ depth = 'books';
513
514
  }
514
515
  }
515
516
  if ((depth === 'books-l2-tbt') || (depth === 'books50-l2-tbt')) {
517
+ if (!this.checkRequiredCredentials(false)) {
518
+ throw new errors.AuthenticationError(this.id + ' watchOrderBook/watchOrderBookForSymbols requires authentication for this depth. Add credentials or change the depth option to books or books5');
519
+ }
516
520
  await this.authenticate({ 'access': 'public' });
517
521
  }
518
522
  const topics = [];
@@ -576,6 +580,8 @@ class okx extends okx$1 {
576
580
  const storedBids = orderbook['bids'];
577
581
  this.handleDeltas(storedAsks, asks);
578
582
  this.handleDeltas(storedBids, bids);
583
+ const marketId = this.safeString(message, 'instId');
584
+ const symbol = this.safeSymbol(marketId);
579
585
  const checksum = this.safeBool(this.options, 'checksum', true);
580
586
  if (checksum) {
581
587
  const asksLength = storedAsks.length;
@@ -596,6 +602,8 @@ class okx extends okx$1 {
596
602
  const localChecksum = this.crc32(payload, true);
597
603
  if (responseChecksum !== localChecksum) {
598
604
  const error = new errors.InvalidNonce(this.id + ' invalid checksum');
605
+ delete client.subscriptions[messageHash];
606
+ delete this.orderbooks[symbol];
599
607
  client.reject(error, messageHash);
600
608
  }
601
609
  }
@@ -690,10 +698,10 @@ class okx extends okx$1 {
690
698
  // ]
691
699
  // }
692
700
  //
693
- const arg = this.safeValue(message, 'arg', {});
701
+ const arg = this.safeDict(message, 'arg', {});
694
702
  const channel = this.safeString(arg, 'channel');
695
703
  const action = this.safeString(message, 'action');
696
- const data = this.safeValue(message, 'data', []);
704
+ const data = this.safeList(message, 'data', []);
697
705
  const marketId = this.safeString(arg, 'instId');
698
706
  const market = this.safeMarket(marketId);
699
707
  const symbol = market['symbol'];
@@ -1523,29 +1531,21 @@ class okx extends okx$1 {
1523
1531
  // { event: 'error', msg: "Illegal request: {"op":"subscribe","args":["spot/ticker:BTC-USDT"]}", code: "60012" }
1524
1532
  // { event: 'error", msg: "channel:ticker,instId:BTC-USDT doesn"t exist", code: "60018" }
1525
1533
  //
1526
- const errorCode = this.safeInteger(message, 'code');
1534
+ const errorCode = this.safeString(message, 'code');
1527
1535
  try {
1528
- if (errorCode) {
1536
+ if (errorCode && errorCode !== '0') {
1529
1537
  const feedback = this.id + ' ' + this.json(message);
1530
1538
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
1531
1539
  const messageString = this.safeValue(message, 'msg');
1532
1540
  if (messageString !== undefined) {
1533
1541
  this.throwBroadlyMatchedException(this.exceptions['broad'], messageString, feedback);
1534
1542
  }
1543
+ throw new errors.ExchangeError(feedback);
1535
1544
  }
1536
1545
  }
1537
1546
  catch (e) {
1538
- if (e instanceof errors.AuthenticationError) {
1539
- const messageHash = 'authenticated';
1540
- client.reject(e, messageHash);
1541
- if (messageHash in client.subscriptions) {
1542
- delete client.subscriptions[messageHash];
1543
- }
1544
- return false;
1545
- }
1546
- else {
1547
- client.reject(e);
1548
- }
1547
+ client.reject(e);
1548
+ return false;
1549
1549
  }
1550
1550
  return message;
1551
1551
  }
@@ -86,6 +86,7 @@ class probit extends probit$1 {
86
86
  'fetchWithdrawal': false,
87
87
  'fetchWithdrawals': true,
88
88
  'reduceMargin': false,
89
+ 'sandbox': true,
89
90
  'setLeverage': false,
90
91
  'setMarginMode': false,
91
92
  'setPositionMode': false,
@@ -79,6 +79,7 @@ class wavesexchange extends wavesexchange$1 {
79
79
  'fetchTransfer': false,
80
80
  'fetchTransfers': false,
81
81
  'reduceMargin': false,
82
+ 'sandbox': true,
82
83
  'setLeverage': false,
83
84
  'setMarginMode': false,
84
85
  'setPositionMode': false,
@@ -104,6 +104,7 @@ class woo extends woo$1 {
104
104
  'fetchTransfers': true,
105
105
  'fetchWithdrawals': true,
106
106
  'reduceMargin': false,
107
+ 'sandbox': true,
107
108
  'setLeverage': true,
108
109
  'setMargin': false,
109
110
  'setPositionMode': true,
@@ -675,7 +675,7 @@ class zaif extends zaif$1 {
675
675
  };
676
676
  }
677
677
  customNonce() {
678
- const num = (this.milliseconds() / 1000).toString();
678
+ const num = this.numberToString(this.milliseconds() / 1000);
679
679
  const nonce = parseFloat(num);
680
680
  return nonce.toFixed(8);
681
681
  }
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, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { 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 } from './src/base/errors.js';
7
- declare const version = "4.3.14";
7
+ declare const version = "4.3.16";
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, 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 } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.15';
41
+ const version = '4.3.17';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
package/js/src/alpaca.js CHANGED
@@ -92,6 +92,7 @@ export default class alpaca extends Exchange {
92
92
  'fetchTransactions': false,
93
93
  'fetchTransfers': false,
94
94
  'fetchWithdrawals': false,
95
+ 'sandbox': true,
95
96
  'setLeverage': false,
96
97
  'setMarginMode': false,
97
98
  'transfer': false,
@@ -94,6 +94,7 @@ export default class ascendex extends Exchange {
94
94
  'fetchWithdrawal': false,
95
95
  'fetchWithdrawals': true,
96
96
  'reduceMargin': true,
97
+ 'sandbox': true,
97
98
  'setLeverage': true,
98
99
  'setMarginMode': true,
99
100
  'setPositionMode': false,
@@ -289,6 +289,7 @@ export default class Exchange {
289
289
  publicAPI: boolean;
290
290
  privateAPI: boolean;
291
291
  CORS: any;
292
+ sandbox: any;
292
293
  spot: any;
293
294
  margin: any;
294
295
  swap: any;
@@ -351,6 +351,7 @@ export default class Exchange {
351
351
  'publicAPI': true,
352
352
  'privateAPI': true,
353
353
  'CORS': undefined,
354
+ 'sandbox': undefined,
354
355
  'spot': undefined,
355
356
  'margin': undefined,
356
357
  'swap': undefined,
@@ -5835,24 +5836,26 @@ export default class Exchange {
5835
5836
  let maxRetries = undefined;
5836
5837
  [maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
5837
5838
  let errors = 0;
5838
- try {
5839
- if (timeframe && method !== 'fetchFundingRateHistory') {
5840
- return await this[method](symbol, timeframe, since, limit, params);
5841
- }
5842
- else {
5843
- return await this[method](symbol, since, limit, params);
5844
- }
5845
- }
5846
- catch (e) {
5847
- if (e instanceof RateLimitExceeded) {
5848
- throw e; // if we are rate limited, we should not retry and fail fast
5839
+ while (errors <= maxRetries) {
5840
+ try {
5841
+ if (timeframe && method !== 'fetchFundingRateHistory') {
5842
+ return await this[method](symbol, timeframe, since, limit, params);
5843
+ }
5844
+ else {
5845
+ return await this[method](symbol, since, limit, params);
5846
+ }
5849
5847
  }
5850
- errors += 1;
5851
- if (errors > maxRetries) {
5852
- throw e;
5848
+ catch (e) {
5849
+ if (e instanceof RateLimitExceeded) {
5850
+ throw e; // if we are rate limited, we should not retry and fail fast
5851
+ }
5852
+ errors += 1;
5853
+ if (errors > maxRetries) {
5854
+ throw e;
5855
+ }
5853
5856
  }
5854
5857
  }
5855
- return undefined;
5858
+ return [];
5856
5859
  }
5857
5860
  async fetchPaginatedCallDeterministic(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}, maxEntriesPerRequest = undefined) {
5858
5861
  let maxCalls = undefined;
@@ -5866,6 +5869,9 @@ export default class Exchange {
5866
5869
  if (since !== undefined) {
5867
5870
  currentSince = Math.max(currentSince, since);
5868
5871
  }
5872
+ else {
5873
+ currentSince = Math.max(currentSince, 1241440531000); // avoid timestamps older than 2009
5874
+ }
5869
5875
  const until = this.safeInteger2(params, 'until', 'till'); // do not omit it here
5870
5876
  if (until !== undefined) {
5871
5877
  const requiredCalls = Math.ceil((until - since) / step);
@@ -5877,6 +5883,9 @@ export default class Exchange {
5877
5883
  if ((until !== undefined) && (currentSince >= until)) {
5878
5884
  break;
5879
5885
  }
5886
+ if (currentSince >= current) {
5887
+ break;
5888
+ }
5880
5889
  tasks.push(this.safeDeterministicCall(method, symbol, currentSince, maxEntriesPerRequest, timeframe, params));
5881
5890
  currentSince = this.sum(currentSince, step) - 1;
5882
5891
  }
@@ -3,38 +3,38 @@ declare class Precise {
3
3
  decimals: number;
4
4
  integer: bigint;
5
5
  base: any;
6
- constructor(number: any, decimals?: Int);
7
- mul(other: any): Precise;
8
- div(other: any, precision?: number): Precise;
9
- add(other: any): Precise;
10
- mod(other: any): Precise;
11
- sub(other: any): Precise;
6
+ constructor(number: bigint | string, decimals?: Int);
7
+ mul(other: Precise): Precise;
8
+ div(other: Precise, precision?: number): Precise;
9
+ add(other: Precise): Precise;
10
+ mod(other: Precise): Precise;
11
+ sub(other: Precise): Precise;
12
12
  abs(): Precise;
13
13
  neg(): Precise;
14
- min(other: any): any;
15
- max(other: any): any;
16
- gt(other: any): boolean;
17
- ge(other: any): boolean;
18
- lt(other: any): any;
19
- le(other: any): any;
14
+ min(other: Precise): Precise;
15
+ max(other: Precise): Precise;
16
+ gt(other: Precise): boolean;
17
+ ge(other: Precise): boolean;
18
+ lt(other: Precise): boolean;
19
+ le(other: Precise): boolean;
20
20
  reduce(): this;
21
21
  equals(other: any): boolean;
22
22
  toString(): string;
23
23
  static stringMul(string1: Str, string2: Str): string;
24
- static stringDiv(string1: any, string2: any, precision?: number): string;
24
+ static stringDiv(string1: Str, string2: Str, precision?: number): string;
25
25
  static stringAdd(string1: Str, string2: Str): string;
26
26
  static stringSub(string1: Str, string2: Str): string;
27
- static stringAbs(string: any): string;
28
- static stringNeg(string: any): string;
27
+ static stringAbs(string: Str): string;
28
+ static stringNeg(string: Str): string;
29
29
  static stringMod(string1: Str, string2: Str): string;
30
30
  static stringEquals(string1: Str, string2: Str): boolean;
31
31
  static stringEq(string1: Str, string2: Str): boolean;
32
- static stringMin(string1: Str, string2: Str): any;
33
- static stringMax(string1: Str, string2: Str): any;
32
+ static stringMin(string1: Str, string2: Str): string;
33
+ static stringMax(string1: Str, string2: Str): string;
34
34
  static stringGt(string1: Str, string2: Str): boolean;
35
35
  static stringGe(string1: Str, string2: Str): boolean;
36
- static stringLt(string1: Str, string2: Str): any;
37
- static stringLe(string1: Str, string2: Str): any;
36
+ static stringLt(string1: Str, string2: Str): boolean;
37
+ static stringLe(string1: Str, string2: Str): boolean;
38
38
  }
39
39
  export default Precise;
40
40
  export { Precise };
@@ -14,8 +14,9 @@ class Precise {
14
14
  let modifier = 0;
15
15
  number = number.toLowerCase();
16
16
  if (number.indexOf('e') > -1) {
17
- [number, modifier] = number.split('e');
18
- modifier = parseInt(modifier.toString());
17
+ let modifierString = '0';
18
+ [number, modifierString] = number.split('e');
19
+ modifier = parseInt(modifierString);
19
20
  }
20
21
  const decimalIndex = number.indexOf('.');
21
22
  this.decimals = (decimalIndex > -1) ? number.length - decimalIndex - 1 : 0;
@@ -1,113 +1,113 @@
1
1
  declare class BaseError extends Error {
2
- constructor(message: any);
2
+ constructor(message: string);
3
3
  }
4
4
  declare class ExchangeError extends BaseError {
5
- constructor(message: any);
5
+ constructor(message: string);
6
6
  }
7
7
  declare class AuthenticationError extends ExchangeError {
8
- constructor(message: any);
8
+ constructor(message: string);
9
9
  }
10
10
  declare class PermissionDenied extends AuthenticationError {
11
- constructor(message: any);
11
+ constructor(message: string);
12
12
  }
13
13
  declare class AccountNotEnabled extends PermissionDenied {
14
- constructor(message: any);
14
+ constructor(message: string);
15
15
  }
16
16
  declare class AccountSuspended extends AuthenticationError {
17
- constructor(message: any);
17
+ constructor(message: string);
18
18
  }
19
19
  declare class ArgumentsRequired extends ExchangeError {
20
- constructor(message: any);
20
+ constructor(message: string);
21
21
  }
22
22
  declare class BadRequest extends ExchangeError {
23
- constructor(message: any);
23
+ constructor(message: string);
24
24
  }
25
25
  declare class BadSymbol extends BadRequest {
26
- constructor(message: any);
26
+ constructor(message: string);
27
27
  }
28
28
  declare class OperationRejected extends ExchangeError {
29
- constructor(message: any);
29
+ constructor(message: string);
30
30
  }
31
31
  declare class NoChange extends OperationRejected {
32
- constructor(message: any);
32
+ constructor(message: string);
33
33
  }
34
34
  declare class MarginModeAlreadySet extends NoChange {
35
- constructor(message: any);
35
+ constructor(message: string);
36
36
  }
37
37
  declare class MarketClosed extends OperationRejected {
38
- constructor(message: any);
38
+ constructor(message: string);
39
39
  }
40
40
  declare class BadResponse extends ExchangeError {
41
- constructor(message: any);
41
+ constructor(message: string);
42
42
  }
43
43
  declare class NullResponse extends BadResponse {
44
- constructor(message: any);
44
+ constructor(message: string);
45
45
  }
46
46
  declare class InsufficientFunds extends ExchangeError {
47
- constructor(message: any);
47
+ constructor(message: string);
48
48
  }
49
49
  declare class InvalidAddress extends ExchangeError {
50
- constructor(message: any);
50
+ constructor(message: string);
51
51
  }
52
52
  declare class AddressPending extends InvalidAddress {
53
- constructor(message: any);
53
+ constructor(message: string);
54
54
  }
55
55
  declare class InvalidOrder extends ExchangeError {
56
- constructor(message: any);
56
+ constructor(message: string);
57
57
  }
58
58
  declare class OrderNotFound extends InvalidOrder {
59
- constructor(message: any);
59
+ constructor(message: string);
60
60
  }
61
61
  declare class OrderNotCached extends InvalidOrder {
62
- constructor(message: any);
62
+ constructor(message: string);
63
63
  }
64
64
  declare class CancelPending extends InvalidOrder {
65
- constructor(message: any);
65
+ constructor(message: string);
66
66
  }
67
67
  declare class OrderImmediatelyFillable extends InvalidOrder {
68
- constructor(message: any);
68
+ constructor(message: string);
69
69
  }
70
70
  declare class OrderNotFillable extends InvalidOrder {
71
- constructor(message: any);
71
+ constructor(message: string);
72
72
  }
73
73
  declare class DuplicateOrderId extends InvalidOrder {
74
- constructor(message: any);
74
+ constructor(message: string);
75
75
  }
76
76
  declare class ContractUnavailable extends InvalidOrder {
77
- constructor(message: any);
77
+ constructor(message: string);
78
78
  }
79
79
  declare class NotSupported extends ExchangeError {
80
- constructor(message: any);
80
+ constructor(message: string);
81
81
  }
82
82
  declare class ProxyError extends ExchangeError {
83
- constructor(message: any);
83
+ constructor(message: string);
84
84
  }
85
85
  declare class ExchangeClosedByUser extends ExchangeError {
86
- constructor(message: any);
86
+ constructor(message: string);
87
87
  }
88
88
  declare class OperationFailed extends BaseError {
89
- constructor(message: any);
89
+ constructor(message: string);
90
90
  }
91
91
  declare class NetworkError extends OperationFailed {
92
- constructor(message: any);
92
+ constructor(message: string);
93
93
  }
94
94
  declare class DDoSProtection extends NetworkError {
95
- constructor(message: any);
95
+ constructor(message: string);
96
96
  }
97
97
  declare class RateLimitExceeded extends NetworkError {
98
- constructor(message: any);
98
+ constructor(message: string);
99
99
  }
100
100
  declare class ExchangeNotAvailable extends NetworkError {
101
- constructor(message: any);
101
+ constructor(message: string);
102
102
  }
103
103
  declare class OnMaintenance extends ExchangeNotAvailable {
104
- constructor(message: any);
104
+ constructor(message: string);
105
105
  }
106
106
  declare class InvalidNonce extends NetworkError {
107
- constructor(message: any);
107
+ constructor(message: string);
108
108
  }
109
109
  declare class RequestTimeout extends NetworkError {
110
- constructor(message: any);
110
+ constructor(message: string);
111
111
  }
112
112
  export { 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 };
113
113
  declare const _default: {
@@ -1,6 +1,6 @@
1
1
  import Client from './Client.js';
2
2
  export default class WsClient extends Client {
3
- connectionStarted: number;
3
+ connectionStarted: number | undefined;
4
4
  protocols: any;
5
5
  options: any;
6
6
  startedConnecting: boolean;
@@ -12,6 +12,10 @@ import { Future } from './Future.js';
12
12
  // eslint-disable-next-line no-restricted-globals
13
13
  const WebSocketPlatform = isNode ? WebSocket : self.WebSocket;
14
14
  export default class WsClient extends Client {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.startedConnecting = false;
18
+ }
15
19
  createConnection() {
16
20
  if (this.verbose) {
17
21
  this.log(new Date(), 'connecting to', this.url);
package/js/src/binance.js CHANGED
@@ -157,6 +157,7 @@ export default class binance extends Exchange {
157
157
  'reduceMargin': true,
158
158
  'repayCrossMargin': true,
159
159
  'repayIsolatedMargin': true,
160
+ 'sandbox': true,
160
161
  'setLeverage': true,
161
162
  'setMargin': false,
162
163
  'setMarginMode': true,
@@ -2621,7 +2622,7 @@ export default class binance extends Exchange {
2621
2622
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2622
2623
  * @returns {object} an associative dictionary of currencies
2623
2624
  */
2624
- const fetchCurrenciesEnabled = this.safeValue(this.options, 'fetchCurrencies');
2625
+ const fetchCurrenciesEnabled = this.safeBool(this.options, 'fetchCurrencies');
2625
2626
  if (!fetchCurrenciesEnabled) {
2626
2627
  return undefined;
2627
2628
  }
@@ -4545,7 +4546,7 @@ export default class binance extends Exchange {
4545
4546
  market = this.safeMarket(marketId, market, undefined, marketType);
4546
4547
  const symbol = market['symbol'];
4547
4548
  let side = undefined;
4548
- const buyerMaker = this.safeValue2(trade, 'm', 'isBuyerMaker');
4549
+ const buyerMaker = this.safeBool2(trade, 'm', 'isBuyerMaker');
4549
4550
  let takerOrMaker = undefined;
4550
4551
  if (buyerMaker !== undefined) {
4551
4552
  side = buyerMaker ? 'sell' : 'buy'; // this is reversed intentionally
@@ -4853,7 +4854,7 @@ export default class binance extends Exchange {
4853
4854
  uppercaseType = 'STOP_LOSS_LIMIT';
4854
4855
  }
4855
4856
  }
4856
- const validOrderTypes = this.safeValue(market['info'], 'orderTypes');
4857
+ const validOrderTypes = this.safeList(market['info'], 'orderTypes');
4857
4858
  if (!this.inArray(uppercaseType, validOrderTypes)) {
4858
4859
  if (initialUppercaseType !== uppercaseType) {
4859
4860
  throw new InvalidOrder(this.id + ' stopPrice parameter is not allowed for ' + symbol + ' ' + type + ' orders');
@@ -4863,7 +4864,7 @@ export default class binance extends Exchange {
4863
4864
  }
4864
4865
  }
4865
4866
  if (clientOrderId === undefined) {
4866
- const broker = this.safeValue(this.options, 'broker');
4867
+ const broker = this.safeDict(this.options, 'broker');
4867
4868
  if (broker !== undefined) {
4868
4869
  const brokerId = this.safeString(broker, 'spot');
4869
4870
  if (brokerId !== undefined) {
@@ -7662,7 +7663,7 @@ export default class binance extends Exchange {
7662
7663
  request['endTime'] = until;
7663
7664
  }
7664
7665
  const raw = await this.sapiGetFiatOrders(this.extend(request, params));
7665
- response = this.safeValue(raw, 'data');
7666
+ response = this.safeList(raw, 'data', []);
7666
7667
  // {
7667
7668
  // "code": "000000",
7668
7669
  // "message": "success",
@@ -7777,7 +7778,7 @@ export default class binance extends Exchange {
7777
7778
  request['beginTime'] = since;
7778
7779
  }
7779
7780
  const raw = await this.sapiGetFiatOrders(this.extend(request, params));
7780
- response = this.safeValue(raw, 'data');
7781
+ response = this.safeList(raw, 'data', []);
7781
7782
  // {
7782
7783
  // "code": "000000",
7783
7784
  // "message": "success",
@@ -7995,7 +7996,7 @@ export default class binance extends Exchange {
7995
7996
  if (txType !== undefined) {
7996
7997
  type = (txType === '0') ? 'deposit' : 'withdrawal';
7997
7998
  }
7998
- const legalMoneyCurrenciesById = this.safeValue(this.options, 'legalMoneyCurrenciesById');
7999
+ const legalMoneyCurrenciesById = this.safeDict(this.options, 'legalMoneyCurrenciesById');
7999
8000
  code = this.safeString(legalMoneyCurrenciesById, code, code);
8000
8001
  }
8001
8002
  const status = this.parseTransactionStatusByType(this.safeString(transaction, 'status'), type);
@@ -8349,7 +8350,7 @@ export default class binance extends Exchange {
8349
8350
  }
8350
8351
  }
8351
8352
  impliedNetwork = this.safeString(reverseNetworks, topLevel);
8352
- const impliedNetworks = this.safeValue(this.options, 'impliedNetworks', {
8353
+ const impliedNetworks = this.safeDict(this.options, 'impliedNetworks', {
8353
8354
  'ETH': { 'ERC20': 'ETH' },
8354
8355
  'TRX': { 'TRC20': 'TRX' },
8355
8356
  });
@@ -9658,7 +9659,7 @@ export default class binance extends Exchange {
9658
9659
  await this.loadMarkets();
9659
9660
  // by default cache the leverage bracket
9660
9661
  // it contains useful stuff like the maintenance margin and initial margin for positions
9661
- const leverageBrackets = this.safeValue(this.options, 'leverageBrackets');
9662
+ const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
9662
9663
  if ((leverageBrackets === undefined) || (reload)) {
9663
9664
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
9664
9665
  const type = this.safeString(params, 'type', defaultType);
package/js/src/bingx.js CHANGED
@@ -86,6 +86,7 @@ export default class bingx extends Exchange {
86
86
  'fetchTransfers': true,
87
87
  'fetchWithdrawals': true,
88
88
  'reduceMargin': true,
89
+ 'sandbox': true,
89
90
  'setLeverage': true,
90
91
  'setMargin': true,
91
92
  'setMarginMode': true,
package/js/src/bitmex.js CHANGED
@@ -91,6 +91,7 @@ export default class bitmex extends Exchange {
91
91
  'fetchTransfer': false,
92
92
  'fetchTransfers': false,
93
93
  'reduceMargin': undefined,
94
+ 'sandbox': true,
94
95
  'setLeverage': true,
95
96
  'setMargin': undefined,
96
97
  'setMarginMode': true,