ccxt 4.2.82 → 4.2.83

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 (126) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +794 -183
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +3 -1
  5. package/dist/cjs/src/bitget.js +1 -0
  6. package/dist/cjs/src/bithumb.js +1 -0
  7. package/dist/cjs/src/bitstamp.js +42 -15
  8. package/dist/cjs/src/deribit.js +19 -1
  9. package/dist/cjs/src/gemini.js +2 -1
  10. package/dist/cjs/src/hyperliquid.js +5 -4
  11. package/dist/cjs/src/kucoinfutures.js +147 -8
  12. package/dist/cjs/src/pro/bithumb.js +388 -0
  13. package/dist/cjs/src/pro/bitmart.js +1 -1
  14. package/dist/cjs/src/pro/bybit.js +1 -1
  15. package/dist/cjs/src/pro/cex.js +18 -5
  16. package/dist/cjs/src/pro/okx.js +2 -1
  17. package/dist/cjs/src/pro/p2b.js +14 -4
  18. package/dist/cjs/src/pro/woo.js +1 -1
  19. package/js/ccxt.d.ts +4 -1
  20. package/js/ccxt.js +3 -1
  21. package/js/src/abstract/bitstamp.d.ts +1 -1
  22. package/js/src/ace.d.ts +1 -1
  23. package/js/src/alpaca.d.ts +1 -1
  24. package/js/src/ascendex.d.ts +1 -1
  25. package/js/src/bigone.d.ts +1 -1
  26. package/js/src/binance.d.ts +1 -1
  27. package/js/src/bingx.d.ts +1 -1
  28. package/js/src/bitbank.d.ts +1 -1
  29. package/js/src/bitbns.d.ts +1 -1
  30. package/js/src/bitfinex.d.ts +1 -1
  31. package/js/src/bitfinex2.d.ts +1 -1
  32. package/js/src/bitflyer.d.ts +1 -1
  33. package/js/src/bitget.d.ts +1 -1
  34. package/js/src/bitget.js +1 -0
  35. package/js/src/bithumb.d.ts +1 -1
  36. package/js/src/bithumb.js +1 -0
  37. package/js/src/bitmart.d.ts +1 -1
  38. package/js/src/bitmex.d.ts +1 -1
  39. package/js/src/bitopro.d.ts +1 -1
  40. package/js/src/bitrue.d.ts +1 -1
  41. package/js/src/bitso.d.ts +1 -1
  42. package/js/src/bitstamp.d.ts +1 -1
  43. package/js/src/bitstamp.js +42 -15
  44. package/js/src/bitteam.d.ts +1 -1
  45. package/js/src/bitvavo.d.ts +1 -1
  46. package/js/src/blockchaincom.d.ts +1 -1
  47. package/js/src/blofin.d.ts +1 -1
  48. package/js/src/btcalpha.d.ts +1 -1
  49. package/js/src/btcmarkets.d.ts +1 -1
  50. package/js/src/btcturk.d.ts +1 -1
  51. package/js/src/bybit.d.ts +1 -1
  52. package/js/src/cex.d.ts +1 -1
  53. package/js/src/coinbase.d.ts +1 -1
  54. package/js/src/coinbaseinternational.d.ts +1 -1
  55. package/js/src/coinbasepro.d.ts +1 -1
  56. package/js/src/coinex.d.ts +1 -1
  57. package/js/src/coinlist.d.ts +1 -1
  58. package/js/src/coinmate.d.ts +1 -1
  59. package/js/src/coinmetro.d.ts +1 -1
  60. package/js/src/coinone.d.ts +1 -1
  61. package/js/src/coinsph.d.ts +1 -1
  62. package/js/src/cryptocom.d.ts +1 -1
  63. package/js/src/currencycom.d.ts +1 -1
  64. package/js/src/delta.d.ts +1 -1
  65. package/js/src/deribit.d.ts +1 -1
  66. package/js/src/deribit.js +19 -1
  67. package/js/src/digifinex.d.ts +1 -1
  68. package/js/src/exmo.d.ts +1 -1
  69. package/js/src/gate.d.ts +1 -1
  70. package/js/src/gemini.d.ts +1 -1
  71. package/js/src/gemini.js +2 -1
  72. package/js/src/hitbtc.d.ts +1 -1
  73. package/js/src/hollaex.d.ts +1 -1
  74. package/js/src/htx.d.ts +1 -1
  75. package/js/src/huobijp.d.ts +1 -1
  76. package/js/src/hyperliquid.d.ts +1 -1
  77. package/js/src/hyperliquid.js +5 -4
  78. package/js/src/idex.d.ts +1 -1
  79. package/js/src/independentreserve.d.ts +1 -1
  80. package/js/src/indodax.d.ts +1 -1
  81. package/js/src/kraken.d.ts +1 -1
  82. package/js/src/krakenfutures.d.ts +1 -1
  83. package/js/src/kucoin.d.ts +1 -1
  84. package/js/src/kucoinfutures.d.ts +3 -2
  85. package/js/src/kucoinfutures.js +147 -8
  86. package/js/src/kuna.d.ts +1 -1
  87. package/js/src/latoken.d.ts +1 -1
  88. package/js/src/lbank.d.ts +1 -1
  89. package/js/src/luno.d.ts +1 -1
  90. package/js/src/lykke.d.ts +1 -1
  91. package/js/src/mercado.d.ts +1 -1
  92. package/js/src/mexc.d.ts +1 -1
  93. package/js/src/ndax.d.ts +1 -1
  94. package/js/src/novadax.d.ts +1 -1
  95. package/js/src/oceanex.d.ts +1 -1
  96. package/js/src/okcoin.d.ts +1 -1
  97. package/js/src/okx.d.ts +1 -1
  98. package/js/src/onetrading.d.ts +1 -1
  99. package/js/src/p2b.d.ts +1 -1
  100. package/js/src/phemex.d.ts +1 -1
  101. package/js/src/poloniex.d.ts +1 -1
  102. package/js/src/poloniexfutures.d.ts +1 -1
  103. package/js/src/pro/bithumb.d.ts +19 -0
  104. package/js/src/pro/bithumb.js +389 -0
  105. package/js/src/pro/bitmart.js +1 -1
  106. package/js/src/pro/bybit.js +1 -1
  107. package/js/src/pro/cex.js +18 -5
  108. package/js/src/pro/okx.js +2 -1
  109. package/js/src/pro/p2b.d.ts +2 -0
  110. package/js/src/pro/p2b.js +14 -4
  111. package/js/src/pro/woo.js +1 -1
  112. package/js/src/probit.d.ts +1 -1
  113. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  114. package/js/src/timex.d.ts +1 -1
  115. package/js/src/tokocrypto.d.ts +1 -1
  116. package/js/src/tradeogre.d.ts +1 -1
  117. package/js/src/upbit.d.ts +1 -1
  118. package/js/src/wavesexchange.d.ts +1 -1
  119. package/js/src/wazirx.d.ts +1 -1
  120. package/js/src/whitebit.d.ts +1 -1
  121. package/js/src/woo.d.ts +1 -1
  122. package/js/src/yobit.d.ts +1 -1
  123. package/js/src/zaif.d.ts +1 -1
  124. package/js/src/zonda.d.ts +1 -1
  125. package/package.json +1 -1
  126. package/skip-tests.json +17 -4
