ccxt 4.3.85 → 4.3.87

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 (77) hide show
  1. package/README.md +8 -5
  2. package/dist/ccxt.browser.min.js +15 -15
  3. package/dist/cjs/ccxt.js +7 -1
  4. package/dist/cjs/src/abstract/hashkey.js +9 -0
  5. package/dist/cjs/src/base/Exchange.js +1 -1
  6. package/dist/cjs/src/base/errors.js +8 -1
  7. package/dist/cjs/src/binance.js +4 -2
  8. package/dist/cjs/src/bingx.js +7 -1
  9. package/dist/cjs/src/bitfinex.js +2 -2
  10. package/dist/cjs/src/hashkey.js +4327 -0
  11. package/dist/cjs/src/hyperliquid.js +85 -65
  12. package/dist/cjs/src/indodax.js +37 -9
  13. package/dist/cjs/src/kraken.js +37 -6
  14. package/dist/cjs/src/krakenfutures.js +12 -10
  15. package/dist/cjs/src/pro/ascendex.js +45 -5
  16. package/dist/cjs/src/pro/bingx.js +13 -12
  17. package/dist/cjs/src/pro/bitget.js +164 -19
  18. package/dist/cjs/src/pro/hashkey.js +839 -0
  19. package/dist/cjs/src/pro/hyperliquid.js +123 -0
  20. package/dist/cjs/src/pro/mexc.js +13 -7
  21. package/dist/cjs/src/pro/p2b.js +34 -7
  22. package/dist/cjs/src/pro/poloniex.js +36 -3
  23. package/dist/cjs/src/pro/poloniexfutures.js +1 -0
  24. package/dist/cjs/src/pro/probit.js +2 -0
  25. package/dist/cjs/src/pro/upbit.js +48 -3
  26. package/dist/cjs/src/pro/vertex.js +1 -0
  27. package/dist/cjs/src/pro/wazirx.js +3 -0
  28. package/dist/cjs/src/pro/whitebit.js +9 -0
  29. package/dist/cjs/src/pro/woo.js +1 -0
  30. package/dist/cjs/src/pro/woofipro.js +1 -0
  31. package/dist/cjs/src/pro/xt.js +1 -0
  32. package/dist/cjs/src/upbit.js +1 -1
  33. package/js/ccxt.d.ts +9 -3
  34. package/js/ccxt.js +7 -3
  35. package/js/src/abstract/hashkey.d.ts +70 -0
  36. package/js/src/abstract/hashkey.js +11 -0
  37. package/js/src/base/Exchange.js +1 -1
  38. package/js/src/base/errorHierarchy.d.ts +1 -0
  39. package/js/src/base/errorHierarchy.js +1 -0
  40. package/js/src/base/errors.d.ts +5 -1
  41. package/js/src/base/errors.js +8 -2
  42. package/js/src/binance.js +4 -2
  43. package/js/src/bingx.js +7 -1
  44. package/js/src/bitfinex.js +2 -2
  45. package/js/src/hashkey.d.ts +178 -0
  46. package/js/src/hashkey.js +4328 -0
  47. package/js/src/hyperliquid.d.ts +3 -0
  48. package/js/src/hyperliquid.js +85 -65
  49. package/js/src/indodax.js +37 -9
  50. package/js/src/kraken.js +37 -6
  51. package/js/src/krakenfutures.js +12 -10
  52. package/js/src/pro/ascendex.d.ts +2 -0
  53. package/js/src/pro/ascendex.js +45 -5
  54. package/js/src/pro/bingx.js +13 -12
  55. package/js/src/pro/bitget.d.ts +8 -0
  56. package/js/src/pro/bitget.js +165 -20
  57. package/js/src/pro/hashkey.d.ts +34 -0
  58. package/js/src/pro/hashkey.js +840 -0
  59. package/js/src/pro/hyperliquid.d.ts +7 -1
  60. package/js/src/pro/hyperliquid.js +123 -0
  61. package/js/src/pro/mexc.js +13 -7
  62. package/js/src/pro/p2b.d.ts +1 -0
  63. package/js/src/pro/p2b.js +34 -7
  64. package/js/src/pro/poloniex.d.ts +1 -0
  65. package/js/src/pro/poloniex.js +36 -3
  66. package/js/src/pro/poloniexfutures.js +1 -0
  67. package/js/src/pro/probit.js +2 -0
  68. package/js/src/pro/upbit.d.ts +1 -0
  69. package/js/src/pro/upbit.js +48 -3
  70. package/js/src/pro/vertex.js +1 -0
  71. package/js/src/pro/wazirx.js +3 -0
  72. package/js/src/pro/whitebit.js +9 -0
  73. package/js/src/pro/woo.js +1 -0
  74. package/js/src/pro/woofipro.js +1 -0
  75. package/js/src/pro/xt.js +1 -0
  76. package/js/src/upbit.js +1 -1
  77. package/package.json +1 -1
