ccxt 4.3.89 → 4.3.91
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/alpaca.js +2 -2
- package/dist/cjs/src/ascendex.js +95 -97
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bingx.js +31 -17
- package/dist/cjs/src/bitfinex2.js +21 -22
- package/dist/cjs/src/bitget.js +2 -2
- package/dist/cjs/src/bitmart.js +6 -9
- package/dist/cjs/src/coinbaseinternational.js +2 -1
- package/dist/cjs/src/coinex.js +1 -17
- package/dist/cjs/src/hitbtc.js +2 -0
- package/dist/cjs/src/htx.js +49 -49
- package/dist/cjs/src/huobijp.js +0 -9
- package/dist/cjs/src/kucoin.js +59 -21
- package/dist/cjs/src/kucoinfutures.js +26 -2
- package/dist/cjs/src/latoken.js +1 -0
- package/dist/cjs/src/okx.js +1 -8
- 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/bybit.js +1 -1
- 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/whitebit.js +5 -3
- package/dist/cjs/src/woo.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/alpaca.js +2 -2
- package/js/src/ascendex.js +95 -97
- package/js/src/binance.js +1 -1
- package/js/src/bingx.js +31 -17
- package/js/src/bitfinex2.d.ts +0 -1
- package/js/src/bitfinex2.js +21 -22
- package/js/src/bitget.js +2 -2
- package/js/src/bitmart.d.ts +0 -1
- package/js/src/bitmart.js +6 -9
- 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/hitbtc.js +2 -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/kucoin.d.ts +3 -1
- package/js/src/kucoin.js +59 -21
- package/js/src/kucoinfutures.d.ts +1 -0
- package/js/src/kucoinfutures.js +26 -2
- package/js/src/latoken.js +1 -0
- package/js/src/okx.d.ts +0 -1
- package/js/src/okx.js +1 -8
- 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/bybit.js +1 -1
- 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/whitebit.js +5 -3
- package/js/src/woo.js +1 -1
- package/package.json +1 -1
|
@@ -48,6 +48,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
48
48
|
'createTriggerOrder': true,
|
|
49
49
|
'fetchAccounts': true,
|
|
50
50
|
'fetchBalance': true,
|
|
51
|
+
'fetchBidsAsks': true,
|
|
51
52
|
'fetchBorrowRateHistories': false,
|
|
52
53
|
'fetchBorrowRateHistory': false,
|
|
53
54
|
'fetchClosedOrders': true,
|
|
@@ -772,11 +773,20 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
772
773
|
* @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list
|
|
773
774
|
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
774
775
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
776
|
+
* @param {string} [params.method] the method to use, futuresPublicGetAllTickers or futuresPublicGetContractsActive
|
|
775
777
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
776
778
|
*/
|
|
777
779
|
await this.loadMarkets();
|
|
778
780
|
symbols = this.marketSymbols(symbols);
|
|
779
|
-
|
|
781
|
+
let method = undefined;
|
|
782
|
+
[method, params] = this.handleOptionAndParams(params, 'fetchTickers', 'method', 'futuresPublicGetContractsActive');
|
|
783
|
+
let response = undefined;
|
|
784
|
+
if (method === 'futuresPublicGetAllTickers') {
|
|
785
|
+
response = await this.futuresPublicGetAllTickers(params);
|
|
786
|
+
}
|
|
787
|
+
else {
|
|
788
|
+
response = await this.futuresPublicGetContractsActive(params);
|
|
789
|
+
}
|
|
780
790
|
//
|
|
781
791
|
// {
|
|
782
792
|
// "code": "200000",
|
|
@@ -839,7 +849,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
839
849
|
// }
|
|
840
850
|
// }
|
|
841
851
|
//
|
|
842
|
-
const data = this.safeList(response, 'data'
|
|
852
|
+
const data = this.safeList(response, 'data');
|
|
843
853
|
const tickers = this.parseTickers(data, symbols);
|
|
844
854
|
return this.filterByArrayTickers(tickers, 'symbol', symbols);
|
|
845
855
|
}
|
|
@@ -949,6 +959,20 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
949
959
|
'info': ticker,
|
|
950
960
|
}, market);
|
|
951
961
|
}
|
|
962
|
+
async fetchBidsAsks(symbols = undefined, params = {}) {
|
|
963
|
+
/**
|
|
964
|
+
* @method
|
|
965
|
+
* @name kucoinfutures#fetchBidsAsks
|
|
966
|
+
* @description fetches the bid and ask price and volume for multiple markets
|
|
967
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
968
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
969
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
970
|
+
*/
|
|
971
|
+
const request = {
|
|
972
|
+
'method': 'futuresPublicGetAllTickers',
|
|
973
|
+
};
|
|
974
|
+
return await this.fetchTickers(symbols, this.extend(request, params));
|
|
975
|
+
}
|
|
952
976
|
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
953
977
|
/**
|
|
954
978
|
* @method
|
package/dist/cjs/src/latoken.js
CHANGED
|
@@ -1541,6 +1541,7 @@ class latoken extends latoken$1 {
|
|
|
1541
1541
|
const statuses = {
|
|
1542
1542
|
'TRANSACTION_STATUS_CONFIRMED': 'ok',
|
|
1543
1543
|
'TRANSACTION_STATUS_EXECUTED': 'ok',
|
|
1544
|
+
'TRANSACTION_STATUS_CHECKING': 'pending',
|
|
1544
1545
|
'TRANSACTION_STATUS_CANCELLED': 'canceled',
|
|
1545
1546
|
};
|
|
1546
1547
|
return this.safeString(statuses, status, status);
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -1038,6 +1038,7 @@ class okx extends okx$1 {
|
|
|
1038
1038
|
'ZEC': 'Zcash',
|
|
1039
1039
|
'ZIL': 'Zilliqa',
|
|
1040
1040
|
'ZKSYNC': 'ZKSYNC',
|
|
1041
|
+
'OMNI': 'Omni',
|
|
1041
1042
|
// 'NEON3': 'N3', // tbd
|
|
1042
1043
|
// undetermined : "CELO-TOKEN", "Digital Cash", Khala
|
|
1043
1044
|
// todo: uncomment below after consensus
|
|
@@ -1592,14 +1593,6 @@ class okx extends okx$1 {
|
|
|
1592
1593
|
const dataResponse = this.safeList(response, 'data', []);
|
|
1593
1594
|
return this.parseMarkets(dataResponse);
|
|
1594
1595
|
}
|
|
1595
|
-
safeNetwork(networkId) {
|
|
1596
|
-
const networksById = {
|
|
1597
|
-
'Bitcoin': 'BTC',
|
|
1598
|
-
'Omni': 'OMNI',
|
|
1599
|
-
'TRON': 'TRC20',
|
|
1600
|
-
};
|
|
1601
|
-
return this.safeString(networksById, networkId, networkId);
|
|
1602
|
-
}
|
|
1603
1596
|
async fetchCurrencies(params = {}) {
|
|
1604
1597
|
/**
|
|
1605
1598
|
* @method
|
|
@@ -649,6 +649,81 @@ class binance extends binance$1 {
|
|
|
649
649
|
const orderbook = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscription);
|
|
650
650
|
return orderbook.limit();
|
|
651
651
|
}
|
|
652
|
+
async unWatchOrderBookForSymbols(symbols, params = {}) {
|
|
653
|
+
/**
|
|
654
|
+
* @method
|
|
655
|
+
* @name binance#unWatchOrderBookForSymbols
|
|
656
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#partial-book-depth-streams
|
|
657
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#diff-depth-stream
|
|
658
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams
|
|
659
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams
|
|
660
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#partial-book-depth-streams
|
|
661
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#diff-book-depth-streams
|
|
662
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
663
|
+
* @param {string[]} symbols unified array of symbols
|
|
664
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
665
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
666
|
+
*/
|
|
667
|
+
await this.loadMarkets();
|
|
668
|
+
symbols = this.marketSymbols(symbols, undefined, false, true, true);
|
|
669
|
+
const firstMarket = this.market(symbols[0]);
|
|
670
|
+
let type = firstMarket['type'];
|
|
671
|
+
if (firstMarket['contract']) {
|
|
672
|
+
type = firstMarket['linear'] ? 'future' : 'delivery';
|
|
673
|
+
}
|
|
674
|
+
const name = 'depth';
|
|
675
|
+
let streamHash = 'multipleOrderbook';
|
|
676
|
+
if (symbols !== undefined) {
|
|
677
|
+
streamHash += '::' + symbols.join(',');
|
|
678
|
+
}
|
|
679
|
+
const watchOrderBookRate = this.safeString(this.options, 'watchOrderBookRate', '100');
|
|
680
|
+
const subParams = [];
|
|
681
|
+
const subMessageHashes = [];
|
|
682
|
+
const messageHashes = [];
|
|
683
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
684
|
+
const symbol = symbols[i];
|
|
685
|
+
const market = this.market(symbol);
|
|
686
|
+
subMessageHashes.push('orderbook::' + symbol);
|
|
687
|
+
messageHashes.push('unsubscribe:orderbook:' + symbol);
|
|
688
|
+
const subscriptionHash = market['lowercaseId'] + '@' + name;
|
|
689
|
+
const symbolHash = subscriptionHash + '@' + watchOrderBookRate + 'ms';
|
|
690
|
+
subParams.push(symbolHash);
|
|
691
|
+
}
|
|
692
|
+
const messageHashesLength = subMessageHashes.length;
|
|
693
|
+
const url = this.urls['api']['ws'][type] + '/' + this.stream(type, streamHash, messageHashesLength);
|
|
694
|
+
const requestId = this.requestId(url);
|
|
695
|
+
const request = {
|
|
696
|
+
'method': 'UNSUBSCRIBE',
|
|
697
|
+
'params': subParams,
|
|
698
|
+
'id': requestId,
|
|
699
|
+
};
|
|
700
|
+
const subscription = {
|
|
701
|
+
'unsubscribe': true,
|
|
702
|
+
'id': requestId.toString(),
|
|
703
|
+
'symbols': symbols,
|
|
704
|
+
'subMessageHashes': subMessageHashes,
|
|
705
|
+
'messageHashes': messageHashes,
|
|
706
|
+
'topic': 'orderbook',
|
|
707
|
+
};
|
|
708
|
+
return await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscription);
|
|
709
|
+
}
|
|
710
|
+
async unWatchOrderBook(symbol, params = {}) {
|
|
711
|
+
/**
|
|
712
|
+
* @method
|
|
713
|
+
* @name binance#unWatchOrderBook
|
|
714
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#partial-book-depth-streams
|
|
715
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#diff-depth-stream
|
|
716
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams
|
|
717
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams
|
|
718
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#partial-book-depth-streams
|
|
719
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#diff-book-depth-streams
|
|
720
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
721
|
+
* @param {string} symbol unified array of symbols
|
|
722
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
723
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
724
|
+
*/
|
|
725
|
+
return await this.unWatchOrderBookForSymbols([symbol], params);
|
|
726
|
+
}
|
|
652
727
|
async fetchOrderBookWs(symbol, limit = undefined, params = {}) {
|
|
653
728
|
/**
|
|
654
729
|
* @method
|
|
@@ -936,8 +1011,71 @@ class binance extends binance$1 {
|
|
|
936
1011
|
if (method !== undefined) {
|
|
937
1012
|
method.call(this, client, message, subscription);
|
|
938
1013
|
}
|
|
1014
|
+
const isUnSubMessage = this.safeBool(subscription, 'unsubscribe', false);
|
|
1015
|
+
if (isUnSubMessage) {
|
|
1016
|
+
this.handleUnSubscription(client, subscription);
|
|
1017
|
+
}
|
|
939
1018
|
return message;
|
|
940
1019
|
}
|
|
1020
|
+
handleUnSubscription(client, subscription) {
|
|
1021
|
+
const messageHashes = this.safeList(subscription, 'messageHashes', []);
|
|
1022
|
+
const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
|
|
1023
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
1024
|
+
const unsubHash = messageHashes[j];
|
|
1025
|
+
const subHash = subMessageHashes[j];
|
|
1026
|
+
if (unsubHash in client.subscriptions) {
|
|
1027
|
+
delete client.subscriptions[unsubHash];
|
|
1028
|
+
}
|
|
1029
|
+
if (subHash in client.subscriptions) {
|
|
1030
|
+
delete client.subscriptions[subHash];
|
|
1031
|
+
}
|
|
1032
|
+
const error = new errors.UnsubscribeError(this.id + ' ' + subHash);
|
|
1033
|
+
client.reject(error, subHash);
|
|
1034
|
+
client.resolve(true, unsubHash);
|
|
1035
|
+
this.cleanCache(subscription);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
cleanCache(subscription) {
|
|
1039
|
+
const topic = this.safeString(subscription, 'topic');
|
|
1040
|
+
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1041
|
+
const symbolsLength = symbols.length;
|
|
1042
|
+
if (symbolsLength > 0) {
|
|
1043
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
1044
|
+
const symbol = symbols[i];
|
|
1045
|
+
if (topic === 'trade') {
|
|
1046
|
+
delete this.trades[symbol];
|
|
1047
|
+
}
|
|
1048
|
+
else if (topic === 'orderbook') {
|
|
1049
|
+
delete this.orderbooks[symbol];
|
|
1050
|
+
}
|
|
1051
|
+
else if (topic === 'ticker') {
|
|
1052
|
+
delete this.tickers[symbol];
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
if (topic === 'myTrades') {
|
|
1058
|
+
// don't reset this.myTrades directly here
|
|
1059
|
+
// because in c# we need to use a different object
|
|
1060
|
+
const keys = Object.keys(this.myTrades);
|
|
1061
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1062
|
+
delete this.myTrades[keys[i]];
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
else if (topic === 'orders') {
|
|
1066
|
+
const orderSymbols = Object.keys(this.orders);
|
|
1067
|
+
for (let i = 0; i < orderSymbols.length; i++) {
|
|
1068
|
+
delete this.orders[orderSymbols[i]];
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
else if (topic === 'ticker') {
|
|
1072
|
+
const tickerSymbols = Object.keys(this.tickers);
|
|
1073
|
+
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
1074
|
+
delete this.tickers[tickerSymbols[i]];
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
941
1079
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
942
1080
|
/**
|
|
943
1081
|
* @method
|
|
@@ -1001,6 +1139,85 @@ class binance extends binance$1 {
|
|
|
1001
1139
|
}
|
|
1002
1140
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
1003
1141
|
}
|
|
1142
|
+
async unWatchTradesForSymbols(symbols, params = {}) {
|
|
1143
|
+
/**
|
|
1144
|
+
* @method
|
|
1145
|
+
* @name binance#unWatchTradesForSymbols
|
|
1146
|
+
* @description unsubscribes from the trades channel
|
|
1147
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
|
|
1148
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
|
|
1149
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
|
|
1150
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
|
|
1151
|
+
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
1152
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1153
|
+
* @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
|
|
1154
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
1155
|
+
*/
|
|
1156
|
+
await this.loadMarkets();
|
|
1157
|
+
symbols = this.marketSymbols(symbols, undefined, false, true, true);
|
|
1158
|
+
let streamHash = 'multipleTrades';
|
|
1159
|
+
if (symbols !== undefined) {
|
|
1160
|
+
const symbolsLength = symbols.length;
|
|
1161
|
+
if (symbolsLength > 200) {
|
|
1162
|
+
throw new errors.BadRequest(this.id + ' watchTradesForSymbols() accepts 200 symbols at most. To watch more symbols call watchTradesForSymbols() multiple times');
|
|
1163
|
+
}
|
|
1164
|
+
streamHash += '::' + symbols.join(',');
|
|
1165
|
+
}
|
|
1166
|
+
let name = undefined;
|
|
1167
|
+
[name, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'name', 'trade');
|
|
1168
|
+
params = this.omit(params, 'callerMethodName');
|
|
1169
|
+
const firstMarket = this.market(symbols[0]);
|
|
1170
|
+
let type = firstMarket['type'];
|
|
1171
|
+
if (firstMarket['contract']) {
|
|
1172
|
+
type = firstMarket['linear'] ? 'future' : 'delivery';
|
|
1173
|
+
}
|
|
1174
|
+
const subMessageHashes = [];
|
|
1175
|
+
const subParams = [];
|
|
1176
|
+
const messageHashes = [];
|
|
1177
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
1178
|
+
const symbol = symbols[i];
|
|
1179
|
+
const market = this.market(symbol);
|
|
1180
|
+
subMessageHashes.push('trade::' + symbol);
|
|
1181
|
+
messageHashes.push('unsubscribe:trade:' + symbol);
|
|
1182
|
+
const rawHash = market['lowercaseId'] + '@' + name;
|
|
1183
|
+
subParams.push(rawHash);
|
|
1184
|
+
}
|
|
1185
|
+
const query = this.omit(params, 'type');
|
|
1186
|
+
const subParamsLength = subParams.length;
|
|
1187
|
+
const url = this.urls['api']['ws'][type] + '/' + this.stream(type, streamHash, subParamsLength);
|
|
1188
|
+
const requestId = this.requestId(url);
|
|
1189
|
+
const request = {
|
|
1190
|
+
'method': 'UNSUBSCRIBE',
|
|
1191
|
+
'params': subParams,
|
|
1192
|
+
'id': requestId,
|
|
1193
|
+
};
|
|
1194
|
+
const subscription = {
|
|
1195
|
+
'unsubscribe': true,
|
|
1196
|
+
'id': requestId.toString(),
|
|
1197
|
+
'subMessageHashes': subMessageHashes,
|
|
1198
|
+
'messageHashes': messageHashes,
|
|
1199
|
+
'symbols': symbols,
|
|
1200
|
+
'topic': 'trade',
|
|
1201
|
+
};
|
|
1202
|
+
return await this.watchMultiple(url, messageHashes, this.extend(request, query), messageHashes, subscription);
|
|
1203
|
+
}
|
|
1204
|
+
async unWatchTrades(symbol, params = {}) {
|
|
1205
|
+
/**
|
|
1206
|
+
* @method
|
|
1207
|
+
* @name binance#unWatchTrades
|
|
1208
|
+
* @description unsubscribes from the trades channel
|
|
1209
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
|
|
1210
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
|
|
1211
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
|
|
1212
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
|
|
1213
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
1214
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1215
|
+
* @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
|
|
1216
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
1217
|
+
*/
|
|
1218
|
+
await this.loadMarkets();
|
|
1219
|
+
return await this.unWatchTradesForSymbols([symbol], params);
|
|
1220
|
+
}
|
|
1004
1221
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
1005
1222
|
/**
|
|
1006
1223
|
* @method
|
|
@@ -1534,6 +1751,112 @@ class binance extends binance$1 {
|
|
|
1534
1751
|
}
|
|
1535
1752
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
1536
1753
|
}
|
|
1754
|
+
async unWatchTickers(symbols = undefined, params = {}) {
|
|
1755
|
+
/**
|
|
1756
|
+
* @method
|
|
1757
|
+
* @name binance#unWatchTickers
|
|
1758
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-mini-ticker-stream
|
|
1759
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-ticker-streams
|
|
1760
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#all-market-mini-tickers-stream
|
|
1761
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams
|
|
1762
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#all-market-mini-tickers-stream
|
|
1763
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#individual-symbol-ticker-streams
|
|
1764
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
1765
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
1766
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1767
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1768
|
+
*/
|
|
1769
|
+
let channelName = undefined;
|
|
1770
|
+
[channelName, params] = this.handleOptionAndParams(params, 'watchTickers', 'name', 'ticker');
|
|
1771
|
+
if (channelName === 'bookTicker') {
|
|
1772
|
+
throw new errors.BadRequest(this.id + ' deprecation notice - to subscribe for bids-asks, use watch_bids_asks() method instead');
|
|
1773
|
+
}
|
|
1774
|
+
await this.loadMarkets();
|
|
1775
|
+
const methodName = 'watchTickers';
|
|
1776
|
+
symbols = this.marketSymbols(symbols, undefined, true, false, true);
|
|
1777
|
+
let firstMarket = undefined;
|
|
1778
|
+
let marketType = undefined;
|
|
1779
|
+
const symbolsDefined = (symbols !== undefined);
|
|
1780
|
+
if (symbolsDefined) {
|
|
1781
|
+
firstMarket = this.market(symbols[0]);
|
|
1782
|
+
}
|
|
1783
|
+
[marketType, params] = this.handleMarketTypeAndParams(methodName, firstMarket, params);
|
|
1784
|
+
let subType = undefined;
|
|
1785
|
+
[subType, params] = this.handleSubTypeAndParams(methodName, firstMarket, params);
|
|
1786
|
+
let rawMarketType = undefined;
|
|
1787
|
+
if (this.isLinear(marketType, subType)) {
|
|
1788
|
+
rawMarketType = 'future';
|
|
1789
|
+
}
|
|
1790
|
+
else if (this.isInverse(marketType, subType)) {
|
|
1791
|
+
rawMarketType = 'delivery';
|
|
1792
|
+
}
|
|
1793
|
+
else if (marketType === 'spot') {
|
|
1794
|
+
rawMarketType = marketType;
|
|
1795
|
+
}
|
|
1796
|
+
else {
|
|
1797
|
+
throw new errors.NotSupported(this.id + ' ' + methodName + '() does not support options markets');
|
|
1798
|
+
}
|
|
1799
|
+
const isBidAsk = (channelName === 'bookTicker');
|
|
1800
|
+
const subscriptionArgs = [];
|
|
1801
|
+
const subMessageHashes = [];
|
|
1802
|
+
if (symbolsDefined) {
|
|
1803
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
1804
|
+
const symbol = symbols[i];
|
|
1805
|
+
const market = this.market(symbol);
|
|
1806
|
+
subscriptionArgs.push(market['lowercaseId'] + '@' + channelName);
|
|
1807
|
+
subMessageHashes.push(this.getMessageHash(channelName, market['symbol'], isBidAsk));
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
else {
|
|
1811
|
+
if (isBidAsk) {
|
|
1812
|
+
if (marketType === 'spot') {
|
|
1813
|
+
throw new errors.ArgumentsRequired(this.id + ' ' + methodName + '() requires symbols for this channel for spot markets');
|
|
1814
|
+
}
|
|
1815
|
+
subscriptionArgs.push('!' + channelName);
|
|
1816
|
+
}
|
|
1817
|
+
else {
|
|
1818
|
+
subscriptionArgs.push('!' + channelName + '@arr');
|
|
1819
|
+
}
|
|
1820
|
+
subMessageHashes.push(this.getMessageHash(channelName, undefined, isBidAsk));
|
|
1821
|
+
}
|
|
1822
|
+
let streamHash = channelName;
|
|
1823
|
+
if (symbolsDefined) {
|
|
1824
|
+
streamHash = channelName + '::' + symbols.join(',');
|
|
1825
|
+
}
|
|
1826
|
+
const url = this.urls['api']['ws'][rawMarketType] + '/' + this.stream(rawMarketType, streamHash);
|
|
1827
|
+
const requestId = this.requestId(url);
|
|
1828
|
+
const request = {
|
|
1829
|
+
'method': 'UNSUBSCRIBE',
|
|
1830
|
+
'params': subscriptionArgs,
|
|
1831
|
+
'id': requestId,
|
|
1832
|
+
};
|
|
1833
|
+
const subscription = {
|
|
1834
|
+
'unsubscribe': true,
|
|
1835
|
+
'id': requestId.toString(),
|
|
1836
|
+
'subMessageHashes': subMessageHashes,
|
|
1837
|
+
'messageHashes': subMessageHashes,
|
|
1838
|
+
'symbols': symbols,
|
|
1839
|
+
'topic': 'ticker',
|
|
1840
|
+
};
|
|
1841
|
+
return await this.watchMultiple(url, subMessageHashes, this.extend(request, params), subMessageHashes, subscription);
|
|
1842
|
+
}
|
|
1843
|
+
async unWatchTicker(symbol, params = {}) {
|
|
1844
|
+
/**
|
|
1845
|
+
* @method
|
|
1846
|
+
* @name binance#unWatchTicker
|
|
1847
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-mini-ticker-stream
|
|
1848
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-ticker-streams
|
|
1849
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#all-market-mini-tickers-stream
|
|
1850
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams
|
|
1851
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#all-market-mini-tickers-stream
|
|
1852
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#individual-symbol-ticker-streams
|
|
1853
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
1854
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1855
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1856
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1857
|
+
*/
|
|
1858
|
+
return await this.unWatchTickers([symbol], params);
|
|
1859
|
+
}
|
|
1537
1860
|
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
1538
1861
|
/**
|
|
1539
1862
|
* @method
|