ccxt 4.3.88 → 4.3.89
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/ace.js +1 -0
- package/dist/cjs/src/alpaca.js +1 -0
- package/dist/cjs/src/ascendex.js +7 -19
- package/dist/cjs/src/bigone.js +1 -0
- package/dist/cjs/src/bingx.js +1 -0
- 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/bitflyer.js +1 -0
- package/dist/cjs/src/bitget.js +1 -0
- 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/cryptocom.js +0 -12
- package/dist/cjs/src/kraken.js +48 -48
- package/dist/cjs/src/mexc.js +1 -61
- package/dist/cjs/src/okcoin.js +4 -9
- 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/bitvavo.js +1 -0
- package/dist/cjs/src/pro/bybit.js +290 -1
- package/dist/cjs/src/pro/cex.js +1 -0
- package/dist/cjs/src/probit.js +1 -0
- package/dist/cjs/src/vertex.js +1 -0
- 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 +1 -0
- package/js/src/ascendex.d.ts +0 -1
- package/js/src/ascendex.js +7 -19
- package/js/src/bigone.js +1 -0
- package/js/src/bingx.js +1 -0
- package/js/src/bit2c.js +1 -0
- package/js/src/bitbank.js +1 -0
- package/js/src/bitfinex.js +1 -0
- package/js/src/bitflyer.js +1 -0
- package/js/src/bitget.js +1 -0
- 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/cryptocom.d.ts +0 -1
- package/js/src/cryptocom.js +0 -12
- package/js/src/kraken.js +48 -48
- 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/onetrading.js +1 -0
- package/js/src/phemex.js +1 -0
- package/js/src/poloniexfutures.js +1 -0
- package/js/src/pro/bitvavo.js +1 -0
- package/js/src/pro/bybit.d.ts +12 -1
- package/js/src/pro/bybit.js +291 -2
- package/js/src/pro/cex.js +1 -0
- package/js/src/probit.js +1 -0
- package/js/src/vertex.js +1 -0
- package/js/src/woo.js +1 -0
- package/js/src/woofipro.js +1 -0
- package/package.json +1 -1
package/js/src/okcoin.js
CHANGED
|
@@ -580,6 +580,9 @@ export default class okcoin extends Exchange {
|
|
|
580
580
|
'defaultNetwork': 'ERC20',
|
|
581
581
|
'networks': {
|
|
582
582
|
'ERC20': 'Ethereum',
|
|
583
|
+
'BTC': 'Bitcoin',
|
|
584
|
+
'OMNI': 'Omni',
|
|
585
|
+
'TRC20': 'TRON',
|
|
583
586
|
},
|
|
584
587
|
},
|
|
585
588
|
'commonCurrencies': {
|
|
@@ -712,14 +715,6 @@ export default class okcoin extends Exchange {
|
|
|
712
715
|
'info': market,
|
|
713
716
|
});
|
|
714
717
|
}
|
|
715
|
-
safeNetwork(networkId) {
|
|
716
|
-
const networksById = {
|
|
717
|
-
'Bitcoin': 'BTC',
|
|
718
|
-
'Omni': 'OMNI',
|
|
719
|
-
'TRON': 'TRC20',
|
|
720
|
-
};
|
|
721
|
-
return this.safeString(networksById, networkId, networkId);
|
|
722
|
-
}
|
|
723
718
|
async fetchCurrencies(params = {}) {
|
|
724
719
|
/**
|
|
725
720
|
* @method
|
|
@@ -763,7 +758,7 @@ export default class okcoin extends Exchange {
|
|
|
763
758
|
if ((networkId !== undefined) && (networkId.indexOf('-') >= 0)) {
|
|
764
759
|
const parts = networkId.split('-');
|
|
765
760
|
const chainPart = this.safeString(parts, 1, networkId);
|
|
766
|
-
const networkCode = this.
|
|
761
|
+
const networkCode = this.networkIdToCode(chainPart);
|
|
767
762
|
const precision = this.parsePrecision(this.safeString(chain, 'wdTickSz'));
|
|
768
763
|
if (maxPrecision === undefined) {
|
|
769
764
|
maxPrecision = precision;
|
package/js/src/onetrading.js
CHANGED
|
@@ -1644,6 +1644,7 @@ export default class onetrading extends Exchange {
|
|
|
1644
1644
|
* @method
|
|
1645
1645
|
* @name onetrading#fetchOrder
|
|
1646
1646
|
* @description fetches information on an order made by the user
|
|
1647
|
+
* @param {string} id the order id
|
|
1647
1648
|
* @param {string} symbol not used by onetrading fetchOrder
|
|
1648
1649
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1649
1650
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
package/js/src/phemex.js
CHANGED
|
@@ -2986,6 +2986,7 @@ export default class phemex extends Exchange {
|
|
|
2986
2986
|
* @name phemex#fetchOrder
|
|
2987
2987
|
* @see https://phemex-docs.github.io/#query-orders-by-ids
|
|
2988
2988
|
* @description fetches information on an order made by the user
|
|
2989
|
+
* @param {string} id the order id
|
|
2989
2990
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2990
2991
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2991
2992
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -1418,6 +1418,7 @@ export default class poloniexfutures extends Exchange {
|
|
|
1418
1418
|
* @description fetches information on an order made by the user
|
|
1419
1419
|
* @see https://api-docs.poloniex.com/futures/api/orders#get-details-of-a-single-order
|
|
1420
1420
|
* @see https://api-docs.poloniex.com/futures/api/orders#get-single-order-by-clientoid
|
|
1421
|
+
* @param {string} id the order id
|
|
1421
1422
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1422
1423
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1423
1424
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
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
|
|
@@ -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/probit.js
CHANGED
|
@@ -1076,6 +1076,7 @@ export default class probit extends Exchange {
|
|
|
1076
1076
|
* @name probit#fetchOrder
|
|
1077
1077
|
* @see https://docs-en.probit.com/reference/order-3
|
|
1078
1078
|
* @description fetches information on an order made by the user
|
|
1079
|
+
* @param {string} id the order id
|
|
1079
1080
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1080
1081
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1081
1082
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
package/js/src/vertex.js
CHANGED
|
@@ -1971,6 +1971,7 @@ export default class vertex extends Exchange {
|
|
|
1971
1971
|
* @name vertex#fetchOrder
|
|
1972
1972
|
* @description fetches information on an order made by the user
|
|
1973
1973
|
* @see https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/order
|
|
1974
|
+
* @param {string} id the order id
|
|
1974
1975
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1975
1976
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1976
1977
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
package/js/src/woo.js
CHANGED
|
@@ -1369,6 +1369,7 @@ export default class woo extends Exchange {
|
|
|
1369
1369
|
* @see https://docs.woo.org/#get-algo-order
|
|
1370
1370
|
* @see https://docs.woo.org/#get-order
|
|
1371
1371
|
* @description fetches information on an order made by the user
|
|
1372
|
+
* @param {string} id the order id
|
|
1372
1373
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1373
1374
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1374
1375
|
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
package/js/src/woofipro.js
CHANGED
|
@@ -1716,6 +1716,7 @@ export default class woofipro extends Exchange {
|
|
|
1716
1716
|
* @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-algo-order-by-order_id
|
|
1717
1717
|
* @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-algo-order-by-client_order_id
|
|
1718
1718
|
* @description fetches information on an order made by the user
|
|
1719
|
+
* @param {string} id the order id
|
|
1719
1720
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1720
1721
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1721
1722
|
* @param {boolean} [params.trigger] whether the order is a stop/algo order
|
package/package.json
CHANGED