ccxt 4.4.3 → 4.4.5

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 (134) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +2 -2
  5. package/dist/cjs/src/base/functions/misc.js +11 -0
  6. package/dist/cjs/src/base/functions.js +1 -0
  7. package/dist/cjs/src/base/ws/WsClient.js +2 -1
  8. package/dist/cjs/src/binance.js +42 -15
  9. package/dist/cjs/src/binanceus.js +1 -0
  10. package/dist/cjs/src/bingx.js +1 -0
  11. package/dist/cjs/src/bitfinex2.js +7 -6
  12. package/dist/cjs/src/bitget.js +57 -100
  13. package/dist/cjs/src/bitmex.js +11 -10
  14. package/dist/cjs/src/bitso.js +5 -4
  15. package/dist/cjs/src/bitstamp.js +9 -9
  16. package/dist/cjs/src/blofin.js +21 -23
  17. package/dist/cjs/src/bybit.js +100 -26
  18. package/dist/cjs/src/coinbase.js +28 -7
  19. package/dist/cjs/src/coinbaseexchange.js +11 -11
  20. package/dist/cjs/src/coinlist.js +6 -5
  21. package/dist/cjs/src/coinmetro.js +3 -3
  22. package/dist/cjs/src/cryptocom.js +7 -5
  23. package/dist/cjs/src/currencycom.js +6 -6
  24. package/dist/cjs/src/delta.js +5 -5
  25. package/dist/cjs/src/digifinex.js +8 -6
  26. package/dist/cjs/src/gate.js +6 -5
  27. package/dist/cjs/src/hashkey.js +9 -7
  28. package/dist/cjs/src/htx.js +13 -16
  29. package/dist/cjs/src/hyperliquid.js +67 -114
  30. package/dist/cjs/src/kraken.js +8 -6
  31. package/dist/cjs/src/kucoin.js +9 -8
  32. package/dist/cjs/src/luno.js +10 -9
  33. package/dist/cjs/src/lykke.js +2 -2
  34. package/dist/cjs/src/mexc.js +42 -3
  35. package/dist/cjs/src/ndax.js +6 -5
  36. package/dist/cjs/src/okcoin.js +18 -27
  37. package/dist/cjs/src/okx.js +18 -26
  38. package/dist/cjs/src/p2b.js +2 -2
  39. package/dist/cjs/src/paradex.js +1 -1
  40. package/dist/cjs/src/pro/binance.js +6 -2
  41. package/dist/cjs/src/pro/binanceus.js +2 -1
  42. package/dist/cjs/src/pro/bybit.js +56 -0
  43. package/dist/cjs/src/pro/hyperliquid.js +16 -1
  44. package/dist/cjs/src/pro/mexc.js +83 -0
  45. package/dist/cjs/src/pro/paradex.js +1 -0
  46. package/dist/cjs/src/woo.js +7 -6
  47. package/dist/cjs/src/woofipro.js +8 -6
  48. package/dist/cjs/src/xt.js +4 -3
  49. package/dist/cjs/src/zonda.js +6 -5
  50. package/js/ccxt.d.ts +1 -1
  51. package/js/ccxt.js +1 -1
  52. package/js/src/base/Exchange.d.ts +2 -2
  53. package/js/src/base/Exchange.js +2 -2
  54. package/js/src/base/functions/misc.d.ts +2 -1
  55. package/js/src/base/functions/misc.js +11 -1
  56. package/js/src/base/types.d.ts +1 -1
  57. package/js/src/base/ws/WsClient.js +2 -2
  58. package/js/src/binance.d.ts +4 -20
  59. package/js/src/binance.js +42 -15
  60. package/js/src/binanceus.js +1 -0
  61. package/js/src/bingx.js +1 -0
  62. package/js/src/bitfinex2.d.ts +3 -19
  63. package/js/src/bitfinex2.js +7 -6
  64. package/js/src/bitget.d.ts +3 -20
  65. package/js/src/bitget.js +57 -100
  66. package/js/src/bitmex.d.ts +3 -22
  67. package/js/src/bitmex.js +11 -10
  68. package/js/src/bitso.d.ts +3 -19
  69. package/js/src/bitso.js +5 -4
  70. package/js/src/bitstamp.d.ts +3 -35
  71. package/js/src/bitstamp.js +9 -9
  72. package/js/src/blofin.d.ts +3 -15
  73. package/js/src/blofin.js +21 -23
  74. package/js/src/bybit.d.ts +3 -19
  75. package/js/src/bybit.js +100 -26
  76. package/js/src/coinbase.d.ts +3 -19
  77. package/js/src/coinbase.js +28 -7
  78. package/js/src/coinbaseexchange.d.ts +3 -19
  79. package/js/src/coinbaseexchange.js +11 -11
  80. package/js/src/coinlist.d.ts +3 -19
  81. package/js/src/coinlist.js +6 -5
  82. package/js/src/coinmetro.d.ts +3 -19
  83. package/js/src/coinmetro.js +3 -3
  84. package/js/src/cryptocom.d.ts +3 -22
  85. package/js/src/cryptocom.js +7 -5
  86. package/js/src/currencycom.d.ts +3 -3
  87. package/js/src/currencycom.js +6 -6
  88. package/js/src/delta.d.ts +3 -19
  89. package/js/src/delta.js +5 -5
  90. package/js/src/digifinex.d.ts +3 -19
  91. package/js/src/digifinex.js +8 -6
  92. package/js/src/gate.d.ts +3 -19
  93. package/js/src/gate.js +6 -5
  94. package/js/src/hashkey.d.ts +3 -20
  95. package/js/src/hashkey.js +9 -7
  96. package/js/src/htx.d.ts +3 -19
  97. package/js/src/htx.js +13 -16
  98. package/js/src/hyperliquid.d.ts +3 -19
  99. package/js/src/hyperliquid.js +68 -115
  100. package/js/src/kraken.d.ts +5 -24
  101. package/js/src/kraken.js +8 -6
  102. package/js/src/kucoin.d.ts +3 -19
  103. package/js/src/kucoin.js +9 -8
  104. package/js/src/luno.d.ts +4 -20
  105. package/js/src/luno.js +10 -9
  106. package/js/src/lykke.js +2 -2
  107. package/js/src/mexc.js +42 -3
  108. package/js/src/ndax.d.ts +3 -19
  109. package/js/src/ndax.js +6 -5
  110. package/js/src/okcoin.d.ts +3 -19
  111. package/js/src/okcoin.js +18 -27
  112. package/js/src/okx.d.ts +3 -19
  113. package/js/src/okx.js +18 -26
  114. package/js/src/p2b.js +2 -2
  115. package/js/src/paradex.js +1 -1
  116. package/js/src/pro/binance.d.ts +140 -0
  117. package/js/src/pro/binance.js +6 -2
  118. package/js/src/pro/binanceus.js +2 -1
  119. package/js/src/pro/bybit.d.ts +2 -0
  120. package/js/src/pro/bybit.js +56 -0
  121. package/js/src/pro/hyperliquid.d.ts +1 -0
  122. package/js/src/pro/hyperliquid.js +16 -1
  123. package/js/src/pro/mexc.d.ts +4 -1
  124. package/js/src/pro/mexc.js +84 -1
  125. package/js/src/pro/paradex.js +1 -0
  126. package/js/src/woo.d.ts +3 -19
  127. package/js/src/woo.js +7 -6
  128. package/js/src/woofipro.d.ts +3 -19
  129. package/js/src/woofipro.js +8 -6
  130. package/js/src/xt.d.ts +3 -22
  131. package/js/src/xt.js +4 -3
  132. package/js/src/zonda.d.ts +3 -19
  133. package/js/src/zonda.js +6 -5
  134. package/package.json +1 -1
