ccxt 4.4.8 → 4.4.9
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.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bigone.js +35 -86
- package/dist/cjs/src/bingx.js +7 -2
- package/dist/cjs/src/bitget.js +3 -0
- package/dist/cjs/src/bybit.js +5 -1
- package/dist/cjs/src/gate.js +35 -1
- package/dist/cjs/src/htx.js +2 -0
- package/dist/cjs/src/kucoin.js +2 -1
- package/dist/cjs/src/kucoinfutures.js +162 -2
- package/dist/cjs/src/pro/binance.js +4 -4
- package/dist/cjs/src/pro/hitbtc.js +122 -48
- package/dist/cjs/src/pro/hollaex.js +5 -0
- package/dist/cjs/src/pro/okx.js +19 -3
- package/dist/cjs/src/pro/p2b.js +35 -1
- package/dist/cjs/src/pro/whitebit.js +31 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bigone.d.ts +1 -1
- package/js/src/abstract/kucoinfutures.d.ts +5 -0
- package/js/src/bigone.js +35 -86
- package/js/src/bingx.js +7 -2
- package/js/src/bitget.js +3 -0
- package/js/src/bybit.js +5 -1
- package/js/src/gate.js +35 -1
- package/js/src/htx.js +2 -0
- package/js/src/kucoin.js +2 -1
- package/js/src/kucoinfutures.d.ts +7 -1
- package/js/src/kucoinfutures.js +162 -2
- package/js/src/pro/binance.js +4 -4
- package/js/src/pro/hitbtc.d.ts +4 -1
- package/js/src/pro/hitbtc.js +122 -48
- package/js/src/pro/hollaex.js +5 -0
- package/js/src/pro/okx.js +19 -3
- package/js/src/pro/p2b.d.ts +2 -1
- package/js/src/pro/p2b.js +35 -1
- package/js/src/pro/whitebit.d.ts +2 -1
- package/js/src/pro/whitebit.js +31 -0
- package/package.json +1 -1
package/js/src/pro/hitbtc.js
CHANGED
|
@@ -17,6 +17,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
17
17
|
'ws': true,
|
|
18
18
|
'watchTicker': true,
|
|
19
19
|
'watchTickers': true,
|
|
20
|
+
'watchBidsAsks': true,
|
|
20
21
|
'watchTrades': true,
|
|
21
22
|
'watchTradesForSymbols': false,
|
|
22
23
|
'watchOrderBook': true,
|
|
@@ -51,8 +52,11 @@ export default class hitbtc extends hitbtcRest {
|
|
|
51
52
|
'watchTickers': {
|
|
52
53
|
'method': 'ticker/{speed}', // 'ticker/{speed}','ticker/price/{speed}', 'ticker/{speed}/batch', or 'ticker/{speed}/price/batch''
|
|
53
54
|
},
|
|
55
|
+
'watchBidsAsks': {
|
|
56
|
+
'method': 'orderbook/top/{speed}', // 'orderbook/top/{speed}', 'orderbook/top/{speed}/batch'
|
|
57
|
+
},
|
|
54
58
|
'watchOrderBook': {
|
|
55
|
-
'method': 'orderbook/full', // 'orderbook/full', 'orderbook/{depth}/{speed}', 'orderbook/{depth}/{speed}/batch'
|
|
59
|
+
'method': 'orderbook/full', // 'orderbook/full', 'orderbook/{depth}/{speed}', 'orderbook/{depth}/{speed}/batch'
|
|
56
60
|
},
|
|
57
61
|
},
|
|
58
62
|
'timeframes': {
|
|
@@ -128,10 +132,17 @@ export default class hitbtc extends hitbtcRest {
|
|
|
128
132
|
* @param {object} [params] extra parameters specific to the hitbtc api
|
|
129
133
|
*/
|
|
130
134
|
await this.loadMarkets();
|
|
135
|
+
symbols = this.marketSymbols(symbols);
|
|
136
|
+
const isBatch = name.indexOf('batch') >= 0;
|
|
131
137
|
const url = this.urls['api']['ws']['public'];
|
|
132
|
-
|
|
133
|
-
if (symbols !== undefined) {
|
|
134
|
-
|
|
138
|
+
const messageHashes = [];
|
|
139
|
+
if (symbols !== undefined && !isBatch) {
|
|
140
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
141
|
+
messageHashes.push(messageHashPrefix + '::' + symbols[i]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
messageHashes.push(messageHashPrefix);
|
|
135
146
|
}
|
|
136
147
|
const subscribe = {
|
|
137
148
|
'method': 'subscribe',
|
|
@@ -139,7 +150,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
139
150
|
'ch': name,
|
|
140
151
|
};
|
|
141
152
|
const request = this.extend(subscribe, params);
|
|
142
|
-
return await this.
|
|
153
|
+
return await this.watchMultiple(url, messageHashes, request, messageHashes);
|
|
143
154
|
}
|
|
144
155
|
async subscribePrivate(name, symbol = undefined, params = {}) {
|
|
145
156
|
/**
|
|
@@ -196,7 +207,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
196
207
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
197
208
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
198
209
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
199
|
-
* @param {string} [params.method] 'orderbook/full', 'orderbook/{depth}/{speed}', 'orderbook/{depth}/{speed}/batch'
|
|
210
|
+
* @param {string} [params.method] 'orderbook/full', 'orderbook/{depth}/{speed}', 'orderbook/{depth}/{speed}/batch'
|
|
200
211
|
* @param {int} [params.depth] 5 , 10, or 20 (default)
|
|
201
212
|
* @param {int} [params.speed] 100 (default), 500, or 1000
|
|
202
213
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
@@ -212,12 +223,6 @@ export default class hitbtc extends hitbtcRest {
|
|
|
212
223
|
else if (name === 'orderbook/{depth}/{speed}/batch') {
|
|
213
224
|
name = 'orderbook/D' + depth + '/' + speed + 'ms/batch';
|
|
214
225
|
}
|
|
215
|
-
else if (name === 'orderbook/top/{speed}') {
|
|
216
|
-
name = 'orderbook/top/' + speed + 'ms';
|
|
217
|
-
}
|
|
218
|
-
else if (name === 'orderbook/top/{speed}/batch') {
|
|
219
|
-
name = 'orderbook/top/' + speed + 'ms/batch';
|
|
220
|
-
}
|
|
221
226
|
const market = this.market(symbol);
|
|
222
227
|
const request = {
|
|
223
228
|
'params': {
|
|
@@ -313,20 +318,8 @@ export default class hitbtc extends hitbtcRest {
|
|
|
313
318
|
* @param {string} [params.speed] '1s' (default), or '3s'
|
|
314
319
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
315
320
|
*/
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const method = this.safeString2(params, 'method', 'defaultMethod', defaultMethod);
|
|
319
|
-
const speed = this.safeString(params, 'speed', '1s');
|
|
320
|
-
const name = this.implodeParams(method, { 'speed': speed });
|
|
321
|
-
params = this.omit(params, ['method', 'speed']);
|
|
322
|
-
const market = this.market(symbol);
|
|
323
|
-
const request = {
|
|
324
|
-
'params': {
|
|
325
|
-
'symbols': [market['id']],
|
|
326
|
-
},
|
|
327
|
-
};
|
|
328
|
-
const result = await this.subscribePublic(name, 'tickers', [symbol], this.deepExtend(request, params));
|
|
329
|
-
return this.safeValue(result, symbol);
|
|
321
|
+
const ticker = await this.watchTickers([symbol], params);
|
|
322
|
+
return this.safeValue(ticker, symbol);
|
|
330
323
|
}
|
|
331
324
|
async watchTickers(symbols = undefined, params = {}) {
|
|
332
325
|
/**
|
|
@@ -335,13 +328,14 @@ export default class hitbtc extends hitbtcRest {
|
|
|
335
328
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
336
329
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
337
330
|
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
338
|
-
* @param {string} params.method 'ticker/{speed}'
|
|
331
|
+
* @param {string} params.method 'ticker/{speed}' ,'ticker/price/{speed}', 'ticker/{speed}/batch' (default), or 'ticker/{speed}/price/batch''
|
|
339
332
|
* @param {string} params.speed '1s' (default), or '3s'
|
|
340
333
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
|
|
341
334
|
*/
|
|
342
335
|
await this.loadMarkets();
|
|
336
|
+
symbols = this.marketSymbols(symbols);
|
|
343
337
|
const options = this.safeValue(this.options, 'watchTicker');
|
|
344
|
-
const defaultMethod = this.safeString(options, 'method', 'ticker/{speed}');
|
|
338
|
+
const defaultMethod = this.safeString(options, 'method', 'ticker/{speed}/batch');
|
|
345
339
|
const method = this.safeString2(params, 'method', 'defaultMethod', defaultMethod);
|
|
346
340
|
const speed = this.safeString(params, 'speed', '1s');
|
|
347
341
|
const name = this.implodeParams(method, { 'speed': speed });
|
|
@@ -361,11 +355,15 @@ export default class hitbtc extends hitbtcRest {
|
|
|
361
355
|
'symbols': marketIds,
|
|
362
356
|
},
|
|
363
357
|
};
|
|
364
|
-
const
|
|
358
|
+
const newTickers = await this.subscribePublic(name, 'tickers', symbols, this.deepExtend(request, params));
|
|
365
359
|
if (this.newUpdates) {
|
|
366
|
-
|
|
360
|
+
if (!Array.isArray(newTickers)) {
|
|
361
|
+
const tickers = {};
|
|
362
|
+
tickers[newTickers['symbol']] = newTickers;
|
|
363
|
+
return tickers;
|
|
364
|
+
}
|
|
367
365
|
}
|
|
368
|
-
return this.filterByArray(
|
|
366
|
+
return this.filterByArray(newTickers, 'symbol', symbols);
|
|
369
367
|
}
|
|
370
368
|
handleTicker(client, message) {
|
|
371
369
|
//
|
|
@@ -408,30 +406,19 @@ export default class hitbtc extends hitbtcRest {
|
|
|
408
406
|
//
|
|
409
407
|
const data = this.safeValue(message, 'data', {});
|
|
410
408
|
const marketIds = Object.keys(data);
|
|
411
|
-
const
|
|
409
|
+
const result = [];
|
|
410
|
+
const topic = 'tickers';
|
|
412
411
|
for (let i = 0; i < marketIds.length; i++) {
|
|
413
412
|
const marketId = marketIds[i];
|
|
414
413
|
const market = this.safeMarket(marketId);
|
|
415
414
|
const symbol = market['symbol'];
|
|
416
415
|
const ticker = this.parseWsTicker(data[marketId], market);
|
|
417
416
|
this.tickers[symbol] = ticker;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const messageHashes = this.findMessageHashes(client, 'tickers::');
|
|
422
|
-
for (let i = 0; i < messageHashes.length; i++) {
|
|
423
|
-
const messageHash = messageHashes[i];
|
|
424
|
-
const parts = messageHash.split('::');
|
|
425
|
-
const symbolsString = parts[1];
|
|
426
|
-
const symbols = symbolsString.split(',');
|
|
427
|
-
const tickers = this.filterByArray(newTickers, 'symbol', symbols);
|
|
428
|
-
const tickersSymbols = Object.keys(tickers);
|
|
429
|
-
const numTickers = tickersSymbols.length;
|
|
430
|
-
if (numTickers > 0) {
|
|
431
|
-
client.resolve(tickers, messageHash);
|
|
432
|
-
}
|
|
417
|
+
result.push(ticker);
|
|
418
|
+
const messageHash = topic + '::' + symbol;
|
|
419
|
+
client.resolve(ticker, messageHash);
|
|
433
420
|
}
|
|
434
|
-
|
|
421
|
+
client.resolve(result, topic);
|
|
435
422
|
}
|
|
436
423
|
parseWsTicker(ticker, market = undefined) {
|
|
437
424
|
//
|
|
@@ -488,6 +475,86 @@ export default class hitbtc extends hitbtcRest {
|
|
|
488
475
|
'info': ticker,
|
|
489
476
|
}, market);
|
|
490
477
|
}
|
|
478
|
+
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
479
|
+
/**
|
|
480
|
+
* @method
|
|
481
|
+
* @name hitbtc#watchBidsAsks
|
|
482
|
+
* @description watches best bid & ask for symbols
|
|
483
|
+
* @see https://api.hitbtc.com/#subscribe-to-top-of-book
|
|
484
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
485
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
486
|
+
* @param {string} [params.method] 'orderbook/top/{speed}' or 'orderbook/top/{speed}/batch (default)'
|
|
487
|
+
* @param {string} [params.speed] '100ms' (default) or '500ms' or '1000ms'
|
|
488
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
489
|
+
*/
|
|
490
|
+
await this.loadMarkets();
|
|
491
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
492
|
+
const options = this.safeValue(this.options, 'watchBidsAsks');
|
|
493
|
+
const defaultMethod = this.safeString(options, 'method', 'orderbook/top/{speed}/batch');
|
|
494
|
+
const method = this.safeString2(params, 'method', 'defaultMethod', defaultMethod);
|
|
495
|
+
const speed = this.safeString(params, 'speed', '100ms');
|
|
496
|
+
const name = this.implodeParams(method, { 'speed': speed });
|
|
497
|
+
params = this.omit(params, ['method', 'speed']);
|
|
498
|
+
const marketIds = this.marketIds(symbols);
|
|
499
|
+
const request = {
|
|
500
|
+
'params': {
|
|
501
|
+
'symbols': marketIds,
|
|
502
|
+
},
|
|
503
|
+
};
|
|
504
|
+
const newTickers = await this.subscribePublic(name, 'bidask', symbols, this.deepExtend(request, params));
|
|
505
|
+
if (this.newUpdates) {
|
|
506
|
+
if (!Array.isArray(newTickers)) {
|
|
507
|
+
const tickers = {};
|
|
508
|
+
tickers[newTickers['symbol']] = newTickers;
|
|
509
|
+
return tickers;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return this.filterByArray(newTickers, 'symbol', symbols);
|
|
513
|
+
}
|
|
514
|
+
handleBidAsk(client, message) {
|
|
515
|
+
//
|
|
516
|
+
// {
|
|
517
|
+
// "ch": "orderbook/top/100ms", // or 'orderbook/top/100ms/batch'
|
|
518
|
+
// "data": {
|
|
519
|
+
// "BTCUSDT": {
|
|
520
|
+
// "t": 1727276919771,
|
|
521
|
+
// "a": "63931.45",
|
|
522
|
+
// "A": "0.02879",
|
|
523
|
+
// "b": "63926.97",
|
|
524
|
+
// "B": "0.00100"
|
|
525
|
+
// }
|
|
526
|
+
// }
|
|
527
|
+
// }
|
|
528
|
+
//
|
|
529
|
+
const data = this.safeDict(message, 'data', {});
|
|
530
|
+
const marketIds = Object.keys(data);
|
|
531
|
+
const result = [];
|
|
532
|
+
const topic = 'bidask';
|
|
533
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
534
|
+
const marketId = marketIds[i];
|
|
535
|
+
const market = this.safeMarket(marketId);
|
|
536
|
+
const symbol = market['symbol'];
|
|
537
|
+
const ticker = this.parseWsBidAsk(data[marketId], market);
|
|
538
|
+
this.bidsasks[symbol] = ticker;
|
|
539
|
+
result.push(ticker);
|
|
540
|
+
const messageHash = topic + '::' + symbol;
|
|
541
|
+
client.resolve(ticker, messageHash);
|
|
542
|
+
}
|
|
543
|
+
client.resolve(result, topic);
|
|
544
|
+
}
|
|
545
|
+
parseWsBidAsk(ticker, market = undefined) {
|
|
546
|
+
const timestamp = this.safeInteger(ticker, 't');
|
|
547
|
+
return this.safeTicker({
|
|
548
|
+
'symbol': market['symbol'],
|
|
549
|
+
'timestamp': timestamp,
|
|
550
|
+
'datetime': this.iso8601(timestamp),
|
|
551
|
+
'ask': this.safeString(ticker, 'a'),
|
|
552
|
+
'askVolume': this.safeString(ticker, 'A'),
|
|
553
|
+
'bid': this.safeString(ticker, 'b'),
|
|
554
|
+
'bidVolume': this.safeString(ticker, 'B'),
|
|
555
|
+
'info': ticker,
|
|
556
|
+
}, market);
|
|
557
|
+
}
|
|
491
558
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
492
559
|
/**
|
|
493
560
|
* @method
|
|
@@ -1223,11 +1290,18 @@ export default class hitbtc extends hitbtcRest {
|
|
|
1223
1290
|
if (channel !== undefined) {
|
|
1224
1291
|
const splitChannel = channel.split('/');
|
|
1225
1292
|
channel = this.safeString(splitChannel, 0);
|
|
1293
|
+
if (channel === 'orderbook') {
|
|
1294
|
+
const channel2 = this.safeString(splitChannel, 1);
|
|
1295
|
+
if (channel2 !== undefined && channel2 === 'top') {
|
|
1296
|
+
channel = 'orderbook/top';
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1226
1299
|
const methods = {
|
|
1227
1300
|
'candles': this.handleOHLCV,
|
|
1228
1301
|
'ticker': this.handleTicker,
|
|
1229
1302
|
'trades': this.handleTrades,
|
|
1230
1303
|
'orderbook': this.handleOrderBook,
|
|
1304
|
+
'orderbook/top': this.handleBidAsk,
|
|
1231
1305
|
'spot_order': this.handleOrder,
|
|
1232
1306
|
'spot_orders': this.handleOrder,
|
|
1233
1307
|
'margin_order': this.handleOrder,
|
package/js/src/pro/hollaex.js
CHANGED
|
@@ -59,6 +59,7 @@ export default class hollaex extends hollaexRest {
|
|
|
59
59
|
* @method
|
|
60
60
|
* @name hollaex#watchOrderBook
|
|
61
61
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
62
|
+
* @see https://apidocs.hollaex.com/#sending-receiving-messages
|
|
62
63
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
63
64
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
64
65
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -117,6 +118,7 @@ export default class hollaex extends hollaexRest {
|
|
|
117
118
|
* @method
|
|
118
119
|
* @name hollaex#watchTrades
|
|
119
120
|
* @description get the list of most recent trades for a particular symbol
|
|
121
|
+
* @see https://apidocs.hollaex.com/#sending-receiving-messages
|
|
120
122
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
121
123
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
122
124
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -173,6 +175,7 @@ export default class hollaex extends hollaexRest {
|
|
|
173
175
|
* @method
|
|
174
176
|
* @name hollaex#watchMyTrades
|
|
175
177
|
* @description watches information on multiple trades made by the user
|
|
178
|
+
* @see https://apidocs.hollaex.com/#sending-receiving-messages
|
|
176
179
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
177
180
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
178
181
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
@@ -253,6 +256,7 @@ export default class hollaex extends hollaexRest {
|
|
|
253
256
|
* @method
|
|
254
257
|
* @name hollaex#watchOrders
|
|
255
258
|
* @description watches information on multiple orders made by the user
|
|
259
|
+
* @see https://apidocs.hollaex.com/#sending-receiving-messages
|
|
256
260
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
257
261
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
258
262
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -374,6 +378,7 @@ export default class hollaex extends hollaexRest {
|
|
|
374
378
|
* @method
|
|
375
379
|
* @name hollaex#watchBalance
|
|
376
380
|
* @description watch balance and get the amount of funds available for trading or funds locked in orders
|
|
381
|
+
* @see https://apidocs.hollaex.com/#sending-receiving-messages
|
|
377
382
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
378
383
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
379
384
|
*/
|
package/js/src/pro/okx.js
CHANGED
|
@@ -2214,15 +2214,31 @@ export default class okx extends okxRest {
|
|
|
2214
2214
|
// { event: 'error', msg: "Illegal request: {"op":"subscribe","args":["spot/ticker:BTC-USDT"]}", code: "60012" }
|
|
2215
2215
|
// { event: 'error", msg: "channel:ticker,instId:BTC-USDT doesn"t exist", code: "60018" }
|
|
2216
2216
|
//
|
|
2217
|
-
|
|
2217
|
+
let errorCode = this.safeString(message, 'code');
|
|
2218
2218
|
try {
|
|
2219
2219
|
if (errorCode && errorCode !== '0') {
|
|
2220
2220
|
const feedback = this.id + ' ' + this.json(message);
|
|
2221
|
-
|
|
2222
|
-
|
|
2221
|
+
if (errorCode !== '1') {
|
|
2222
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
2223
|
+
}
|
|
2224
|
+
let messageString = this.safeValue(message, 'msg');
|
|
2223
2225
|
if (messageString !== undefined) {
|
|
2224
2226
|
this.throwBroadlyMatchedException(this.exceptions['broad'], messageString, feedback);
|
|
2225
2227
|
}
|
|
2228
|
+
else {
|
|
2229
|
+
const data = this.safeList(message, 'data', []);
|
|
2230
|
+
for (let i = 0; i < data.length; i++) {
|
|
2231
|
+
const d = data[i];
|
|
2232
|
+
errorCode = this.safeString(d, 'sCode');
|
|
2233
|
+
if (errorCode !== undefined) {
|
|
2234
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
2235
|
+
}
|
|
2236
|
+
messageString = this.safeValue(message, 'sMsg');
|
|
2237
|
+
if (messageString !== undefined) {
|
|
2238
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], messageString, feedback);
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2226
2242
|
throw new ExchangeError(feedback);
|
|
2227
2243
|
}
|
|
2228
2244
|
}
|
package/js/src/pro/p2b.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import p2bRest from '../p2b.js';
|
|
2
|
-
import type { Int, OHLCV, OrderBook, Trade, Ticker } from '../base/types.js';
|
|
2
|
+
import type { Int, OHLCV, OrderBook, Trade, Ticker, Strings, Tickers } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class p2b extends p2bRest {
|
|
5
5
|
describe(): any;
|
|
6
6
|
subscribe(name: string, messageHash: string, request: any, params?: {}): Promise<any>;
|
|
7
7
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
8
8
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
9
|
+
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
9
10
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
10
11
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
11
12
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
package/js/src/pro/p2b.js
CHANGED
|
@@ -30,7 +30,7 @@ export default class p2b extends p2bRest {
|
|
|
30
30
|
'watchOrders': false,
|
|
31
31
|
// 'watchStatus': true,
|
|
32
32
|
'watchTicker': true,
|
|
33
|
-
'watchTickers':
|
|
33
|
+
'watchTickers': true,
|
|
34
34
|
'watchTrades': true,
|
|
35
35
|
'watchTradesForSymbols': true,
|
|
36
36
|
},
|
|
@@ -136,6 +136,39 @@ export default class p2b extends p2bRest {
|
|
|
136
136
|
const messageHash = name + '::' + market['symbol'];
|
|
137
137
|
return await this.subscribe(name + '.subscribe', messageHash, request, params);
|
|
138
138
|
}
|
|
139
|
+
async watchTickers(symbols = undefined, params = {}) {
|
|
140
|
+
/**
|
|
141
|
+
* @method
|
|
142
|
+
* @name p2b#watchTickers
|
|
143
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#last-price
|
|
144
|
+
* @see https://github.com/P2B-team/P2B-WSS-Public/blob/main/wss_documentation.md#market-status
|
|
145
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
146
|
+
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
147
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
148
|
+
* @param {object} [params.method] 'state' (default) or 'price'
|
|
149
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
150
|
+
*/
|
|
151
|
+
await this.loadMarkets();
|
|
152
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
153
|
+
const watchTickerOptions = this.safeDict(this.options, 'watchTicker');
|
|
154
|
+
let name = this.safeString(watchTickerOptions, 'name', 'state'); // or price
|
|
155
|
+
[name, params] = this.handleOptionAndParams(params, 'method', 'name', name);
|
|
156
|
+
const messageHashes = [];
|
|
157
|
+
const args = [];
|
|
158
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
159
|
+
const market = this.market(symbols[i]);
|
|
160
|
+
messageHashes.push(name + '::' + market['symbol']);
|
|
161
|
+
args.push(market['id']);
|
|
162
|
+
}
|
|
163
|
+
const url = this.urls['api']['ws'];
|
|
164
|
+
const request = {
|
|
165
|
+
'method': name + '.subscribe',
|
|
166
|
+
'params': args,
|
|
167
|
+
'id': this.milliseconds(),
|
|
168
|
+
};
|
|
169
|
+
await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
|
|
170
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
171
|
+
}
|
|
139
172
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
140
173
|
/**
|
|
141
174
|
* @method
|
|
@@ -351,6 +384,7 @@ export default class p2b extends p2bRest {
|
|
|
351
384
|
ticker = this.parseTicker(tickerData, market);
|
|
352
385
|
}
|
|
353
386
|
const symbol = ticker['symbol'];
|
|
387
|
+
this.tickers[symbol] = ticker;
|
|
354
388
|
const messageHash = messageHashStart + '::' + symbol;
|
|
355
389
|
client.resolve(ticker, messageHash);
|
|
356
390
|
return message;
|
package/js/src/pro/whitebit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import whitebitRest from '../whitebit.js';
|
|
2
|
-
import type { Int, Str, OrderBook, Order, Trade, Ticker, OHLCV, Balances } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, OrderBook, Order, Trade, Ticker, OHLCV, Balances, Strings, Tickers } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class whitebit extends whitebitRest {
|
|
5
5
|
describe(): any;
|
|
@@ -10,6 +10,7 @@ export default class whitebit extends whitebitRest {
|
|
|
10
10
|
handleDelta(bookside: any, delta: any): void;
|
|
11
11
|
handleDeltas(bookside: any, deltas: any): void;
|
|
12
12
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
13
|
+
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
14
|
handleTicker(client: Client, message: any): any;
|
|
14
15
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
15
16
|
handleTrades(client: Client, message: any): void;
|
package/js/src/pro/whitebit.js
CHANGED
|
@@ -21,6 +21,7 @@ export default class whitebit extends whitebitRest {
|
|
|
21
21
|
'watchOrderBook': true,
|
|
22
22
|
'watchOrders': true,
|
|
23
23
|
'watchTicker': true,
|
|
24
|
+
'watchTickers': true,
|
|
24
25
|
'watchTrades': true,
|
|
25
26
|
'watchTradesForSymbols': false,
|
|
26
27
|
},
|
|
@@ -259,6 +260,36 @@ export default class whitebit extends whitebitRest {
|
|
|
259
260
|
// every time we want to subscribe to another market we have to "re-subscribe" sending it all again
|
|
260
261
|
return await this.watchMultipleSubscription(messageHash, method, symbol, false, params);
|
|
261
262
|
}
|
|
263
|
+
async watchTickers(symbols = undefined, params = {}) {
|
|
264
|
+
/**
|
|
265
|
+
* @method
|
|
266
|
+
* @name whitebit#watchTickers
|
|
267
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
268
|
+
* @see https://docs.whitebit.com/public/websocket/#market-statistics
|
|
269
|
+
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
270
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
271
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
272
|
+
*/
|
|
273
|
+
await this.loadMarkets();
|
|
274
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
275
|
+
const method = 'market_subscribe';
|
|
276
|
+
const url = this.urls['api']['ws'];
|
|
277
|
+
const id = this.nonce();
|
|
278
|
+
const messageHashes = [];
|
|
279
|
+
const args = [];
|
|
280
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
281
|
+
const market = this.market(symbols[i]);
|
|
282
|
+
messageHashes.push('ticker:' + market['symbol']);
|
|
283
|
+
args.push(market['id']);
|
|
284
|
+
}
|
|
285
|
+
const request = {
|
|
286
|
+
'id': id,
|
|
287
|
+
'method': method,
|
|
288
|
+
'params': args,
|
|
289
|
+
};
|
|
290
|
+
await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
|
|
291
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
292
|
+
}
|
|
262
293
|
handleTicker(client, message) {
|
|
263
294
|
//
|
|
264
295
|
// {
|
package/package.json
CHANGED