ccxt 4.3.88 → 4.3.90
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 +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +1 -0
- package/dist/cjs/src/alpaca.js +3 -2
- package/dist/cjs/src/ascendex.js +102 -116
- package/dist/cjs/src/bigone.js +1 -0
- package/dist/cjs/src/bingx.js +32 -17
- package/dist/cjs/src/bit2c.js +1 -0
- package/dist/cjs/src/bitbank.js +1 -0
- package/dist/cjs/src/bitfinex.js +1 -0
- package/dist/cjs/src/bitfinex2.js +21 -22
- package/dist/cjs/src/bitflyer.js +1 -0
- package/dist/cjs/src/bitget.js +3 -2
- package/dist/cjs/src/bitmart.js +6 -9
- package/dist/cjs/src/bitmex.js +1 -0
- package/dist/cjs/src/bitopro.js +1 -0
- package/dist/cjs/src/bitrue.js +62 -71
- package/dist/cjs/src/bitso.js +1 -0
- package/dist/cjs/src/bitstamp.js +1 -0
- package/dist/cjs/src/bitvavo.js +1 -0
- package/dist/cjs/src/blockchaincom.js +1 -0
- package/dist/cjs/src/btcalpha.js +1 -0
- package/dist/cjs/src/btcbox.js +1 -0
- package/dist/cjs/src/btcmarkets.js +1 -0
- package/dist/cjs/src/bybit.js +2 -0
- package/dist/cjs/src/cex.js +1 -0
- package/dist/cjs/src/coinbaseexchange.js +1 -0
- package/dist/cjs/src/coinbaseinternational.js +2 -1
- package/dist/cjs/src/coinex.js +1 -17
- package/dist/cjs/src/cryptocom.js +0 -12
- package/dist/cjs/src/hitbtc.js +1 -0
- package/dist/cjs/src/htx.js +49 -49
- package/dist/cjs/src/huobijp.js +0 -9
- package/dist/cjs/src/kraken.js +48 -48
- package/dist/cjs/src/latoken.js +1 -0
- package/dist/cjs/src/mexc.js +1 -61
- package/dist/cjs/src/okcoin.js +4 -9
- package/dist/cjs/src/okx.js +1 -8
- package/dist/cjs/src/onetrading.js +1 -0
- package/dist/cjs/src/phemex.js +1 -0
- package/dist/cjs/src/poloniexfutures.js +1 -0
- package/dist/cjs/src/pro/binance.js +323 -0
- package/dist/cjs/src/pro/bingx.js +263 -91
- package/dist/cjs/src/pro/bithumb.js +5 -1
- package/dist/cjs/src/pro/bitvavo.js +1 -0
- package/dist/cjs/src/pro/bybit.js +291 -2
- package/dist/cjs/src/pro/cex.js +1 -0
- package/dist/cjs/src/pro/coinex.js +994 -679
- package/dist/cjs/src/pro/lbank.js +2 -3
- package/dist/cjs/src/pro/okx.js +159 -3
- package/dist/cjs/src/probit.js +1 -0
- package/dist/cjs/src/vertex.js +1 -0
- package/dist/cjs/src/whitebit.js +5 -3
- package/dist/cjs/src/woo.js +1 -0
- package/dist/cjs/src/woofipro.js +1 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/ace.js +1 -0
- package/js/src/alpaca.js +3 -2
- package/js/src/ascendex.d.ts +0 -1
- package/js/src/ascendex.js +102 -116
- package/js/src/bigone.js +1 -0
- package/js/src/bingx.js +32 -17
- package/js/src/bit2c.js +1 -0
- package/js/src/bitbank.js +1 -0
- package/js/src/bitfinex.js +1 -0
- package/js/src/bitfinex2.d.ts +0 -1
- package/js/src/bitfinex2.js +21 -22
- package/js/src/bitflyer.js +1 -0
- package/js/src/bitget.js +3 -2
- package/js/src/bitmart.d.ts +0 -1
- package/js/src/bitmart.js +6 -9
- package/js/src/bitmex.js +1 -0
- package/js/src/bitopro.js +1 -0
- package/js/src/bitrue.d.ts +0 -1
- package/js/src/bitrue.js +62 -71
- package/js/src/bitso.js +1 -0
- package/js/src/bitstamp.js +1 -0
- package/js/src/bitvavo.js +1 -0
- package/js/src/blockchaincom.js +1 -0
- package/js/src/btcalpha.js +1 -0
- package/js/src/btcbox.js +1 -0
- package/js/src/btcmarkets.js +1 -0
- package/js/src/bybit.js +2 -0
- package/js/src/cex.js +1 -0
- package/js/src/coinbaseexchange.js +1 -0
- package/js/src/coinbaseinternational.js +2 -1
- package/js/src/coinex.d.ts +0 -2
- package/js/src/coinex.js +1 -17
- package/js/src/cryptocom.d.ts +0 -1
- package/js/src/cryptocom.js +0 -12
- package/js/src/hitbtc.js +1 -0
- package/js/src/htx.js +49 -49
- package/js/src/huobijp.d.ts +0 -1
- package/js/src/huobijp.js +0 -9
- package/js/src/kraken.js +48 -48
- package/js/src/latoken.js +1 -0
- package/js/src/mexc.js +1 -61
- package/js/src/okcoin.d.ts +0 -1
- package/js/src/okcoin.js +4 -9
- package/js/src/okx.d.ts +0 -1
- package/js/src/okx.js +1 -8
- package/js/src/onetrading.js +1 -0
- package/js/src/phemex.js +1 -0
- package/js/src/poloniexfutures.js +1 -0
- package/js/src/pro/binance.d.ts +9 -1
- package/js/src/pro/binance.js +327 -1
- package/js/src/pro/bingx.d.ts +2 -2
- package/js/src/pro/bingx.js +263 -91
- package/js/src/pro/bithumb.js +5 -1
- package/js/src/pro/bitvavo.js +1 -0
- package/js/src/pro/bybit.d.ts +12 -1
- package/js/src/pro/bybit.js +292 -3
- package/js/src/pro/cex.js +1 -0
- package/js/src/pro/coinex.d.ts +12 -6
- package/js/src/pro/coinex.js +996 -681
- package/js/src/pro/lbank.js +2 -3
- package/js/src/pro/okx.d.ts +7 -0
- package/js/src/pro/okx.js +162 -4
- package/js/src/probit.js +1 -0
- package/js/src/vertex.js +1 -0
- package/js/src/whitebit.js +5 -3
- package/js/src/woo.js +1 -0
- package/js/src/woofipro.js +1 -0
- package/package.json +1 -1
package/js/src/pro/bithumb.js
CHANGED
|
@@ -36,6 +36,7 @@ export default class bithumb extends bithumbRest {
|
|
|
36
36
|
* @method
|
|
37
37
|
* @name bithumb#watchTicker
|
|
38
38
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
39
|
+
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
|
|
39
40
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
40
41
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
41
42
|
* @param {string} [params.channel] the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
|
|
@@ -55,8 +56,9 @@ export default class bithumb extends bithumbRest {
|
|
|
55
56
|
async watchTickers(symbols = undefined, params = {}) {
|
|
56
57
|
/**
|
|
57
58
|
* @method
|
|
58
|
-
* @name
|
|
59
|
+
* @name bithumb#watchTickers
|
|
59
60
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
61
|
+
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
|
|
60
62
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
61
63
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
62
64
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -170,6 +172,7 @@ export default class bithumb extends bithumbRest {
|
|
|
170
172
|
/**
|
|
171
173
|
* @method
|
|
172
174
|
* @name bithumb#watchOrderBook
|
|
175
|
+
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
|
|
173
176
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
174
177
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
175
178
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
@@ -257,6 +260,7 @@ export default class bithumb extends bithumbRest {
|
|
|
257
260
|
* @method
|
|
258
261
|
* @name bithumb#watchTrades
|
|
259
262
|
* @description get the list of most recent trades for a particular symbol
|
|
263
|
+
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
|
|
260
264
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
261
265
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
262
266
|
* @param {int} [limit] the maximum amount of trades to fetch
|
package/js/src/pro/bitvavo.js
CHANGED
|
@@ -642,6 +642,7 @@ export default class bitvavo extends bitvavoRest {
|
|
|
642
642
|
* @name bitvavo#fetchOrderWs
|
|
643
643
|
* @see https://docs.bitvavo.com/#tag/General/paths/~1assets/get
|
|
644
644
|
* @description fetches information on an order made by the user
|
|
645
|
+
* @param {string} id the order id
|
|
645
646
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
646
647
|
* @param {object} [params] extra parameters specific to the bitvavo api endpoint
|
|
647
648
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
package/js/src/pro/bybit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import bybitRest from '../bybit.js';
|
|
2
|
-
import type { Int, OHLCV, Str, Strings, Ticker, OrderBook, Order, Trade, Tickers, Position, Balances, OrderType, OrderSide, Num, Liquidation } from '../base/types.js';
|
|
2
|
+
import type { Int, OHLCV, Str, Strings, Ticker, OrderBook, Order, Trade, Tickers, Position, Balances, OrderType, OrderSide, Num, Dict, Liquidation } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class bybit extends bybitRest {
|
|
5
5
|
describe(): any;
|
|
@@ -11,6 +11,8 @@ export default class bybit extends bybitRest {
|
|
|
11
11
|
cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
12
12
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
13
13
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
14
|
+
unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
|
|
15
|
+
unWatchTicker(symbols: string, params?: {}): Promise<any>;
|
|
14
16
|
handleTicker(client: Client, message: any): void;
|
|
15
17
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
16
18
|
watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").Dictionary<OHLCV[]>>>;
|
|
@@ -18,15 +20,20 @@ export default class bybit extends bybitRest {
|
|
|
18
20
|
parseWsOHLCV(ohlcv: any, market?: any): OHLCV;
|
|
19
21
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
20
22
|
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
23
|
+
unWatchOrderBookForSymbols(symbols: Strings, params?: {}): Promise<any>;
|
|
24
|
+
unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
|
|
21
25
|
handleOrderBook(client: Client, message: any): void;
|
|
22
26
|
handleDelta(bookside: any, delta: any): void;
|
|
23
27
|
handleDeltas(bookside: any, deltas: any): void;
|
|
24
28
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
25
29
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
30
|
+
unWatchTradesForSymbols(symbols: Strings, params?: {}): Promise<any>;
|
|
31
|
+
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
|
26
32
|
handleTrades(client: Client, message: any): void;
|
|
27
33
|
parseWsTrade(trade: any, market?: any): Trade;
|
|
28
34
|
getPrivateType(url: any): "spot" | "unified" | "usdc";
|
|
29
35
|
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
36
|
+
unWatchMyTrades(symbol?: Str, params?: {}): Promise<any>;
|
|
30
37
|
handleMyTrades(client: Client, message: any): void;
|
|
31
38
|
watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
|
|
32
39
|
setPositionsCache(client: Client, symbols?: Strings): void;
|
|
@@ -36,6 +43,7 @@ export default class bybit extends bybitRest {
|
|
|
36
43
|
handleLiquidation(client: Client, message: any): void;
|
|
37
44
|
parseWsLiquidation(liquidation: any, market?: any): Liquidation;
|
|
38
45
|
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
46
|
+
unWatchOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
39
47
|
handleOrderWs(client: Client, message: any): void;
|
|
40
48
|
handleOrder(client: Client, message: any): void;
|
|
41
49
|
parseWsSpotOrder(order: any, market?: any): Order;
|
|
@@ -43,6 +51,7 @@ export default class bybit extends bybitRest {
|
|
|
43
51
|
handleBalance(client: Client, message: any): void;
|
|
44
52
|
parseWsBalance(balance: any, accountType?: any): void;
|
|
45
53
|
watchTopics(url: any, messageHashes: any, topics: any, params?: {}): Promise<any>;
|
|
54
|
+
unWatchTopics(url: string, topic: string, symbols: string[], messageHashes: string[], subMessageHashes: string[], topics: any, params?: {}): Promise<any>;
|
|
46
55
|
authenticate(url: any, params?: {}): Promise<any>;
|
|
47
56
|
handleErrorMessage(client: Client, message: any): boolean;
|
|
48
57
|
handleMessage(client: Client, message: any): void;
|
|
@@ -53,4 +62,6 @@ export default class bybit extends bybitRest {
|
|
|
53
62
|
handlePong(client: Client, message: any): any;
|
|
54
63
|
handleAuthenticate(client: Client, message: any): any;
|
|
55
64
|
handleSubscriptionStatus(client: Client, message: any): any;
|
|
65
|
+
handleUnSubscribe(client: Client, message: any): any;
|
|
66
|
+
cleanCache(subscription: Dict): void;
|
|
56
67
|
}
|
package/js/src/pro/bybit.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import bybitRest from '../bybit.js';
|
|
9
|
-
import { ArgumentsRequired, AuthenticationError, ExchangeError, BadRequest } from '../base/errors.js';
|
|
9
|
+
import { ArgumentsRequired, AuthenticationError, ExchangeError, BadRequest, UnsubscribeError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -393,6 +393,49 @@ export default class bybit extends bybitRest {
|
|
|
393
393
|
}
|
|
394
394
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
395
395
|
}
|
|
396
|
+
async unWatchTickers(symbols = undefined, params = {}) {
|
|
397
|
+
/**
|
|
398
|
+
* @method
|
|
399
|
+
* @name bybit#unWatchTickers
|
|
400
|
+
* @description unWatches a price ticker
|
|
401
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
|
|
402
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
|
|
403
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
404
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
405
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
406
|
+
*/
|
|
407
|
+
await this.loadMarkets();
|
|
408
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
409
|
+
const options = this.safeValue(this.options, 'watchTickers', {});
|
|
410
|
+
const topic = this.safeString(options, 'name', 'tickers');
|
|
411
|
+
const messageHashes = [];
|
|
412
|
+
const subMessageHashes = [];
|
|
413
|
+
const marketIds = this.marketIds(symbols);
|
|
414
|
+
const topics = [];
|
|
415
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
416
|
+
const marketId = marketIds[i];
|
|
417
|
+
const symbol = symbols[i];
|
|
418
|
+
topics.push(topic + '.' + marketId);
|
|
419
|
+
subMessageHashes.push('ticker:' + symbol);
|
|
420
|
+
messageHashes.push('unsubscribe:ticker:' + symbol);
|
|
421
|
+
}
|
|
422
|
+
const url = await this.getUrlByMarketType(symbols[0], false, 'watchTickers', params);
|
|
423
|
+
return await this.unWatchTopics(url, 'ticker', symbols, messageHashes, subMessageHashes, topics, params);
|
|
424
|
+
}
|
|
425
|
+
async unWatchTicker(symbols, params = {}) {
|
|
426
|
+
/**
|
|
427
|
+
* @method
|
|
428
|
+
* @name bybit#unWatchTicker
|
|
429
|
+
* @description unWatches a price ticker
|
|
430
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
|
|
431
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
|
|
432
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
433
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
434
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
435
|
+
*/
|
|
436
|
+
await this.loadMarkets();
|
|
437
|
+
return await this.unWatchTickers([symbols], params);
|
|
438
|
+
}
|
|
396
439
|
handleTicker(client, message) {
|
|
397
440
|
//
|
|
398
441
|
// linear
|
|
@@ -726,6 +769,56 @@ export default class bybit extends bybitRest {
|
|
|
726
769
|
const orderbook = await this.watchTopics(url, messageHashes, topics, params);
|
|
727
770
|
return orderbook.limit();
|
|
728
771
|
}
|
|
772
|
+
async unWatchOrderBookForSymbols(symbols, params = {}) {
|
|
773
|
+
/**
|
|
774
|
+
* @method
|
|
775
|
+
* @name bybit#unWatchOrderBookForSymbols
|
|
776
|
+
* @description unsubscribe from the orderbook channel
|
|
777
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook
|
|
778
|
+
* @param {string[]} symbols unified symbol of the market to unwatch the trades for
|
|
779
|
+
* @param {int} [params.limit] orderbook limit, default is undefined
|
|
780
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
781
|
+
*/
|
|
782
|
+
await this.loadMarkets();
|
|
783
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
784
|
+
let channel = 'orderbook.';
|
|
785
|
+
let limit = this.safeInteger(params, 'limit');
|
|
786
|
+
if (limit !== undefined) {
|
|
787
|
+
params = this.omit(params, 'limit');
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
const firstMarket = this.market(symbols[0]);
|
|
791
|
+
limit = firstMarket['spot'] ? 50 : 500;
|
|
792
|
+
}
|
|
793
|
+
channel += limit.toString();
|
|
794
|
+
const subMessageHashes = [];
|
|
795
|
+
const messageHashes = [];
|
|
796
|
+
const topics = [];
|
|
797
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
798
|
+
const symbol = symbols[i];
|
|
799
|
+
const market = this.market(symbol);
|
|
800
|
+
const marketId = market['id'];
|
|
801
|
+
const topic = channel + '.' + marketId;
|
|
802
|
+
messageHashes.push('unsubscribe:orderbook:' + symbol);
|
|
803
|
+
subMessageHashes.push('orderbook:' + symbol);
|
|
804
|
+
topics.push(topic);
|
|
805
|
+
}
|
|
806
|
+
const url = await this.getUrlByMarketType(symbols[0], false, 'watchOrderBook', params);
|
|
807
|
+
return await this.unWatchTopics(url, 'orderbook', symbols, messageHashes, subMessageHashes, topics, params);
|
|
808
|
+
}
|
|
809
|
+
async unWatchOrderBook(symbol, params = {}) {
|
|
810
|
+
/**
|
|
811
|
+
* @method
|
|
812
|
+
* @name bybit#unWatchOrderBook
|
|
813
|
+
* @description unsubscribe from the orderbook channel
|
|
814
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook
|
|
815
|
+
* @param {string[]} symbols unified symbol of the market to unwatch the trades for
|
|
816
|
+
* @param {int} [params.limit] orderbook limit, default is undefined
|
|
817
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
818
|
+
*/
|
|
819
|
+
await this.loadMarkets();
|
|
820
|
+
return await this.unWatchOrderBookForSymbols([symbol], params);
|
|
821
|
+
}
|
|
729
822
|
handleOrderBook(client, message) {
|
|
730
823
|
//
|
|
731
824
|
// {
|
|
@@ -850,6 +943,44 @@ export default class bybit extends bybitRest {
|
|
|
850
943
|
}
|
|
851
944
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
852
945
|
}
|
|
946
|
+
async unWatchTradesForSymbols(symbols, params = {}) {
|
|
947
|
+
/**
|
|
948
|
+
* @method
|
|
949
|
+
* @name bybit#unWatchTradesForSymbols
|
|
950
|
+
* @description unsubscribe from the trades channel
|
|
951
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/trade
|
|
952
|
+
* @param {string[]} symbols unified symbol of the market to unwatch the trades for
|
|
953
|
+
* @returns {any} status of the unwatch request
|
|
954
|
+
*/
|
|
955
|
+
await this.loadMarkets();
|
|
956
|
+
symbols = this.marketSymbols(symbols, undefined, false, true);
|
|
957
|
+
const url = await this.getUrlByMarketType(symbols[0], false, 'unWatchTradesForSymbols', params);
|
|
958
|
+
const messageHashes = [];
|
|
959
|
+
const topics = [];
|
|
960
|
+
const subMessageHashes = [];
|
|
961
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
962
|
+
const symbol = symbols[i];
|
|
963
|
+
const market = this.market(symbol);
|
|
964
|
+
const topic = 'publicTrade.' + market['id'];
|
|
965
|
+
topics.push(topic);
|
|
966
|
+
const messageHash = 'unsubscribe:trade:' + symbol;
|
|
967
|
+
messageHashes.push(messageHash);
|
|
968
|
+
subMessageHashes.push('trade:' + symbol);
|
|
969
|
+
}
|
|
970
|
+
return await this.unWatchTopics(url, 'trade', symbols, messageHashes, subMessageHashes, topics, params);
|
|
971
|
+
}
|
|
972
|
+
async unWatchTrades(symbol, params = {}) {
|
|
973
|
+
/**
|
|
974
|
+
* @method
|
|
975
|
+
* @name bybit#unWatchTrades
|
|
976
|
+
* @description unsubscribe from the trades channel
|
|
977
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/trade
|
|
978
|
+
* @param {string} symbol unified symbol of the market to unwatch the trades for
|
|
979
|
+
* @returns {any} status of the unwatch request
|
|
980
|
+
*/
|
|
981
|
+
await this.loadMarkets();
|
|
982
|
+
return await this.unWatchTradesForSymbols([symbol], params);
|
|
983
|
+
}
|
|
853
984
|
handleTrades(client, message) {
|
|
854
985
|
//
|
|
855
986
|
// {
|
|
@@ -1008,6 +1139,35 @@ export default class bybit extends bybitRest {
|
|
|
1008
1139
|
}
|
|
1009
1140
|
return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
|
|
1010
1141
|
}
|
|
1142
|
+
async unWatchMyTrades(symbol = undefined, params = {}) {
|
|
1143
|
+
/**
|
|
1144
|
+
* @method
|
|
1145
|
+
* @name bybit#unWatchMyTrades
|
|
1146
|
+
* @description unWatches information on multiple trades made by the user
|
|
1147
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/private/execution
|
|
1148
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1149
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1150
|
+
* @param {boolean} [params.unifiedMargin] use unified margin account
|
|
1151
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1152
|
+
*/
|
|
1153
|
+
const method = 'watchMyTrades';
|
|
1154
|
+
const messageHash = 'unsubscribe:myTrades';
|
|
1155
|
+
let subHash = 'myTrades';
|
|
1156
|
+
await this.loadMarkets();
|
|
1157
|
+
if (symbol !== undefined) {
|
|
1158
|
+
symbol = this.symbol(symbol);
|
|
1159
|
+
subHash += ':' + symbol;
|
|
1160
|
+
}
|
|
1161
|
+
const url = await this.getUrlByMarketType(symbol, true, method, params);
|
|
1162
|
+
await this.authenticate(url);
|
|
1163
|
+
const topicByMarket = {
|
|
1164
|
+
'spot': 'ticketInfo',
|
|
1165
|
+
'unified': 'execution',
|
|
1166
|
+
'usdc': 'user.openapi.perp.trade',
|
|
1167
|
+
};
|
|
1168
|
+
const topic = this.safeValue(topicByMarket, this.getPrivateType(url));
|
|
1169
|
+
return await this.unWatchTopics(url, 'myTrades', [], [messageHash], [subHash], [topic], params);
|
|
1170
|
+
}
|
|
1011
1171
|
handleMyTrades(client, message) {
|
|
1012
1172
|
//
|
|
1013
1173
|
// spot
|
|
@@ -1280,7 +1440,7 @@ export default class bybit extends bybitRest {
|
|
|
1280
1440
|
const topic = 'liquidation.' + market['id'];
|
|
1281
1441
|
const newLiquidation = await this.watchTopics(url, [messageHash], [topic], params);
|
|
1282
1442
|
if (this.newUpdates) {
|
|
1283
|
-
return
|
|
1443
|
+
return newLiquidation;
|
|
1284
1444
|
}
|
|
1285
1445
|
return this.filterBySymbolsSinceLimit(this.liquidations, [symbol], since, limit, true);
|
|
1286
1446
|
}
|
|
@@ -1372,6 +1532,35 @@ export default class bybit extends bybitRest {
|
|
|
1372
1532
|
}
|
|
1373
1533
|
return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
|
|
1374
1534
|
}
|
|
1535
|
+
async unWatchOrders(symbol = undefined, params = {}) {
|
|
1536
|
+
/**
|
|
1537
|
+
* @method
|
|
1538
|
+
* @name bybit#unWatchOrders
|
|
1539
|
+
* @description unWatches information on multiple orders made by the user
|
|
1540
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/private/order
|
|
1541
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1542
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1543
|
+
* @param {boolean} [params.unifiedMargin] use unified margin account
|
|
1544
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1545
|
+
*/
|
|
1546
|
+
await this.loadMarkets();
|
|
1547
|
+
const method = 'watchOrders';
|
|
1548
|
+
const messageHash = 'unsubscribe:orders';
|
|
1549
|
+
let subHash = 'orders';
|
|
1550
|
+
if (symbol !== undefined) {
|
|
1551
|
+
symbol = this.symbol(symbol);
|
|
1552
|
+
subHash += ':' + symbol;
|
|
1553
|
+
}
|
|
1554
|
+
const url = await this.getUrlByMarketType(symbol, true, method, params);
|
|
1555
|
+
await this.authenticate(url);
|
|
1556
|
+
const topicsByMarket = {
|
|
1557
|
+
'spot': ['order', 'stopOrder'],
|
|
1558
|
+
'unified': ['order'],
|
|
1559
|
+
'usdc': ['user.openapi.perp.order'],
|
|
1560
|
+
};
|
|
1561
|
+
const topics = this.safeValue(topicsByMarket, this.getPrivateType(url));
|
|
1562
|
+
return await this.unWatchTopics(url, 'orders', [], [messageHash], [subHash], topics, params);
|
|
1563
|
+
}
|
|
1375
1564
|
handleOrderWs(client, message) {
|
|
1376
1565
|
//
|
|
1377
1566
|
// {
|
|
@@ -1954,7 +2143,24 @@ export default class bybit extends bybitRest {
|
|
|
1954
2143
|
'args': topics,
|
|
1955
2144
|
};
|
|
1956
2145
|
const message = this.extend(request, params);
|
|
1957
|
-
return await this.watchMultiple(url, messageHashes, message,
|
|
2146
|
+
return await this.watchMultiple(url, messageHashes, message, messageHashes);
|
|
2147
|
+
}
|
|
2148
|
+
async unWatchTopics(url, topic, symbols, messageHashes, subMessageHashes, topics, params = {}) {
|
|
2149
|
+
const reqId = this.requestId();
|
|
2150
|
+
const request = {
|
|
2151
|
+
'op': 'unsubscribe',
|
|
2152
|
+
'req_id': reqId,
|
|
2153
|
+
'args': topics,
|
|
2154
|
+
};
|
|
2155
|
+
const subscription = {
|
|
2156
|
+
'id': reqId,
|
|
2157
|
+
'topic': topic,
|
|
2158
|
+
'messageHashes': messageHashes,
|
|
2159
|
+
'subMessageHashes': subMessageHashes,
|
|
2160
|
+
'symbols': symbols,
|
|
2161
|
+
};
|
|
2162
|
+
const message = this.extend(request, params);
|
|
2163
|
+
return await this.watchMultiple(url, messageHashes, message, messageHashes, subscription);
|
|
1958
2164
|
}
|
|
1959
2165
|
async authenticate(url, params = {}) {
|
|
1960
2166
|
this.checkRequiredCredentials();
|
|
@@ -2105,6 +2311,7 @@ export default class bybit extends bybitRest {
|
|
|
2105
2311
|
'order.amend': this.handleOrderWs,
|
|
2106
2312
|
'order.cancel': this.handleOrderWs,
|
|
2107
2313
|
'auth': this.handleAuthenticate,
|
|
2314
|
+
'unsubscribe': this.handleUnSubscribe,
|
|
2108
2315
|
};
|
|
2109
2316
|
const exacMethod = this.safeValue(methods, topic);
|
|
2110
2317
|
if (exacMethod !== undefined) {
|
|
@@ -2195,4 +2402,86 @@ export default class bybit extends bybitRest {
|
|
|
2195
2402
|
//
|
|
2196
2403
|
return message;
|
|
2197
2404
|
}
|
|
2405
|
+
handleUnSubscribe(client, message) {
|
|
2406
|
+
//
|
|
2407
|
+
// {"success":true,"ret_msg":"","conn_id":"7188110e-6908-41e9-b863-6365127e92ad","req_id":"3","op":"unsubscribe"}
|
|
2408
|
+
//
|
|
2409
|
+
// client.subscription will be something like:
|
|
2410
|
+
// {
|
|
2411
|
+
// "publicTrade.LTCUSDT":true,
|
|
2412
|
+
// "publicTrade.ADAUSDT":true,
|
|
2413
|
+
// "unsubscribe:trade:LTC/USDT:USDT": {
|
|
2414
|
+
// "id":4,
|
|
2415
|
+
// "subHash": "trade:LTC/USDT"
|
|
2416
|
+
// },
|
|
2417
|
+
// }
|
|
2418
|
+
const reqId = this.safeString(message, 'req_id');
|
|
2419
|
+
const keys = Object.keys(client.subscriptions);
|
|
2420
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2421
|
+
const messageHash = keys[i];
|
|
2422
|
+
if (!(messageHash in client.subscriptions)) {
|
|
2423
|
+
continue;
|
|
2424
|
+
// the previous iteration can have deleted the messageHash from the subscriptions
|
|
2425
|
+
}
|
|
2426
|
+
if (messageHash.startsWith('unsubscribe')) {
|
|
2427
|
+
const subscription = client.subscriptions[messageHash];
|
|
2428
|
+
const subId = this.safeString(subscription, 'id');
|
|
2429
|
+
if (reqId !== subId) {
|
|
2430
|
+
continue;
|
|
2431
|
+
}
|
|
2432
|
+
const messageHashes = this.safeList(subscription, 'messageHashes', []);
|
|
2433
|
+
const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
|
|
2434
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
2435
|
+
const unsubHash = messageHashes[j];
|
|
2436
|
+
const subHash = subMessageHashes[j];
|
|
2437
|
+
if (unsubHash in client.subscriptions) {
|
|
2438
|
+
delete client.subscriptions[unsubHash];
|
|
2439
|
+
}
|
|
2440
|
+
if (subHash in client.subscriptions) {
|
|
2441
|
+
delete client.subscriptions[subHash];
|
|
2442
|
+
}
|
|
2443
|
+
const error = new UnsubscribeError(this.id + ' ' + messageHash);
|
|
2444
|
+
client.reject(error, subHash);
|
|
2445
|
+
client.resolve(true, unsubHash);
|
|
2446
|
+
this.cleanCache(subscription);
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
return message;
|
|
2451
|
+
}
|
|
2452
|
+
cleanCache(subscription) {
|
|
2453
|
+
const topic = this.safeString(subscription, 'topic');
|
|
2454
|
+
const symbols = this.safeList(subscription, 'symbols', []);
|
|
2455
|
+
const symbolsLength = symbols.length;
|
|
2456
|
+
if (symbolsLength > 0) {
|
|
2457
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
2458
|
+
const symbol = symbols[i];
|
|
2459
|
+
if (topic === 'trade') {
|
|
2460
|
+
delete this.trades[symbol];
|
|
2461
|
+
}
|
|
2462
|
+
else if (topic === 'orderbook') {
|
|
2463
|
+
delete this.orderbooks[symbol];
|
|
2464
|
+
}
|
|
2465
|
+
else if (topic === 'ticker') {
|
|
2466
|
+
delete this.tickers[symbol];
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
else {
|
|
2471
|
+
if (topic === 'myTrades') {
|
|
2472
|
+
// don't reset this.myTrades directly here
|
|
2473
|
+
// because in c# we need to use a different object
|
|
2474
|
+
const keys = Object.keys(this.myTrades);
|
|
2475
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2476
|
+
delete this.myTrades[keys[i]];
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
else if (topic === 'orders') {
|
|
2480
|
+
const orderSymbols = Object.keys(this.orders);
|
|
2481
|
+
for (let i = 0; i < orderSymbols.length; i++) {
|
|
2482
|
+
delete this.orders[orderSymbols[i]];
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2198
2487
|
}
|
package/js/src/pro/cex.js
CHANGED
|
@@ -1195,6 +1195,7 @@ export default class cex extends cexRest {
|
|
|
1195
1195
|
* @name cex#fetchOrderWs
|
|
1196
1196
|
* @description fetches information on an order made by the user
|
|
1197
1197
|
* @see https://docs.cex.io/#ws-api-get-order
|
|
1198
|
+
* @param {string} id the order id
|
|
1198
1199
|
* @param {string} symbol not used by cex fetchOrder
|
|
1199
1200
|
* @param {object} [params] extra parameters specific to the cex api endpoint
|
|
1200
1201
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
package/js/src/pro/coinex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import coinexRest from '../coinex.js';
|
|
2
|
-
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers,
|
|
2
|
+
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, Balances, Dict, int } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class coinex extends coinexRest {
|
|
5
5
|
describe(): any;
|
|
@@ -8,15 +8,17 @@ export default class coinex extends coinexRest {
|
|
|
8
8
|
parseWSTicker(ticker: any, market?: any): Ticker;
|
|
9
9
|
watchBalance(params?: {}): Promise<Balances>;
|
|
10
10
|
handleBalance(client: Client, message: any): void;
|
|
11
|
+
parseWsBalance(balance: any, accountType?: any): void;
|
|
12
|
+
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
13
|
+
handleMyTrades(client: Client, message: any): void;
|
|
11
14
|
handleTrades(client: Client, message: any): void;
|
|
12
15
|
parseWsTrade(trade: any, market?: any): Trade;
|
|
13
|
-
handleOHLCV(client: Client, message: any): void;
|
|
14
16
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
15
17
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
16
18
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
19
|
+
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
20
|
+
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
17
21
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
18
|
-
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
19
|
-
fetchOHLCVWs(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
20
22
|
handleDelta(bookside: any, delta: any): void;
|
|
21
23
|
handleDeltas(bookside: any, deltas: any): void;
|
|
22
24
|
handleOrderBook(client: Client, message: any): void;
|
|
@@ -24,8 +26,12 @@ export default class coinex extends coinexRest {
|
|
|
24
26
|
handleOrders(client: Client, message: any): void;
|
|
25
27
|
parseWsOrder(order: any, market?: any): Order;
|
|
26
28
|
parseWsOrderStatus(status: any): string;
|
|
29
|
+
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
30
|
+
handleBidAsk(client: Client, message: any): void;
|
|
31
|
+
parseWsBidAsk(ticker: any, market?: any): Ticker;
|
|
27
32
|
handleMessage(client: Client, message: any): void;
|
|
28
|
-
|
|
33
|
+
handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
|
|
34
|
+
handleAuthenticationMessage(client: Client, message: any): void;
|
|
29
35
|
handleSubscriptionStatus(client: Client, message: any): void;
|
|
30
|
-
authenticate(
|
|
36
|
+
authenticate(type: string): Promise<any>;
|
|
31
37
|
}
|