@@ -1,8 +1,11 @@
1
1
  import hyperliquidRest from '../hyperliquid.js';
2
2
  import Client from '../base/ws/Client.js';
3
- import { Int, Str, Market, OrderBook, Trade, OHLCV, Order, Dict, Strings, Ticker, Tickers } from '../base/types.js';
3
+ import { Int, Str, Market, OrderBook, Trade, OHLCV, Order, Dict, Strings, Ticker, Tickers, type Num, OrderType, OrderSide, type OrderRequest } from '../base/types.js';
4
4
  export default class hyperliquid extends hyperliquidRest {
5
5
  describe(): any;
6
+ createOrdersWs(orders: OrderRequest[], params?: {}): Promise<Order[]>;
7
+ createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
8
+ editOrderWs(id: string, symbol: string, type: string, side: string, amount?: Num, price?: Num, params?: {}): Promise<Order>;
6
9
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
7
10
  handleOrderBook(client: any, message: any): void;
8
11
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -15,6 +18,7 @@ export default class hyperliquid extends hyperliquidRest {
15
18
  parseWsTrade(trade: Dict, market?: Market): Trade;
16
19
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
17
20
  handleOHLCV(client: Client, message: any): void;
21
+ handleWsPost(client: Client, message: any): void;
18
22
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
19
23
  handleOrder(client: Client, message: any): void;
20
24
  handleErrorMessage(client: Client, message: any): boolean;
@@ -23,4 +27,6 @@ export default class hyperliquid extends hyperliquidRest {
23
27
  method: string;
24
28
  };
25
29
  handlePong(client: Client, message: any): any;
30
+ requestId(): number;
31
+ wrapAsPostAction(request: Dict): Dict;
26
32
  }
@@ -14,6 +14,9 @@ export default class hyperliquid extends hyperliquidRest {
14
14
  return this.deepExtend(super.describe(), {
15
15
  'has': {
16
16
  'ws': true,
17
+ 'createOrderWs': true,
18
+ 'createOrdersWs': true,
19
+ 'editOrderWs': true,
17
20
  'watchBalance': false,
18
21
  'watchMyTrades': true,
19
22
  'watchOHLCV': true,
@@ -48,6 +51,90 @@ export default class hyperliquid extends hyperliquidRest {
48
51
  },
49
52
  });
50
53
  }
54
+ async createOrdersWs(orders, params = {}) {
55
+ /**
56
+ * @method
57
+ * @name hyperliquid#createOrdersWs
58
+ * @description create a list of trade orders using WebSocket post request
59
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
60
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
61
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
62
+ */
63
+ await this.loadMarkets();
64
+ const url = this.urls['api']['ws']['public'];
65
+ const ordersRequest = this.createOrdersRequest(orders, params);
66
+ const wrapped = this.wrapAsPostAction(ordersRequest);
67
+ const request = this.safeDict(wrapped, 'request', {});
68
+ const requestId = this.safeString(wrapped, 'requestId');
69
+ const response = await this.watch(url, requestId, request, requestId);
70
+ const responseOjb = this.safeDict(response, 'response', {});
71
+ const data = this.safeDict(responseOjb, 'data', {});
72
+ const statuses = this.safeList(data, 'statuses', []);
73
+ return this.parseOrders(statuses, undefined);
74
+ }
75
+ async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
76
+ /**
77
+ * @method
78
+ * @name hyperliquid#createOrder
79
+ * @description create a trade order using WebSocket post request
80
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
81
+ * @param {string} symbol unified symbol of the market to create an order in
82
+ * @param {string} type 'market' or 'limit'
83
+ * @param {string} side 'buy' or 'sell'
84
+ * @param {float} amount how much of currency you want to trade in units of base currency
85
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
86
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
87
+ * @param {string} [params.timeInForce] 'Gtc', 'Ioc', 'Alo'
88
+ * @param {bool} [params.postOnly] true or false whether the order is post-only
89
+ * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
90
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
91
+ * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
92
+ * @param {string} [params.slippage] the slippage for market order
93
+ * @param {string} [params.vaultAddress] the vault address for order
94
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
95
+ */
96
+ await this.loadMarkets();
97
+ const [order, globalParams] = this.parseCreateOrderArgs(symbol, type, side, amount, price, params);
98
+ const orders = await this.createOrdersWs([order], globalParams);
99
+ return orders[0];
100
+ }
101
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
102
+ /**
103
+ * @method
104
+ * @name hyperliquid#editOrder
105
+ * @description edit a trade order
106
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-an-order
107
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
108
+ * @param {string} id cancel order id
109
+ * @param {string} symbol unified symbol of the market to create an order in
110
+ * @param {string} type 'market' or 'limit'
111
+ * @param {string} side 'buy' or 'sell'
112
+ * @param {float} amount how much of currency you want to trade in units of base currency
113
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
114
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
115
+ * @param {string} [params.timeInForce] 'Gtc', 'Ioc', 'Alo'
116
+ * @param {bool} [params.postOnly] true or false whether the order is post-only
117
+ * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
118
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
119
+ * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
120
+ * @param {string} [params.vaultAddress] the vault address for order
121
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
122
+ */
123
+ await this.loadMarkets();
124
+ const market = this.market(symbol);
125
+ const url = this.urls['api']['ws']['public'];
126
+ const postRequest = this.editOrderRequest(id, symbol, type, side, amount, price, params);
127
+ const wrapped = this.wrapAsPostAction(postRequest);
128
+ const request = this.safeDict(wrapped, 'request', {});
129
+ const requestId = this.safeString(wrapped, 'requestId');
130
+ const response = await this.watch(url, requestId, request, requestId);
131
+ // response is the same as in this.editOrder
132
+ const responseObject = this.safeDict(response, 'response', {});
133
+ const dataObject = this.safeDict(responseObject, 'data', {});
134
+ const statuses = this.safeList(dataObject, 'statuses', []);
135
+ const first = this.safeDict(statuses, 0, {});
136
+ return this.parseOrder(first, market);
137
+ }
51
138
  async watchOrderBook(symbol, limit = undefined, params = {}) {
52
139
  /**
53
140
  * @method
@@ -513,6 +600,22 @@ export default class hyperliquid extends hyperliquidRest {
513
600
  const messageHash = 'candles:' + timeframe + ':' + symbol;
514
601
  client.resolve(ohlcv, messageHash);
515
602
  }
603
+ handleWsPost(client, message) {
604
+ // {
605
+ // channel: "post",
606
+ // data: {
607
+ // id: <number>,
608
+ // response: {
609
+ // type: "info" | "action" | "error",
610
+ // payload: { ... }
611
+ // }
612
+ // }
613
+ const data = this.safeDict(message, 'data');
614
+ const id = this.safeString(data, 'id');
615
+ const response = this.safeDict(data, 'response');
616
+ const payload = this.safeDict(response, 'payload');
617
+ client.resolve(payload, id);
618
+ }
516
619
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
517
620
  /**
518
621
  * @method
@@ -627,6 +730,7 @@ export default class hyperliquid extends hyperliquidRest {
627
730
  'orderUpdates': this.handleOrder,
628
731
  'userFills': this.handleMyTrades,
629
732
  'webData2': this.handleWsTickers,
733
+ 'post': this.handleWsPost,
630
734
  };
631
735
  const exacMethod = this.safeValue(methods, topic);
632
736
  if (exacMethod !== undefined) {
@@ -657,4 +761,23 @@ export default class hyperliquid extends hyperliquidRest {
657
761
  client.lastPong = this.safeInteger(message, 'pong');
658
762
  return message;
659
763
  }
764
+ requestId() {
765
+ const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
766
+ this.options['requestId'] = requestId;
767
+ return requestId;
768
+ }
769
+ wrapAsPostAction(request) {
770
+ const requestId = this.requestId();
771
+ return {
772
+ 'requestId': requestId,
773
+ 'request': {
774
+ 'method': 'post',
775
+ 'id': requestId,
776
+ 'request': {
777
+ 'type': 'action',
778
+ 'payload': request,
779
+ },
780
+ },
781
+ };
782
+ }
660
783
  }
@@ -32,6 +32,7 @@ export default class mexc extends mexcRest {
32
32
  'watchTicker': true,
33
33
  'watchTickers': false,
34
34
  'watchTrades': true,
35
+ 'watchTradesForSymbols': false,
35
36
  },
36
37
  'urls': {
37
38
  'api': {
@@ -74,6 +75,8 @@ export default class mexc extends mexcRest {
74
75
  * @method
75
76
  * @name mexc#watchTicker
76
77
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
78
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
79
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
77
80
  * @param {string} symbol unified symbol of the market to fetch the ticker for
78
81
  * @param {object} [params] extra parameters specific to the exchange API endpoint
79
82
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -206,7 +209,7 @@ export default class mexc extends mexcRest {
206
209
  /**
207
210
  * @method
208
211
  * @name mexc#watchOHLCV
209
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#kline-streams
212
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-streams
210
213
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
211
214
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
212
215
  * @param {string} timeframe the length of time each candle represents
@@ -352,7 +355,8 @@ export default class mexc extends mexcRest {
352
355
  /**
353
356
  * @method
354
357
  * @name mexc#watchOrderBook
355
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#diff-depth-stream
358
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#diff-depth-stream
359
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
356
360
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
357
361
  * @param {string} symbol unified symbol of the market to fetch the order book for
358
362
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -522,7 +526,8 @@ export default class mexc extends mexcRest {
522
526
  /**
523
527
  * @method
524
528
  * @name mexc#watchTrades
525
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#trade-streams
529
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#trade-streams
530
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
526
531
  * @description get the list of most recent trades for a particular symbol
527
532
  * @param {string} symbol unified symbol of the market to fetch trades for
528
533
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -611,7 +616,8 @@ export default class mexc extends mexcRest {
611
616
  /**
612
617
  * @method
613
618
  * @name mexc#watchMyTrades
614
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#spot-account-deals
619
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#spot-account-deals
620
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#private-channels
615
621
  * @description watches information on multiple trades made by the user
616
622
  * @param {string} symbol unified market symbol of the market trades were made in
617
623
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -758,8 +764,8 @@ export default class mexc extends mexcRest {
758
764
  /**
759
765
  * @method
760
766
  * @name mexc#watchOrders
761
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#spot-account-orders
762
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#margin-account-orders
767
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#spot-account-orders
768
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#margin-account-orders
763
769
  * @description watches information on multiple orders made by the user
764
770
  * @param {string} symbol unified market symbol of the market orders were made in
765
771
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -1010,7 +1016,7 @@ export default class mexc extends mexcRest {
1010
1016
  /**
1011
1017
  * @method
1012
1018
  * @name mexc#watchBalance
1013
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#spot-account-upadte
1019
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#spot-account-upadte
1014
1020
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
1015
1021
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1016
1022
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
@@ -7,6 +7,7 @@ export default class p2b extends p2bRest {
7
7
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
8
8
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
9
9
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
10
+ watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
10
11
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
11
12
  handleOHLCV(client: Client, message: any): any;
12
13
  handleTrade(client: Client, message: any): any;
package/js/src/pro/p2b.js CHANGED
@@ -32,6 +32,7 @@ export default class p2b extends p2bRest {
32
32
  'watchTicker': true,
33
33
  'watchTickers': false,
34
34
  'watchTrades': true,
35
+ 'watchTradesForSymbols': true,
35
36
  },
36
37
  'urls': {
37
38
  'api': {
@@ -147,15 +148,41 @@ export default class p2b extends p2bRest {
147
148
  * @param {object} [params] extra parameters specific to the exchange API endpoint
148
149
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
149
150
  */
151
+ return await this.watchTradesForSymbols([symbol], since, limit, params);
152
+ }
153
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
154
+ /**
155
+ * @method
156
+ * @name p2b#watchTradesForSymbols
157
+ * @description get the list of most recent trades for a list of symbols
158
+ * @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#deals
159
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
160
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
161
+ * @param {int} [limit] the maximum amount of trades to fetch
162
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
163
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
164
+ */
150
165
  await this.loadMarkets();