@@ -0,0 +1,389 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import bithumbRest from '../bithumb.js';
9
+ import { ArrayCache } from '../base/ws/Cache.js';
10
+ import { ExchangeError } from '../base/errors.js';
11
+ // ---------------------------------------------------------------------------
12
+ export default class bithumb extends bithumbRest {
13
+ describe() {
14
+ return this.deepExtend(super.describe(), {
15
+ 'has': {
16
+ 'ws': true,
17
+ 'watchBalance': false,
18
+ 'watchTicker': true,
19
+ 'watchTickers': true,
20
+ 'watchTrades': true,
21
+ 'watchOrderBook': true,
22
+ 'watchOHLCV': false,
23
+ },
24
+ 'urls': {
25
+ 'api': {
26
+ 'ws': 'wss://pubwss.bithumb.com/pub/ws',
27
+ },
28
+ },
29
+ 'options': {},
30
+ 'streaming': {},
31
+ 'exceptions': {},
32
+ });
33
+ }
34
+ async watchTicker(symbol, params = {}) {
35
+ /**
36
+ * @method
37
+ * @name bithumb#watchTicker
38
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
39
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
40
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
41
+ * @param {string} [params.channel] the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
42
+ * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
43
+ */
44
+ const url = this.urls['api']['ws'];
45
+ await this.loadMarkets();
46
+ const market = this.market(symbol);
47
+ const messageHash = 'ticker:' + market['symbol'];
48
+ const request = {
49
+ 'type': 'ticker',
50
+ 'symbols': [market['base'] + '_' + market['quote']],
51
+ 'tickTypes': [this.safeString(params, 'tickTypes', '24H')],
52
+ };
53
+ return await this.watch(url, messageHash, this.extend(request, params), messageHash);
54
+ }
55
+ async watchTickers(symbols = undefined, params = {}) {
56
+ /**
57
+ * @method
58
+ * @name binance#watchTickers
59
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
60
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
61
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
62
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
63
+ */
64
+ await this.loadMarkets();
65
+ const url = this.urls['api']['ws'];
66
+ const marketIds = [];
67
+ const messageHashes = [];
68
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
69
+ for (let i = 0; i < symbols.length; i++) {
70
+ const symbol = symbols[i];
71
+ const market = this.market(symbol);
72
+ marketIds.push(market['base'] + '_' + market['quote']);
73
+ messageHashes.push('ticker:' + market['symbol']);
74
+ }
75
+ const request = {
76
+ 'type': 'ticker',
77
+ 'symbols': marketIds,
78
+ 'tickTypes': [this.safeString(params, 'tickTypes', '24H')],
79
+ };
80
+ const message = this.extend(request, params);
81
+ const newTicker = await this.watchMultiple(url, messageHashes, message, messageHashes);
82
+ if (this.newUpdates) {
83
+ const result = {};
84
+ result[newTicker['symbol']] = newTicker;
85
+ return result;
86
+ }
87
+ return this.filterByArray(this.tickers, 'symbol', symbols);
88
+ }
89
+ handleTicker(client, message) {
90
+ //
91
+ // {
92
+ // "type" : "ticker",
93
+ // "content" : {
94
+ // "symbol" : "BTC_KRW", // 통화코드
95
+ // "tickType" : "24H", // 변동 기준시간- 30M, 1H, 12H, 24H, MID
96
+ // "date" : "20200129", // 일자
97
+ // "time" : "121844", // 시간
98
+ // "openPrice" : "2302", // 시가
99
+ // "closePrice" : "2317", // 종가
100
+ // "lowPrice" : "2272", // 저가
101
+ // "highPrice" : "2344", // 고가
102
+ // "value" : "2831915078.07065789", // 누적거래금액
103
+ // "volume" : "1222314.51355788", // 누적거래량
104
+ // "sellVolume" : "760129.34079004", // 매도누적거래량
105
+ // "buyVolume" : "462185.17276784", // 매수누적거래량
106
+ // "prevClosePrice" : "2326", // 전일종가
107
+ // "chgRate" : "0.65", // 변동률
108
+ // "chgAmt" : "15", // 변동금액
109
+ // "volumePower" : "60.80" // 체결강도
110
+ // }
111
+ // }
112
+ //
113
+ const content = this.safeDict(message, 'content', {});
114
+ const marketId = this.safeString(content, 'symbol');
115
+ const symbol = this.safeSymbol(marketId, undefined, '_');
116
+ const ticker = this.parseWsTicker(content);
117
+ const messageHash = 'ticker:' + symbol;
118
+ this.tickers[symbol] = ticker;
119
+ client.resolve(this.tickers[symbol], messageHash);
120
+ }
121
+ parseWsTicker(ticker, market = undefined) {
122
+ //
123
+ // {
124
+ // "symbol" : "BTC_KRW", // 통화코드
125
+ // "tickType" : "24H", // 변동 기준시간- 30M, 1H, 12H, 24H, MID
126
+ // "date" : "20200129", // 일자
127
+ // "time" : "121844", // 시간
128
+ // "openPrice" : "2302", // 시가
129
+ // "closePrice" : "2317", // 종가
130
+ // "lowPrice" : "2272", // 저가
131
+ // "highPrice" : "2344", // 고가
132
+ // "value" : "2831915078.07065789", // 누적거래금액
133
+ // "volume" : "1222314.51355788", // 누적거래량
134
+ // "sellVolume" : "760129.34079004", // 매도누적거래량
135
+ // "buyVolume" : "462185.17276784", // 매수누적거래량
136
+ // "prevClosePrice" : "2326", // 전일종가
137
+ // "chgRate" : "0.65", // 변동률
138
+ // "chgAmt" : "15", // 변동금액
139
+ // "volumePower" : "60.80" // 체결강도
140
+ // }
141
+ //
142
+ const date = this.safeString(ticker, 'date', '');
143
+ const time = this.safeString(ticker, 'time', '');
144
+ const datetime = date.slice(0, 4) + '-' + date.slice(4, 6) + '-' + date.slice(6, 8) + 'T' + time.slice(0, 2) + ':' + time.slice(2, 4) + ':' + time.slice(4, 6);
145
+ const marketId = this.safeString(ticker, 'symbol');
146
+ return this.safeTicker({
147
+ 'symbol': this.safeSymbol(marketId, market, '_'),
148
+ 'timestamp': this.parse8601(datetime),
149
+ 'datetime': datetime,
150
+ 'high': this.safeString(ticker, 'highPrice'),
151
+ 'low': this.safeString(ticker, 'lowPrice'),
152
+ 'bid': undefined,
153
+ 'bidVolume': this.safeString(ticker, 'buyVolume'),
154
+ 'ask': undefined,
155
+ 'askVolume': this.safeString(ticker, 'sellVolume'),
156
+ 'vwap': undefined,
157
+ 'open': this.safeString(ticker, 'openPrice'),
158
+ 'close': this.safeString(ticker, 'closePrice'),
159
+ 'last': undefined,
160
+ 'previousClose': this.safeString(ticker, 'prevClosePrice'),
161
+ 'change': this.safeString(ticker, 'chgAmt'),
162
+ 'percentage': this.safeString(ticker, 'chgRate'),
163
+ 'average': undefined,
164
+ 'baseVolume': this.safeString(ticker, 'volume'),
165
+ 'quoteVolume': this.safeString(ticker, 'value'),
166
+ 'info': ticker,
167
+ }, market);
168
+ }
169
+ async watchOrderBook(symbol, limit = undefined, params = {}) {
170
+ /**
171
+ * @method
172
+ * @name bithumb#watchOrderBook
173
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
174
+ * @param {string} symbol unified symbol of the market to fetch the order book for
175
+ * @param {int} [limit] the maximum amount of order book entries to return
176
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
177
+ * @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
178
+ */
179
+ await this.loadMarkets();
180
+ const url = this.urls['api']['ws'];
181
+ const market = this.market(symbol);
182
+ symbol = market['symbol'];
183
+ const messageHash = 'orderbook' + ':' + symbol;
184
+ const request = {
185
+ 'type': 'orderbookdepth',
186
+ 'symbols': [market['base'] + '_' + market['quote']],
187
+ };
188
+ const orderbook = await this.watch(url, messageHash, this.extend(request, params), messageHash);
189
+ return orderbook.limit();
190
+ }
191
+ handleOrderBook(client, message) {
192
+ //
193
+ // {
194
+ // "type" : "orderbookdepth",
195
+ // "content" : {
196
+ // "list" : [
197
+ // {
198
+ // "symbol" : "BTC_KRW",
199
+ // "orderType" : "ask", // 주문타입 – bid / ask
200
+ // "price" : "10593000", // 호가
201
+ // "quantity" : "1.11223318", // 잔량
202
+ // "total" : "3" // 건수
203
+ // },
204
+ // {"symbol" : "BTC_KRW", "orderType" : "ask", "price" : "10596000", "quantity" : "0.5495", "total" : "8"},
205
+ // {"symbol" : "BTC_KRW", "orderType" : "ask", "price" : "10598000", "quantity" : "18.2085", "total" : "10"},
206
+ // {"symbol" : "BTC_KRW", "orderType" : "bid", "price" : "10532000", "quantity" : "0", "total" : "0"},
207
+ // {"symbol" : "BTC_KRW", "orderType" : "bid", "price" : "10572000", "quantity" : "2.3324", "total" : "4"},
208
+ // {"symbol" : "BTC_KRW", "orderType" : "bid", "price" : "10571000", "quantity" : "1.469", "total" : "3"},
209
+ // {"symbol" : "BTC_KRW", "orderType" : "bid", "price" : "10569000", "quantity" : "0.5152", "total" : "2"}
210
+ // ],
211
+ // "datetime":1580268255864325 // 일시
212
+ // }
213
+ // }
214
+ //
215
+ const content = this.safeDict(message, 'content', {});
216
+ const list = this.safeList(content, 'list', []);
217
+ const first = this.safeDict(list, 0, {});
218
+ const marketId = this.safeString(first, 'symbol');
219
+ const symbol = this.safeSymbol(marketId, undefined, '_');
220
+ const timestampStr = this.safeString(content, 'datetime');
221
+ const timestamp = this.parseToInt(timestampStr.slice(0, 13));
222
+ if (!(symbol in this.orderbooks)) {
223
+ const ob = this.orderBook();
224
+ ob['symbol'] = symbol;
225
+ this.orderbooks[symbol] = ob;
226
+ }
227
+ const orderbook = this.orderbooks[symbol];
228
+ this.handleDeltas(orderbook, list);
229
+ orderbook['timestamp'] = timestamp;
230
+ orderbook['datetime'] = this.iso8601(timestamp);
231
+ const messageHash = 'orderbook' + ':' + symbol;
232
+ client.resolve(orderbook, messageHash);
233
+ }
234
+ handleDelta(orderbook, delta) {
235
+ //
236
+ // {
237
+ // symbol: "ETH_BTC",
238
+ // orderType: "bid",
239
+ // price: "0.07349517",
240
+ // quantity: "0",
241
+ // total: "0",
242
+ // }
243
+ //
244
+ const sideId = this.safeString(delta, 'orderType');
245
+ const side = (sideId === 'bid') ? 'bids' : 'asks';
246
+ const bidAsk = this.parseBidAsk(delta, 'price', 'quantity');
247
+ const orderbookSide = orderbook[side];
248
+ orderbookSide.storeArray(bidAsk);
249
+ }
250
+ handleDeltas(orderbook, deltas) {
251
+ for (let i = 0; i < deltas.length; i++) {
252
+ this.handleDelta(orderbook, deltas[i]);
253
+ }
254
+ }
255
+ async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
256
+ /**
257
+ * @method
258
+ * @name bithumb#watchTrades
259
+ * @description get the list of most recent trades for a particular symbol
260
+ * @param {string} symbol unified symbol of the market to fetch trades for
261
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
262
+ * @param {int} [limit] the maximum amount of trades to fetch
263
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
264
+ * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
265
+ */
266
+ await this.loadMarkets();
267
+ const url = this.urls['api']['ws'];
268
+ const market = this.market(symbol);
269
+ symbol = market['symbol'];
270
+ const messageHash = 'trade:' + symbol;
271
+ const request = {
272
+ 'type': 'transaction',
273
+ 'symbols': [market['base'] + '_' + market['quote']],
274
+ };
275
+ const trades = await this.watch(url, messageHash, this.extend(request, params), messageHash);
276
+ if (this.newUpdates) {
277
+ limit = trades.getLimit(symbol, limit);
278
+ }
279
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
280
+ }
281
+ handleTrades(client, message) {
282
+ //
283
+ // {
284
+ // "type" : "transaction",
285
+ // "content" : {
286
+ // "list" : [
287
+ // {
288
+ // "symbol" : "BTC_KRW",
289
+ // "buySellGb" : "1",
290
+ // "contPrice" : "10579000",
291
+ // "contQty" : "0.01",
292
+ // "contAmt" : "105790.00",
293
+ // "contDtm" : "2020-01-29 12:24:18.830039",
294
+ // "updn" : "dn"
295
+ // }
296
+ // ]
297
+ // }
298
+ // }
299
+ //
300
+ const content = this.safeDict(message, 'content', {});
301
+ const rawTrades = this.safeList(content, 'list', []);
302
+ for (let i = 0; i < rawTrades.length; i++) {
303
+ const rawTrade = rawTrades[i];
304
+ const marketId = this.safeString(rawTrade, 'symbol');
305
+ const symbol = this.safeSymbol(marketId, undefined, '_');
306
+ if (!(symbol in this.trades)) {
307
+ const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
308
+ const stored = new ArrayCache(limit);
309
+ this.trades[symbol] = stored;
310
+ }
311
+ const trades = this.trades[symbol];
312
+ const parsed = this.parseWsTrade(rawTrade);
313
+ trades.append(parsed);
314
+ const messageHash = 'trade' + ':' + symbol;
315
+ client.resolve(trades, messageHash);
316
+ }
317
+ }
318
+ parseWsTrade(trade, market = undefined) {
319
+ //
320
+ // {
321
+ // "symbol" : "BTC_KRW",
322
+ // "buySellGb" : "1",
323
+ // "contPrice" : "10579000",
324
+ // "contQty" : "0.01",
325
+ // "contAmt" : "105790.00",
326
+ // "contDtm" : "2020-01-29 12:24:18.830039",
327
+ // "updn" : "dn"
328
+ // }
329
+ //
330
+ const marketId = this.safeString(trade, 'symbol');
331
+ const datetime = this.safeString(trade, 'contDtm');
332
+ const sideId = this.safeString(trade, 'buySellGb');
333
+ return this.safeTrade({
334
+ 'id': undefined,
335
+ 'info': trade,
336
+ 'timestamp': this.parse8601(datetime),
337
+ 'datetime': datetime,
338
+ 'symbol': this.safeSymbol(marketId, market, '_'),
339
+ 'order': undefined,
340
+ 'type': undefined,
341
+ 'side': (sideId === '1') ? 'buy' : 'sell',
342
+ 'takerOrMaker': undefined,
343
+ 'price': this.safeString(trade, 'contPrice'),
344
+ 'amount': this.safeString(trade, 'contQty'),
345
+ 'cost': this.safeString(trade, 'contAmt'),
346
+ 'fee': undefined,
347
+ }, market);
348
+ }
349
+ handleErrorMessage(client, message) {
350
+ //
351
+ // {
352
+ // "status" : "5100",
353
+ // "resmsg" : "Invalid Filter Syntax"
354
+ // }
355
+ //
356
+ if (!('status' in message)) {
357
+ return true;
358
+ }
359
+ const errorCode = this.safeString(message, 'status');
360
+ try {
361
+ if (errorCode !== '0000') {
362
+ const msg = this.safeString(message, 'resmsg');
363
+ throw new ExchangeError(this.id + ' ' + msg);
364
+ }
365
+ return true;
366
+ }
367
+ catch (e) {
368
+ client.reject(e);
369
+ }
370
+ return true;
371
+ }
372
+ handleMessage(client, message) {
373
+ if (!this.handleErrorMessage(client, message)) {
374
+ return;
375
+ }
376
+ const topic = this.safeString(message, 'type');
377
+ if (topic !== undefined) {
378
+ const methods = {
379
+ 'ticker': this.handleTicker,
380
+ 'orderbookdepth': this.handleOrderBook,
381
+ 'transaction': this.handleTrades,
382
+ };
383
+ const method = this.safeValue(methods, topic);
384
+ if (method !== undefined) {
385
+ method.call(this, client, message);
386
+ }
387
+ }
388
+ }
389
+ }
@@ -707,10 +707,10 @@ export default class bitmart extends bitmartRest {
707
707
  // }
708
708
  //
709
709
  const data = this.safeValue(message, 'data', []);
710
- const cache = this.positions;
711
710
  if (this.positions === undefined) {
712
711
  this.positions = new ArrayCacheBySymbolBySide();
713
712
  }
713
+ const cache = this.positions;
714
714
  const newPositions = [];
715
715
  for (let i = 0; i < data.length; i++) {
716
716
  const rawPosition = data[i];
@@ -202,7 +202,7 @@ export default class bybit extends bybitRest {
202
202
  /**
203
203
  * @method
204
204
  * @name bybit#watchTickers
205
- * @description n watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
205
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
206
206
  * @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
207
207
  * @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
208
208
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
package/js/src/pro/cex.js CHANGED
@@ -129,6 +129,7 @@ export default class cex extends cexRest {
129
129
  const url = this.urls['api']['ws'];
130
130
  const messageHash = 'trades';
131
131
  const subscriptionHash = 'old:' + symbol;
132
+ this.options['currentWatchTradeSymbol'] = symbol; // exchange supports only 1 symbol for this watchTrades channel
132
133
  const client = this.safeValue(this.clients, url);
133
134
  if (client !== undefined) {
134
135
  const subscriptionKeys = Object.keys(client.subscriptions);
@@ -170,11 +171,16 @@ export default class cex extends cexRest {
170
171
  const data = this.safeList(message, 'data', []);
171
172
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
172
173
  const stored = new ArrayCache(limit);
174
+ const symbol = this.safeString(this.options, 'currentWatchTradeSymbol');
175
+ if (symbol === undefined) {
176
+ return;
177
+ }
178
+ const market = this.market(symbol);
173
179
  const dataLength = data.length;
174
180
  for (let i = 0; i < dataLength; i++) {
175
181
  const index = dataLength - 1 - i;
176
182
  const rawTrade = data[index];
177
- const parsed = this.parseWsOldTrade(rawTrade);
183
+ const parsed = this.parseWsOldTrade(rawTrade, market);
178
184
  stored.append(parsed);
179
185
  }
180
186
  const messageHash = 'trades';
@@ -201,7 +207,7 @@ export default class cex extends cexRest {
201
207
  'id': id,
202
208
  'timestamp': timestamp,
203
209
  'datetime': this.iso8601(timestamp),
204
- 'symbol': undefined,
210
+ 'symbol': this.safeString(market, 'symbol'),
205
211
  'type': undefined,
206
212
  'side': side,
207
213
  'order': undefined,
@@ -223,8 +229,10 @@ export default class cex extends cexRest {
223
229
  //
224
230
  const data = this.safeValue(message, 'data', []);
225
231
  const stored = this.trades; // to do fix this, this.trades is not meant to be used like this
226
- for (let i = 0; i < data.length; i++) {
227
- const rawTrade = data[i];
232
+ const dataLength = data.length;
233
+ for (let i = 0; i < dataLength; i++) {
234
+ const index = dataLength - 1 - i;
235
+ const rawTrade = data[index];
228
236
  const parsed = this.parseWsOldTrade(rawTrade);
229
237
  stored.append(parsed);
230
238
  }
@@ -340,12 +348,17 @@ export default class cex extends cexRest {
340
348
  const data = this.safeValue(message, 'data', {});
341
349
  const ticker = this.parseWsTicker(data);
342
350
  const symbol = ticker['symbol'];
351
+ if (symbol === undefined) {
352
+ return;
353
+ }
343
354
  this.tickers[symbol] = ticker;
344
355
  let messageHash = 'ticker:' + symbol;
345
356
  client.resolve(ticker, messageHash);
346
357
  client.resolve(ticker, 'tickers');
347
358
  messageHash = this.safeString(message, 'oid');
348
- client.resolve(ticker, messageHash);
359
+ if (messageHash !== undefined) {
360
+ client.resolve(ticker, messageHash);
361
+ }
349
362
  }
350
363
  parseWsTicker(ticker, market = undefined) {
351
364
  //
package/js/src/pro/okx.js CHANGED
@@ -1324,7 +1324,8 @@ export default class okx extends okxRest {
1324
1324
  this.handleErrors(undefined, undefined, client.url, method, undefined, stringMsg, stringMsg, undefined, undefined);
1325
1325
  }
1326
1326
  const orders = this.parseOrders(args, undefined, undefined, undefined);
1327
- client.resolve(orders, messageHash);
1327
+ const first = this.safeDict(orders, 0, {});
1328
+ client.resolve(first, messageHash);
1328
1329
  }
1329
1330
  async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
1330
1331
  /**
@@ -20,4 +20,6 @@ export default class p2b extends p2bRest {
20
20
  id: number;
21
21
  };
22
22
  handlePong(client: Client, message: any): any;
23
+ onError(client: Client, error: any): void;
24
+ onClose(client: Client, error: any): void;
23
25
  }
package/js/src/pro/p2b.js CHANGED
@@ -53,6 +53,7 @@ export default class p2b extends p2bRest {
53
53
  'watchTickers': {
54
54
  'name': 'state', // or 'price'
55
55
  },
56
+ 'tickerSubs': this.createSafeDictionary(),
56
57
  },
57
58
  'streaming': {
58
59
  'ping': this.ping,
@@ -123,13 +124,14 @@ export default class p2b extends p2bRest {
123
124
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
124
125
  */
125
126
  await this.loadMarkets();
126
- const watchTickerOptions = this.safeValue(this.options, 'watchTicker');
127
+ const watchTickerOptions = this.safeDict(this.options, 'watchTicker');
127
128
  let name = this.safeString(watchTickerOptions, 'name', 'state'); // or price
128
129
  [name, params] = this.handleOptionAndParams(params, 'method', 'name', name);
129
130
  const market = this.market(symbol);
130
- const request = [
131
- market['id'],
132
- ];
131
+ symbol = market['symbol'];
132
+ this.options['tickerSubs'][market['id']] = true; // we need to re-subscribe to all tickers upon watching a new ticker
133
+ const tickerSubs = this.options['tickerSubs'];
134
+ const request = Object.keys(tickerSubs);
133
135
  const messageHash = name + '::' + market['symbol'];
134
136
  return await this.subscribe(name + '.subscribe', messageHash, request, params);
135
137
  }
@@ -432,4 +434,12 @@ export default class p2b extends p2bRest {
432
434
  client.lastPong = this.safeInteger(message, 'id');
433
435
  return message;
434
436
  }
437
+ onError(client, error) {
438
+ this.options['tickerSubs'] = this.createSafeDictionary();
439
+ this.onError(client, error);
440
+ }
441
+ onClose(client, error) {
442
+ this.options['tickerSubs'] = this.createSafeDictionary();
443
+ this.onClose(client, error);
444
+ }
435
445
  }
package/js/src/pro/woo.js CHANGED
@@ -232,7 +232,7 @@ export default class woo extends wooRest {
232
232
  /**
233
233
  * @method
234
234
  * @name woo#watchTickers
235
- * @description n watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
235
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
236
236
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
237
237
  * @param {object} [params] extra parameters specific to the exchange API endpoint
238
238
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -6,7 +6,7 @@ import type { Balances, Currency, Int, Market, Num, OHLCV, Order, OrderBook, Ord
6
6
  */
7
7
  export default class probit extends Exchange {
8
8
  describe(): any;
9
- fetchMarkets(params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
9
+ fetchMarkets(params?: {}): Promise<Market[]>;
10
10
  parseMarket(market: any): Market;
11
11
  fetchCurrencies(params?: {}): Promise<{}>;
12
12
  parseBalance(response: any): Balances;
@@ -15,7 +15,7 @@ export declare class BigInteger {
15
15
  protected intValue(): number;
16
16
  protected byteValue(): number;
17
17
  protected shortValue(): number;
18
- protected signum(): 1 | 0 | -1;
18
+ protected signum(): 0 | 1 | -1;
19
19
  toByteArray(): number[];
20
20
  protected equals(a: BigInteger): boolean;
21
21
  protected min(a: BigInteger): BigInteger;
package/js/src/timex.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { Balances, Currency, Int, Market, Num, OHLCV, Order, OrderBook, Ord
7
7
  export default class timex extends Exchange {
8
8
  describe(): any;
9
9
  fetchTime(params?: {}): Promise<number>;
10
- fetchMarkets(params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
10
+ fetchMarkets(params?: {}): Promise<Market[]>;
11
11
  fetchCurrencies(params?: {}): Promise<{}>;
12
12
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
13
13
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -8,7 +8,7 @@ export default class tokocrypto extends Exchange {
8
8
  describe(): any;
9
9
  nonce(): number;
10
10
  fetchTime(params?: {}): Promise<number>;
11
- fetchMarkets(params?: {}): Promise<any[]>;
11
+ fetchMarkets(params?: {}): Promise<Market[]>;
12
12
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
13
13
  parseTrade(trade: any, market?: Market): Trade;
14
14
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -7,7 +7,7 @@ import type { Int, Num, Order, OrderSide, OrderType, Str, Ticker, IndexType } fr
7
7
  */
8
8
  export default class tradeogre extends Exchange {
9
9
  describe(): any;
10
- fetchMarkets(params?: {}): Promise<any[]>;
10
+ fetchMarkets(params?: {}): Promise<Market[]>;
11
11
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
12
12
  parseTicker(ticker: any, market?: Market): Ticker;
13
13
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<import("./base/types.js").OrderBook>;
package/js/src/upbit.d.ts CHANGED
@@ -38,7 +38,7 @@ export default class upbit extends Exchange {
38
38
  }>;
39
39
  fetchMarket(symbol: string, params?: {}): Promise<import("./base/types.js").MarketInterface>;
40
40
  fetchMarketById(id: string, params?: {}): Promise<import("./base/types.js").MarketInterface>;
41
- fetchMarkets(params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
41
+ fetchMarkets(params?: {}): Promise<Market[]>;
42
42
  parseMarket(market: any): Market;
43
43
  parseBalance(response: any): Balances;
44
44
  fetchBalance(params?: {}): Promise<Balances>;
@@ -15,7 +15,7 @@ export default class wavesexchange extends Exchange {
15
15
  cost: number;
16
16
  }>;
17
17
  getQuotes(): Promise<any>;
18
- fetchMarkets(params?: {}): Promise<any[]>;
18
+ fetchMarkets(params?: {}): Promise<Market[]>;
19
19
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
20
20
  parseOrderBookSide(bookSide: any, market?: any, limit?: Int): any[];
21
21
  checkRequiredKeys(): void;
@@ -6,7 +6,7 @@ import type { Balances, Currency, Int, Market, Num, OHLCV, Order, OrderBook, Ord
6
6
  */
7
7
  export default class wazirx extends Exchange {
8
8
  describe(): any;
9
- fetchMarkets(params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
9
+ fetchMarkets(params?: {}): Promise<Market[]>;
10
10
  parseMarket(market: any): Market;
11
11
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
12
12
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
@@ -6,7 +6,7 @@ import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, Orde
6
6
  */
7
7
  export default class whitebit extends Exchange {
8
8
  describe(): any;
9
- fetchMarkets(params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
9
+ fetchMarkets(params?: {}): Promise<Market[]>;
10
10
  parseMarket(market: any): Market;
11
11
  fetchCurrencies(params?: {}): Promise<{}>;
12
12
  fetchTransactionFees(codes?: string[], params?: {}): Promise<{
package/js/src/woo.d.ts CHANGED
@@ -14,7 +14,7 @@ export default class woo extends Exchange {
14
14
  info: any;
15
15
  }>;
16
16
  fetchTime(params?: {}): Promise<number>;
17
- fetchMarkets(params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
17
+ fetchMarkets(params?: {}): Promise<Market[]>;
18
18
  parseMarket(market: any): Market;
19
19
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
20
20
  parseTrade(trade: any, market?: Market): Trade;