@@ -3,6 +3,146 @@ import type { Int, OrderSide, OrderType, Str, Strings, Trade, OrderBook, Order,
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class binance extends binanceRest {
5
5
  describe(): any;
6
+ describeData(): {
7
+ has: {
8
+ ws: boolean;
9
+ watchBalance: boolean;
10
+ watchLiquidations: boolean;
11
+ watchLiquidationsForSymbols: boolean;
12
+ watchMyLiquidations: boolean;
13
+ watchMyLiquidationsForSymbols: boolean;
14
+ watchBidsAsks: boolean;
15
+ watchMyTrades: boolean;
16
+ watchOHLCV: boolean;
17
+ watchOHLCVForSymbols: boolean;
18
+ watchOrderBook: boolean;
19
+ watchOrderBookForSymbols: boolean;
20
+ watchOrders: boolean;
21
+ watchOrdersForSymbols: boolean;
22
+ watchPositions: boolean;
23
+ watchTicker: boolean;
24
+ watchTickers: boolean;
25
+ watchTrades: boolean;
26
+ watchTradesForSymbols: boolean;
27
+ createOrderWs: boolean;
28
+ editOrderWs: boolean;
29
+ cancelOrderWs: boolean;
30
+ cancelOrdersWs: boolean;
31
+ cancelAllOrdersWs: boolean;
32
+ fetchBalanceWs: boolean;
33
+ fetchDepositsWs: boolean;
34
+ fetchMarketsWs: boolean;
35
+ fetchMyTradesWs: boolean;
36
+ fetchOHLCVWs: boolean;
37
+ fetchOrderBookWs: boolean;
38
+ fetchOpenOrdersWs: boolean;
39
+ fetchOrderWs: boolean;
40
+ fetchOrdersWs: boolean;
41
+ fetchPositionWs: boolean;
42
+ fetchPositionForSymbolWs: boolean;
43
+ fetchPositionsWs: boolean;
44
+ fetchTickerWs: boolean;
45
+ fetchTradesWs: boolean;
46
+ fetchTradingFeesWs: boolean;
47
+ fetchWithdrawalsWs: boolean;
48
+ };
49
+ urls: {
50
+ test: {
51
+ ws: {
52
+ spot: string;
53
+ margin: string;
54
+ future: string;
55
+ delivery: string;
56
+ 'ws-api': {
57
+ spot: string;
58
+ future: string;
59
+ };
60
+ };
61
+ };
62
+ api: {
63
+ ws: {
64
+ spot: string;
65
+ margin: string;
66
+ future: string;
67
+ delivery: string;
68
+ 'ws-api': {
69
+ spot: string;
70
+ future: string;
71
+ };
72
+ papi: string;
73
+ };
74
+ };
75
+ doc: string;
76
+ };
77
+ streaming: {
78
+ keepAlive: number;
79
+ };
80
+ options: {
81
+ returnRateLimits: boolean;
82
+ streamLimits: {
83
+ spot: number;
84
+ margin: number;
85
+ future: number;
86
+ delivery: number;
87
+ };
88
+ subscriptionLimitByStream: {
89
+ spot: number;
90
+ margin: number;
91
+ future: number;
92
+ delivery: number;
93
+ };
94
+ streamBySubscriptionsHash: {};
95
+ streamIndex: number;
96
+ watchOrderBookRate: number;
97
+ liquidationsLimit: number;
98
+ myLiquidationsLimit: number;
99
+ tradesLimit: number;
100
+ ordersLimit: number;
101
+ OHLCVLimit: number;
102
+ requestId: {};
103
+ watchOrderBookLimit: number;
104
+ watchTrades: {
105
+ name: string;
106
+ };
107
+ watchTicker: {
108
+ name: string;
109
+ };
110
+ watchTickers: {
111
+ name: string;
112
+ };
113
+ watchOHLCV: {
114
+ name: string;
115
+ };
116
+ watchOrderBook: {
117
+ maxRetries: number;
118
+ checksum: boolean;
119
+ };
120
+ watchBalance: {
121
+ fetchBalanceSnapshot: boolean;
122
+ awaitBalanceSnapshot: boolean;
123
+ };
124
+ watchLiquidationsForSymbols: {
125
+ defaultType: string;
126
+ };
127
+ watchPositions: {
128
+ fetchPositionsSnapshot: boolean;
129
+ awaitPositionsSnapshot: boolean;
130
+ };
131
+ wallet: string;
132
+ listenKeyRefreshRate: number;
133
+ ws: {
134
+ cost: number;
135
+ };
136
+ tickerChannelsMap: {
137
+ '24hrTicker': string;
138
+ '24hrMiniTicker': string;
139
+ '1hTicker': string;
140
+ '4hTicker': string;
141
+ '1dTicker': string;
142
+ bookTicker: string;
143
+ };
144
+ };
145
+ };
6
146
  requestId(url: any): any;
7
147
  stream(type: Str, subscriptionHash: Str, numSubscriptions?: number): string;
8
148
  watchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
@@ -16,7 +16,11 @@ import { ed25519 } from '../static_dependencies/noble-curves/ed25519.js';
16
16
  // -----------------------------------------------------------------------------
17
17
  export default class binance extends binanceRest {
18
18
  describe() {
19
- return this.deepExtend(super.describe(), {
19
+ const superDescribe = super.describe();
20
+ return this.deepExtend(superDescribe, this.describeData());
21
+ }
22
+ describeData() {
23
+ return {
20
24
  'has': {
21
25
  'ws': true,
22
26
  'watchBalance': true,
@@ -158,7 +162,7 @@ export default class binance extends binanceRest {
158
162
  'bookTicker': 'bookTicker',
159
163
  },
160
164
  },
161
- });
165
+ };
162
166
  }
163
167
  requestId(url) {
164
168
  const options = this.safeDict(this.options, 'requestId', this.createSafeDictionary());
@@ -13,7 +13,8 @@ export default class binanceus extends binance {
13
13
  // eslint-disable-next-line new-cap
14
14
  const restInstance = new binanceusRest();
15
15
  const restDescribe = restInstance.describe();
16
- const extended = this.deepExtend(restDescribe, super.describe());
16
+ const parentWsDescribe = super.describeData();
17
+ const extended = this.deepExtend(restDescribe, parentWsDescribe);
17
18
  return this.deepExtend(extended, {
18
19
  'id': 'binanceus',
19
20
  'name': 'Binance US',
@@ -14,6 +14,8 @@ export default class bybit extends bybitRest {
14
14
  unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
15
15
  unWatchTicker(symbols: string, params?: {}): Promise<any>;
16
16
  handleTicker(client: Client, message: any): void;
17
+ watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
18
+ parseWsBidAsk(orderbook: any, market?: any): Ticker;
17
19
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
18
20
  watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").Dictionary<OHLCV[]>>>;
19
21
  unWatchOHLCVForSymbols(symbolsAndTimeframes: string[][], params?: {}): Promise<any>;
@@ -25,6 +25,7 @@ export default class bybit extends bybitRest {
25
25
  'fetchTradesWs': false,
26
26
  'fetchBalanceWs': false,
27
27
  'watchBalance': true,
28
+ 'watchBidsAsks': true,
28
29
  'watchLiquidations': true,
29
30
  'watchLiquidationsForSymbols': false,
30
31
  'watchMyLiquidations': false,
@@ -581,6 +582,52 @@ export default class bybit extends bybitRest {
581
582
  const messageHash = 'ticker:' + symbol;
582
583
  client.resolve(this.tickers[symbol], messageHash);
583
584
  }
585
+ async watchBidsAsks(symbols = undefined, params = {}) {
586
+ /**
587
+ * @method
588
+ * @name bybit#watchBidsAsks
589
+ * @description watches best bid & ask for symbols
590
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook
591
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
592
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
593
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
594
+ */
595
+ await this.loadMarkets();
596
+ symbols = this.marketSymbols(symbols, undefined, false);
597
+ const messageHashes = [];
598
+ const url = await this.getUrlByMarketType(symbols[0], false, 'watchBidsAsks', params);
599
+ params = this.cleanParams(params);
600
+ const marketIds = this.marketIds(symbols);
601
+ const topics = [];
602
+ for (let i = 0; i < marketIds.length; i++) {
603
+ const marketId = marketIds[i];
604
+ const topic = 'orderbook.1.' + marketId;
605
+ topics.push(topic);
606
+ messageHashes.push('bidask:' + symbols[i]);
607
+ }
608
+ const ticker = await this.watchTopics(url, messageHashes, topics, params);
609
+ if (this.newUpdates) {
610
+ return ticker;
611
+ }
612
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
613
+ }
614
+ parseWsBidAsk(orderbook, market = undefined) {
615
+ const timestamp = this.safeInteger(orderbook, 'timestamp');
616
+ const bids = this.sortBy(this.aggregate(orderbook['bids']), 0);
617
+ const asks = this.sortBy(this.aggregate(orderbook['asks']), 0);
618
+ const bestBid = this.safeList(bids, 0, []);
619
+ const bestAsk = this.safeList(asks, 0, []);
620
+ return this.safeTicker({
621
+ 'symbol': market['symbol'],
622
+ 'timestamp': timestamp,
623
+ 'datetime': this.iso8601(timestamp),
624
+ 'ask': this.safeNumber(bestAsk, 0),
625
+ 'askVolume': this.safeNumber(bestAsk, 1),
626
+ 'bid': this.safeNumber(bestBid, 0),
627
+ 'bidVolume': this.safeNumber(bestBid, 1),
628
+ 'info': orderbook,
629
+ }, market);
630
+ }
584
631
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
585
632
  /**
586
633
  * @method
@@ -905,6 +952,8 @@ export default class bybit extends bybitRest {
905
952
  // }
906
953
  // }
907
954
  //
955
+ const topic = this.safeString(message, 'topic');
956
+ const limit = topic.split('.')[1];
908
957
  const isSpot = client.url.indexOf('spot') >= 0;
909
958
  const type = this.safeString(message, 'type');
910
959
  const isSnapshot = (type === 'snapshot');
@@ -933,6 +982,13 @@ export default class bybit extends bybitRest {
933
982
  const messageHash = 'orderbook' + ':' + symbol;
934
983
  this.orderbooks[symbol] = orderbook;
935
984
  client.resolve(orderbook, messageHash);
985
+ if (limit === '1') {
986
+ const bidask = this.parseWsBidAsk(this.orderbooks[symbol], market);
987
+ const newBidsAsks = {};
988
+ newBidsAsks[symbol] = bidask;
989
+ this.bidsasks[symbol] = bidask;
990
+ client.resolve(newBidsAsks, 'bidask:' + symbol);
991
+ }
936
992
  }
937
993
  handleDelta(bookside, delta) {
938
994
  const bidAsk = this.parseBidAsk(delta, 0, 1);
@@ -9,6 +9,7 @@ export default class hyperliquid extends hyperliquidRest {
9
9
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
10
10
  unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
11
11
  handleOrderBook(client: any, message: any): void;
12
+ watchTicker(symbol: string, params?: {}): Promise<Ticker>;
12
13
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
13
14
  unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
14
15
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -22,7 +22,7 @@ export default class hyperliquid extends hyperliquidRest {
22
22
  'watchOHLCV': true,
23
23
  'watchOrderBook': true,
24
24
  'watchOrders': true,
25
- 'watchTicker': false,
25
+ 'watchTicker': true,
26
26
  'watchTickers': true,
27
27
  'watchTrades': true,
28
28
  'watchTradesForSymbols': false,
@@ -238,6 +238,21 @@ export default class hyperliquid extends hyperliquidRest {
238
238
  const messageHash = 'orderbook:' + symbol;
239
239
  client.resolve(orderbook, messageHash);
240
240
  }
241
+ async watchTicker(symbol, params = {}) {
242
+ /**
243
+ * @method
244
+ * @name hyperliquid#watchTicker
245
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
246
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
247
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
248
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
249
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
250
+ */
251
+ const market = this.market(symbol);
252
+ symbol = market['symbol'];
253
+ const tickers = await this.watchTickers([symbol], params);
254
+ return tickers[symbol];
255
+ }
241
256
  async watchTickers(symbols = undefined, params = {}) {
242
257
  /**
243
258
  * @method
@@ -1,5 +1,5 @@
1
1
  import mexcRest from '../mexc.js';
2
- import type { Int, OHLCV, Str, OrderBook, Order, Trade, Ticker, Balances, Strings, Tickers } from '../base/types.js';
2
+ import type { Int, OHLCV, Str, OrderBook, Order, Trade, Ticker, Balances, Tickers, Strings } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class mexc extends mexcRest {
5
5
  describe(): any;
@@ -8,6 +8,9 @@ export default class mexc extends mexcRest {
8
8
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
9
9
  handleTickers(client: Client, message: any): void;
10
10
  parseWsTicker(ticker: any, market?: any): Ticker;
11
+ watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
12
+ handleBidAsk(client: Client, message: any): void;
13
+ parseWsBidAsk(ticker: any, market?: any): Ticker;
11
14
  watchSpotPublic(channel: any, messageHash: any, params?: {}): Promise<any>;
12
15
  watchSpotPrivate(channel: any, messageHash: any, params?: {}): Promise<any>;
13
16
  watchSwapPublic(channel: any, messageHash: any, requestParams: any, params?: {}): Promise<any>;
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import mexcRest from '../mexc.js';
9
- import { AuthenticationError } from '../base/errors.js';
9
+ import { ArgumentsRequired, AuthenticationError, NotSupported } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
@@ -31,6 +31,7 @@ export default class mexc extends mexcRest {
31
31
  'watchOrders': true,
32
32
  'watchTicker': true,
33
33
  'watchTickers': true,
34
+ 'watchBidsAsks': true,
34
35
  'watchTrades': true,
35
36
  'watchTradesForSymbols': false,
36
37
  },
@@ -110,6 +111,7 @@ export default class mexc extends mexcRest {
110
111
  // "t": 1678643605721
111
112
  // }
112
113
  //
114
+ this.handleBidAsk(client, message);
113
115
  const rawTicker = this.safeValue2(message, 'd', 'data');
114
116
  const marketId = this.safeString2(message, 's', 'symbol');
115
117
  const timestamp = this.safeInteger(message, 't');
@@ -238,6 +240,87 @@ export default class mexc extends mexcRest {
238
240
  'info': ticker,
239
241
  }, market);
240
242
  }
243
+ async watchBidsAsks(symbols = undefined, params = {}) {
244
+ /**
245
+ * @method
246
+ * @name mexc#watchBidsAsks
247
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
248
+ * @description watches best bid & ask for symbols
249
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
250
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
251
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
252
+ */
253
+ await this.loadMarkets();
254
+ symbols = this.marketSymbols(symbols, undefined, true, false, true);
255
+ let marketType = undefined;
256
+ if (symbols === undefined) {
257
+ throw new ArgumentsRequired(this.id + 'watchBidsAsks required symbols argument');
258
+ }
259
+ const markets = this.marketsForSymbols(symbols);
260
+ [marketType, params] = this.handleMarketTypeAndParams('watchBidsAsks', markets[0], params);
261
+ const isSpot = marketType === 'spot';
262
+ if (!isSpot) {
263
+ throw new NotSupported(this.id + 'watchBidsAsks only support spot market');
264
+ }
265
+ const messageHashes = [];
266
+ const topics = [];
267
+ for (let i = 0; i < symbols.length; i++) {
268
+ if (isSpot) {
269
+ const market = this.market(symbols[i]);
270
+ topics.push('spot@public.bookTicker.v3.api@' + market['id']);
271
+ }
272
+ messageHashes.push('bidask:' + symbols[i]);
273
+ }
274
+ const url = this.urls['api']['ws']['spot'];
275
+ const request = {
276
+ 'method': 'SUBSCRIPTION',
277
+ 'params': topics,
278
+ };
279
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
280
+ if (this.newUpdates) {
281
+ const tickers = {};
282
+ tickers[ticker['symbol']] = ticker;
283
+ return tickers;
284
+ }
285
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
286
+ }
287
+ handleBidAsk(client, message) {
288
+ //
289
+ // {
290
+ // "c": "spot@public.bookTicker.v3.api@BTCUSDT",
291
+ // "d": {
292
+ // "A": "4.70432",
293
+ // "B": "6.714863",
294
+ // "a": "20744.54",
295
+ // "b": "20744.17"
296
+ // },
297
+ // "s": "BTCUSDT",
298
+ // "t": 1678643605721
299
+ // }
300
+ //
301
+ const parsedTicker = this.parseWsBidAsk(message);
302
+ const symbol = parsedTicker['symbol'];
303
+ this.bidsasks[symbol] = parsedTicker;
304
+ const messageHash = 'bidask:' + symbol;
305
+ client.resolve(parsedTicker, messageHash);
306
+ }
307
+ parseWsBidAsk(ticker, market = undefined) {
308
+ const data = this.safeDict(ticker, 'd');
309
+ const marketId = this.safeString(ticker, 's');
310
+ market = this.safeMarket(marketId, market);
311
+ const symbol = this.safeString(market, 'symbol');
312
+ const timestamp = this.safeInteger(ticker, 't');
313
+ return this.safeTicker({
314
+ 'symbol': symbol,
315
+ 'timestamp': timestamp,
316
+ 'datetime': this.iso8601(timestamp),
317
+ 'ask': this.safeNumber(data, 'a'),
318
+ 'askVolume': this.safeNumber(data, 'A'),
319
+ 'bid': this.safeNumber(data, 'b'),
320
+ 'bidVolume': this.safeNumber(data, 'B'),
321
+ 'info': ticker,
322
+ }, market);
323
+ }
241
324
  async watchSpotPublic(channel, messageHash, params = {}) {
242
325
  const url = this.urls['api']['ws']['spot'];
243
326
  const request = {
@@ -224,6 +224,7 @@ export default class paradex extends paradexRest {
224
224
  * @method
225
225
  * @name paradex#watchTickers
226
226
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
227
+ * @see https://docs.api.testnet.paradex.trade/#sub-markets_summary-operation
227
228
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
228
229
  * @param {object} [params] extra parameters specific to the exchange API endpoint
229
230
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
package/js/src/woo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/woo.js';
2
- import type { TransferEntry, Balances, Conversion, Currency, FundingRateHistory, Int, Market, MarginModification, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Dict, Strings, Trade, Transaction, Leverage, Account, Currencies, TradingFees, int, FundingHistory } from './base/types.js';
2
+ import type { TransferEntry, Balances, Conversion, Currency, FundingRateHistory, Int, Market, MarginModification, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Dict, Strings, Trade, Transaction, Leverage, Account, Currencies, TradingFees, int, FundingHistory, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class woo
5
5
  * @augments Exchange
@@ -61,24 +61,8 @@ export default class woo extends Exchange {
61
61
  info: any;
62
62
  }>;
63
63
  getAssetHistoryRows(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
64
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
65
- parseLedgerEntry(item: Dict, currency?: Currency): {
66
- id: string;
67
- currency: any;
68
- account: string;
69
- referenceAccount: any;
70
- referenceId: string;
71
- status: string;
72
- amount: number;
73
- before: any;
74
- after: any;
75
- fee: any;
76
- direction: string;
77
- timestamp: number;
78
- datetime: string;
79
- type: string;
80
- info: Dict;
81
- };
64
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
65
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
82
66
  parseLedgerEntryType(type: any): string;
83
67
  getCurrencyFromChaincode(networkizedCode: any, currency: any): any;
84
68
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
package/js/src/woo.js CHANGED
@@ -2144,9 +2144,9 @@ export default class woo extends Exchange {
2144
2144
  * @name woo#fetchLedger
2145
2145
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2146
2146
  * @see https://docs.woo.org/#get-asset-history
2147
- * @param {string} code unified currency code, default is undefined
2147
+ * @param {string} [code] unified currency code, default is undefined
2148
2148
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2149
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2149
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2150
2150
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2151
2151
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2152
2152
  */
@@ -2157,12 +2157,14 @@ export default class woo extends Exchange {
2157
2157
  const networkizedCode = this.safeString(item, 'token');
2158
2158
  const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
2159
2159
  const code = currencyDefined['code'];
2160
+ currency = this.safeCurrency(code, currency);
2160
2161
  const amount = this.safeNumber(item, 'amount');
2161
2162
  const side = this.safeString(item, 'token_side');
2162
2163
  const direction = (side === 'DEPOSIT') ? 'in' : 'out';
2163
2164
  const timestamp = this.safeTimestamp(item, 'created_time');
2164
2165
  const fee = this.parseTokenAndFeeTemp(item, 'fee_token', 'fee_amount');
2165
- return {
2166
+ return this.safeLedgerEntry({
2167
+ 'info': item,
2166
2168
  'id': this.safeString(item, 'id'),
2167
2169
  'currency': code,
2168
2170
  'account': this.safeString(item, 'account'),
@@ -2172,13 +2174,12 @@ export default class woo extends Exchange {
2172
2174
  'amount': amount,
2173
2175
  'before': undefined,
2174
2176
  'after': undefined,
2175
- 'fee': fee,
2176
2177
  'direction': direction,
2177
2178
  'timestamp': timestamp,
2178
2179
  'datetime': this.iso8601(timestamp),
2179
2180
  'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
2180
- 'info': item,
2181
- };
2181
+ 'fee': fee,
2182
+ }, currency);
2182
2183
  }
2183
2184
  parseLedgerEntryType(type) {
2184
2185
  const types = {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/woofipro.js';
2
- import type { Balances, Currency, FundingRateHistory, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Trade, Transaction, Leverage, Currencies, TradingFees, OrderRequest, Dict, int } from './base/types.js';
2
+ import type { Balances, Currency, FundingRateHistory, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Trade, Transaction, Leverage, Currencies, TradingFees, OrderRequest, Dict, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class woofipro
5
5
  * @augments Exchange
@@ -87,25 +87,9 @@ export default class woofipro extends Exchange {
87
87
  parseBalance(response: any): Balances;
88
88
  fetchBalance(params?: {}): Promise<Balances>;
89
89
  getAssetHistoryRows(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
90
- parseLedgerEntry(item: Dict, currency?: Currency): {
91
- id: string;
92
- currency: string;
93
- account: string;
94
- referenceAccount: any;
95
- referenceId: string;
96
- status: string;
97
- amount: number;
98
- before: any;
99
- after: any;
100
- fee: any;
101
- direction: string;
102
- timestamp: number;
103
- datetime: string;
104
- type: string;
105
- info: Dict;
106
- };
90
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
107
91
  parseLedgerEntryType(type: any): string;
108
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
92
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
109
93
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
110
94
  parseTransactionStatus(status: Str): string;
111
95
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -2122,13 +2122,15 @@ export default class woofipro extends Exchange {
2122
2122
  return [currency, this.safeList(data, 'rows', [])];
2123
2123
  }
2124
2124
  parseLedgerEntry(item, currency = undefined) {
2125
- const code = this.safeString(item, 'token');
2125
+ const currencyId = this.safeString(item, 'token');
2126
+ const code = this.safeCurrencyCode(currencyId, currency);
2127
+ currency = this.safeCurrency(currencyId, currency);
2126
2128
  const amount = this.safeNumber(item, 'amount');
2127
2129
  const side = this.safeString(item, 'token_side');
2128
2130
  const direction = (side === 'DEPOSIT') ? 'in' : 'out';
2129
2131
  const timestamp = this.safeInteger(item, 'created_time');
2130
2132
  const fee = this.parseTokenAndFeeTemp(item, 'fee_token', 'fee_amount');
2131
- return {
2133
+ return this.safeLedgerEntry({
2132
2134
  'id': this.safeString(item, 'id'),
2133
2135
  'currency': code,
2134
2136
  'account': this.safeString(item, 'account'),
@@ -2144,7 +2146,7 @@ export default class woofipro extends Exchange {
2144
2146
  'datetime': this.iso8601(timestamp),
2145
2147
  'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
2146
2148
  'info': item,
2147
- };
2149
+ }, currency);
2148
2150
  }
2149
2151
  parseLedgerEntryType(type) {
2150
2152
  const types = {
@@ -2157,11 +2159,11 @@ export default class woofipro extends Exchange {
2157
2159
  /**
2158
2160
  * @method
2159
2161
  * @name woofipro#fetchLedger
2160
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2162
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2161
2163
  * @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-asset-history
2162
- * @param {string} code unified currency code, default is undefined
2164
+ * @param {string} [code] unified currency code, default is undefined
2163
2165
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2164
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2166
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2165
2167
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2166
2168
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2167
2169
  */
package/js/src/xt.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/xt.js';
2
- import { Currencies, Currency, Dict, FundingHistory, FundingRateHistory, Int, LeverageTier, MarginModification, Market, Num, OHLCV, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry } from './base/types.js';
2
+ import { Currencies, Currency, Dict, FundingHistory, FundingRateHistory, Int, LeverageTier, MarginModification, Market, Num, OHLCV, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class xt
5
5
  * @augments Exchange
@@ -41,27 +41,8 @@ export default class xt extends Exchange {
41
41
  cancelOrders(ids: string[], symbol?: string, params?: {}): Promise<Order[]>;
42
42
  parseOrder(order: any, market?: any): Order;
43
43
  parseOrderStatus(status: any): string;
44
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
45
- parseLedgerEntry(item: any, currency?: any): {
46
- id: string;
47
- direction: string;
48
- account: any;
49
- referenceId: any;
50
- referenceAccount: any;
51
- type: string;
52
- currency: string;
53
- amount: number;
54
- timestamp: number;
55
- datetime: string;
56
- before: any;
57
- after: number;
58
- status: any;
59
- fee: {
60
- currency: any;
61
- cost: any;
62
- };
63
- info: any;
64
- };
44
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
45
+ parseLedgerEntry(item: any, currency?: any): LedgerEntry;
65
46
  parseLedgerEntryType(type: any): string;
66
47
  fetchDepositAddress(code: string, params?: {}): Promise<{
67
48
  currency: string;