151
- const market = this.market(symbol);
152
- const request = [
153
- market['id'],
154
- ];
155
- const messageHash = 'deals::' + market['symbol'];
156
- const trades = await this.subscribe('deals.subscribe', messageHash, request, params);
166
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
167
+ const messageHashes = [];
168
+ if (symbols !== undefined) {
169
+ for (let i = 0; i < symbols.length; i++) {
170
+ messageHashes.push('deals::' + symbols[i]);
171
+ }
172
+ }
173
+ const marketIds = this.marketIds(symbols);
174
+ const url = this.urls['api']['ws'];
175
+ const subscribe = {
176
+ 'method': 'deals.subscribe',
177
+ 'params': marketIds,
178
+ 'id': this.milliseconds(),
179
+ };
180
+ const query = this.extend(subscribe, params);
181
+ const trades = await this.watchMultiple(url, messageHashes, query, messageHashes);
157
182
  if (this.newUpdates) {
158
- limit = trades.getLimit(symbol, limit);
183
+ const first = this.safeValue(trades, 0);
184
+ const tradeSymbol = this.safeString(first, 'symbol');
185
+ limit = trades.getLimit(tradeSymbol, limit);
159
186
  }
160
187
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
161
188
  }
@@ -15,6 +15,7 @@ export default class poloniex extends poloniexRest {
15
15
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
16
16
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
17
17
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
18
+ watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
18
19
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
19
20
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
20
21
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -21,6 +21,7 @@ export default class poloniex extends poloniexRest {
21
21
  'watchTicker': true,
22
22
  'watchTickers': true,
23
23
  'watchTrades': true,
24
+ 'watchTradesForSymbols': true,
24
25
  'watchBalance': true,
25
26
  'watchStatus': false,
26
27
  'watchOrders': true,
@@ -398,12 +399,44 @@ export default class poloniex extends poloniexRest {
398
399
  * @param {object} [params] extra parameters specific to the exchange API endpoint
399
400
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
400
401
  */
402
+ return await this.watchTradesForSymbols([symbol], since, limit, params);
403
+ }
404
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
405
+ /**
406
+ * @method
407
+ * @name poloniex#watchTradesForSymbols
408
+ * @description get the list of most recent trades for a list of symbols
409
+ * @see https://api-docs.poloniex.com/spot/websocket/market-data#trades
410
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
411
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
412
+ * @param {int} [limit] the maximum amount of trades to fetch
413
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
414
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
415
+ */
401
416
  await this.loadMarkets();
402
- symbol = this.symbol(symbol);
417
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
403
418
  const name = 'trades';
404
- const trades = await this.subscribe(name, name, false, [symbol], params);
419
+ const url = this.urls['api']['ws']['public'];
420
+ const marketIds = this.marketIds(symbols);
421
+ const subscribe = {
422
+ 'event': 'subscribe',
423
+ 'channel': [
424
+ name,
425
+ ],
426
+ 'symbols': marketIds,
427
+ };
428
+ const request = this.extend(subscribe, params);
429
+ const messageHashes = [];
430
+ if (symbols !== undefined) {
431
+ for (let i = 0; i < symbols.length; i++) {
432
+ messageHashes.push(name + '::' + symbols[i]);
433
+ }
434
+ }
435
+ const trades = await this.watchMultiple(url, messageHashes, request, messageHashes);
405
436
  if (this.newUpdates) {
406
- limit = trades.getLimit(symbol, limit);
437
+ const first = this.safeValue(trades, 0);
438
+ const tradeSymbol = this.safeString(first, 'symbol');
439
+ limit = trades.getLimit(tradeSymbol, limit);
407
440
  }
408
441
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
409
442
  }
@@ -28,6 +28,7 @@ export default class poloniexfutures extends poloniexfuturesRest {
28
28
  'watchTicker': true,
29
29
  'watchTickers': false,
30
30
  'watchTrades': true,
31
+ 'watchTradesForSymbols': false,
31
32
  'watchBalance': true,
32
33
  'watchOrders': true,
33
34
  'watchMyTrades': false,
@@ -18,6 +18,7 @@ export default class probit extends probitRest {
18
18
  'watchTicker': true,
19
19
  'watchTickers': false,
20
20
  'watchTrades': true,
21
+ 'watchTradesForSymbols': false,
21
22
  'watchMyTrades': true,
22
23
  'watchOrders': true,
23
24
  'watchOrderBook': true,
@@ -225,6 +226,7 @@ export default class probit extends probitRest {
225
226
  * @method
226
227
  * @name probit#watchMyTrades
227
228
  * @description get the list of trades associated with the user
229
+ * @see https://docs-en.probit.com/reference/trade_history
228
230
  * @param {string} symbol unified symbol of the market to fetch trades for
229
231
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
230
232
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -6,6 +6,7 @@ export default class upbit extends upbitRest {
6
6
  watchPublic(symbol: string, channel: any, params?: {}): Promise<any>;
7
7
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
8
8
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
9
+ watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
9
10
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
10
11
  handleTicker(client: Client, message: any): void;
11
12
  handleOrderBook(client: Client, message: any): void;
@@ -18,6 +18,7 @@ export default class upbit extends upbitRest {
18
18
  'watchOrderBook': true,
19
19
  'watchTicker': true,
20
20
  'watchTrades': true,
21
+ 'watchTradesForSymbols': true,
21
22
  'watchOrders': true,
22
23
  'watchMyTrades': true,
23
24
  'watchBalance': true,
@@ -82,11 +83,55 @@ export default class upbit extends upbitRest {
82
83
  * @param {object} [params] extra parameters specific to the exchange API endpoint
83
84
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
84
85
  */
86
+ return await this.watchTradesForSymbols([symbol], since, limit, params);
87
+ }
88
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
89
+ /**
90
+ * @method
91
+ * @name upbit#watchTradesForSymbols
92
+ * @description get the list of most recent trades for a list of symbols
93
+ * @see https://global-docs.upbit.com/reference/websocket-trade
94
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
95
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
96
+ * @param {int} [limit] the maximum amount of trades to fetch
97
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
98
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
99
+ */
85
100
  await this.loadMarkets();
86
- symbol = this.symbol(symbol);
87
- const trades = await this.watchPublic(symbol, 'trade');
101
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
102
+ const channel = 'trade';
103
+ const messageHashes = [];
104
+ const url = this.implodeParams(this.urls['api']['ws'], {
105
+ 'hostname': this.hostname,
106
+ });
107
+ if (symbols !== undefined) {
108
+ for (let i = 0; i < symbols.length; i++) {
109
+ const market = this.market(symbols[i]);
110
+ const marketId = market['id'];
111
+ const symbol = market['symbol'];
112
+ this.options[channel] = this.safeValue(this.options, channel, {});
113
+ this.options[channel][symbol] = true;
114
+ messageHashes.push(channel + ':' + marketId);
115
+ }
116
+ }
117
+ const optionSymbols = Object.keys(this.options[channel]);
118
+ const marketIds = this.marketIds(optionSymbols);
119
+ const request = [
120
+ {
121
+ 'ticket': this.uuid(),
122
+ },
123
+ {
124
+ 'type': channel,
125
+ 'codes': marketIds,
126
+ // 'isOnlySnapshot': false,
127
+ // 'isOnlyRealtime': false,
128
+ },
129
+ ];
130
+ const trades = await this.watchMultiple(url, messageHashes, request, messageHashes);
88
131
  if (this.newUpdates) {
89
- limit = trades.getLimit(symbol, limit);
132
+ const first = this.safeValue(trades, 0);
133
+ const tradeSymbol = this.safeString(first, 'symbol');
134
+ limit = trades.getLimit(tradeSymbol, limit);
90
135
  }
91
136
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
92
137
  }
@@ -23,6 +23,7 @@ export default class vertex extends vertexRest {
23
23
  'watchTicker': true,
24
24
  'watchTickers': false,
25
25
  'watchTrades': true,
26
+ 'watchTradesForSymbols': false,
26
27
  'watchPositions': true,
27
28
  },
28
29
  'urls': {
@@ -18,6 +18,7 @@ export default class wazirx extends wazirxRest {
18
18
  'watchTicker': true,
19
19
  'watchTickers': true,
20
20
  'watchTrades': true,
21
+ 'watchTradesForSymbols': false,
21
22
  'watchMyTrades': true,
22
23
  'watchOrders': true,
23
24
  'watchOrderBook': true,
@@ -287,6 +288,7 @@ export default class wazirx extends wazirxRest {
287
288
  * @method
288
289
  * @name wazirx#watchTrades
289
290
  * @description get the list of most recent trades for a particular symbol
291
+ * @see https://docs.wazirx.com/#trade-streams
290
292
  * @param {string} symbol unified symbol of the market to fetch trades for
291
293
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
292
294
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -384,6 +386,7 @@ export default class wazirx extends wazirxRest {
384
386
  * @method
385
387
  * @name wazirx#watchOHLCV
386
388
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
389
+ * @see https://docs.wazirx.com/#kline-candlestick-stream
387
390
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
388
391
  * @param {string} timeframe the length of time each candle represents
389
392
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -22,6 +22,7 @@ export default class whitebit extends whitebitRest {
22
22
  'watchOrders': true,
23
23
  'watchTicker': true,
24
24
  'watchTrades': true,
25
+ 'watchTradesForSymbols': false,
25
26
  },
26
27
  'urls': {
27
28
  'api': {
@@ -64,6 +65,7 @@ export default class whitebit extends whitebitRest {
64
65
  * @method
65
66
  * @name whitebit#watchOHLCV
66
67
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
68
+ * @see https://docs.whitebit.com/public/websocket/#kline
67
69
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
68
70
  * @param {string} timeframe the length of time each candle represents
69
71
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -138,6 +140,7 @@ export default class whitebit extends whitebitRest {
138
140
  * @method
139
141
  * @name whitebit#watchOrderBook
140
142
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
143
+ * @see https://docs.whitebit.com/public/websocket/#market-depth
141
144
  * @param {string} symbol unified symbol of the market to fetch the order book for
142
145
  * @param {int} [limit] the maximum amount of order book entries to return
143
146
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -243,6 +246,7 @@ export default class whitebit extends whitebitRest {
243
246
  * @method
244
247
  * @name whitebit#watchTicker
245
248
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
249
+ * @see https://docs.whitebit.com/public/websocket/#market-statistics
246
250
  * @param {string} symbol unified symbol of the market to fetch the ticker for
247
251
  * @param {object} [params] extra parameters specific to the exchange API endpoint
248
252
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -309,6 +313,7 @@ export default class whitebit extends whitebitRest {
309
313
  * @method
310
314
  * @name whitebit#watchTrades
311
315
  * @description get the list of most recent trades for a particular symbol
316
+ * @see https://docs.whitebit.com/public/websocket/#market-trades
312
317
  * @param {string} symbol unified symbol of the market to fetch trades for
313
318
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
314
319
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -375,6 +380,7 @@ export default class whitebit extends whitebitRest {
375
380
  * @method
376
381
  * @name whitebit#watchMyTrades
377
382
  * @description watches trades made by the user
383
+ * @see https://docs.whitebit.com/private/websocket/#deals
378
384
  * @param {str} symbol unified market symbol
379
385
  * @param {int} [since] the earliest time in ms to fetch trades for
380
386
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -474,6 +480,7 @@ export default class whitebit extends whitebitRest {
474
480
  * @method
475
481
  * @name whitebit#watchOrders
476
482
  * @description watches information on multiple orders made by the user
483
+ * @see https://docs.whitebit.com/private/websocket/#orders-pending
477
484
  * @param {string} symbol unified market symbol of the market orders were made in
478
485
  * @param {int} [since] the earliest time in ms to fetch orders for
479
486
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -649,6 +656,8 @@ export default class whitebit extends whitebitRest {
649
656
  * @method
650
657
  * @name whitebit#watchBalance
651
658
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
659
+ * @see https://docs.whitebit.com/private/websocket/#balance-spot
660
+ * @see https://docs.whitebit.com/private/websocket/#balance-margin
652
661
  * @param {object} [params] extra parameters specific to the exchange API endpoint
653
662
  * @param {str} [params.type] spot or contract if not provided this.options['defaultType'] is used
654
663
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
package/js/src/pro/woo.js CHANGED
@@ -24,6 +24,7 @@ export default class woo extends wooRest {
24
24
  'watchTicker': true,
25
25
  'watchTickers': true,
26
26
  'watchTrades': true,
27
+ 'watchTradesForSymbols': false,
27
28
  'watchPositions': true,
28
29
  },
29
30
  'urls': {
@@ -25,6 +25,7 @@ export default class woofipro extends woofiproRest {
25
25
  'watchTicker': true,
26
26
  'watchTickers': true,
27
27
  'watchTrades': true,
28
+ 'watchTradesForSymbols': false,
28
29
  'watchPositions': true,
29
30
  },
30
31
  'urls': {
package/js/src/pro/xt.js CHANGED
@@ -18,6 +18,7 @@ export default class xt extends xtRest {
18
18
  'watchTicker': true,
19
19
  'watchTickers': true,
20
20
  'watchTrades': true,
21
+ 'watchTradesForSymbols': false,
21
22
  'watchBalance': true,
22
23
  'watchOrders': true,
23
24
  'watchMyTrades': true,
package/js/src/upbit.js CHANGED
@@ -2004,7 +2004,7 @@ export default class upbit extends Exchange {
2004
2004
  headers['Content-Type'] = 'application/json';
2005
2005
  }
2006
2006
  if (hasQuery) {
2007
- auth = this.urlencode(query);
2007
+ auth = this.rawencode(query);
2008
2008
  }
2009
2009
  if (auth !== undefined) {
2010
2010
  const hash = this.hash(this.encode(auth), sha512);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.85",
3
+ "version": "4.3.87",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",