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/dist/cjs/src/mexc.js
CHANGED
|
@@ -563,7 +563,7 @@ class mexc extends mexc$1 {
|
|
|
563
563
|
'POKT': 'POKT',
|
|
564
564
|
'QKC': 'QKC',
|
|
565
565
|
'QTUM': 'QTUM',
|
|
566
|
-
'RAP20': 'RAP20 (Rangers Mainnet)',
|
|
566
|
+
'RAP20': 'RAP20' + ' ' + '(Rangers Mainnet)',
|
|
567
567
|
'REI': 'REI',
|
|
568
568
|
'RSK': 'RBTC',
|
|
569
569
|
'RVN': 'Ravencoin(RVN)',
|
|
@@ -713,69 +713,9 @@ class mexc extends mexc$1 {
|
|
|
713
713
|
// OKB <> OKT (for usdt it's exception) for OKC, PMEER, FLARE, STRD, ZEL, FUND, "NONE", CRING, FREETON, QTZ (probably unique network is meant), HT, BSC(RACAV1), BSC(RACAV2), AMBROSUS, BAJUN, NOM. their individual info is at https://www.mexc.com/api/platform/asset/spot/{COINNAME}
|
|
714
714
|
},
|
|
715
715
|
'networksById': {
|
|
716
|
-
'Aleph Zero(AZERO)': 'AZERO',
|
|
717
|
-
'Alephium(ALPH)': 'ALPH',
|
|
718
|
-
'Algorand(ALGO)': 'ALGO',
|
|
719
|
-
'APTOS(APT)': 'APT',
|
|
720
|
-
'Arbitrum One(ARB)': 'ARB',
|
|
721
|
-
'Avalanche C Chain(AVAX CCHAIN)': 'AVAXC',
|
|
722
|
-
'Avalanche X Chain(AVAX XCHAIN)': 'AVAXX',
|
|
723
|
-
'BEP20(BSC)': 'BSC',
|
|
724
|
-
'Bitcoin Cash(BCH)': 'BCH',
|
|
725
|
-
'Bitcoin SV(BSV)': 'BSV',
|
|
726
|
-
'Bitcoin(BTC)': 'BTC',
|
|
727
|
-
'Bittensor(TAO)': 'TAO',
|
|
728
|
-
'BNB Beacon Chain(BEP2)': 'BEP2',
|
|
729
716
|
'BNB Smart Chain(BEP20-RACAV1)': 'BSC',
|
|
730
717
|
'BNB Smart Chain(BEP20-RACAV2)': 'BSC',
|
|
731
718
|
'BNB Smart Chain(BEP20)': 'BSC',
|
|
732
|
-
'Cardano(ADA)': 'ADA',
|
|
733
|
-
'Celestia(TIA)': 'TIA',
|
|
734
|
-
'Chia(XCH)': 'XCH',
|
|
735
|
-
'Chiliz Chain(CHZ2)': 'CHZ2',
|
|
736
|
-
'Chiliz Legacy Chain(CHZ)': 'CHZ',
|
|
737
|
-
'Clore.ai(CLORE)': 'CLORE',
|
|
738
|
-
'Cosmos(ATOM)': 'ATOM',
|
|
739
|
-
'Dogechain(DC)': 'DC',
|
|
740
|
-
'Dogecoin(DOGE)': 'DOGE',
|
|
741
|
-
'Dymension(DYM)': 'DYM',
|
|
742
|
-
'Dynex(DNX)': 'DNX',
|
|
743
|
-
'Elysium(LAVA)': 'LAVA',
|
|
744
|
-
'Ethereum Classic(ETC)': 'ETC',
|
|
745
|
-
'Ethereum(ERC20)': 'ERC20',
|
|
746
|
-
'Fantom(FTM)': 'FTM',
|
|
747
|
-
'Hedera(HBAR)': 'HBAR',
|
|
748
|
-
'Index Chain': 'INDEX',
|
|
749
|
-
'Internet Computer(ICP)': 'ICP',
|
|
750
|
-
'Kaspa(KAS)': 'KAS',
|
|
751
|
-
'Klaytn(KLAY)': 'KLAY',
|
|
752
|
-
'Litecoin(LTC)': 'LTC',
|
|
753
|
-
'Mantle(MNT)': 'MNT',
|
|
754
|
-
'Mcoin Network': 'MCOIN',
|
|
755
|
-
'Meter(MTRG)': 'MTRG',
|
|
756
|
-
'Monero(XMR)': 'XMR',
|
|
757
|
-
'NEAR Protocol(NEAR)': 'NEAR',
|
|
758
|
-
'Neoxa Network': 'NEOXA',
|
|
759
|
-
'Neurai(XNA)': 'XNA',
|
|
760
|
-
'Omega Network(OMN)': 'OMN',
|
|
761
|
-
'Optimism(OP)': 'OPTIMISM',
|
|
762
|
-
'Polkadot(DOT)': 'DOT',
|
|
763
|
-
'Polygon(MATIC)': 'MATIC',
|
|
764
|
-
'RAP20 (Rangers Mainnet)': 'RAP20',
|
|
765
|
-
'Ravencoin(RVN)': 'RVN',
|
|
766
|
-
'Ripple(XRP)': 'XRP',
|
|
767
|
-
'Satoxcoin(SATOX)': 'SATOX',
|
|
768
|
-
'Solana(SOL)': 'SOL',
|
|
769
|
-
'Starknet(STARK)': 'STARK',
|
|
770
|
-
'Stellar(XLM)': 'XLM',
|
|
771
|
-
'Terra(LUNA)': 'LUNA',
|
|
772
|
-
'Toncoin(TON)': 'TON',
|
|
773
|
-
'Tron(TRC20)': 'TRC20',
|
|
774
|
-
'UGAS(Ultrain)': 'UGAS',
|
|
775
|
-
'VeChain(VET)': 'VET',
|
|
776
|
-
'Vexanium(VEX)': 'VEX',
|
|
777
|
-
'XPR Network': 'XPR',
|
|
778
|
-
'Zilliqa(ZIL)': 'ZIL',
|
|
779
719
|
// TODO: uncomment below after deciding unified name
|
|
780
720
|
// 'PEPE COIN BSC':
|
|
781
721
|
// 'SMART BLOCKCHAIN':
|
package/dist/cjs/src/okcoin.js
CHANGED
|
@@ -577,6 +577,9 @@ class okcoin extends okcoin$1 {
|
|
|
577
577
|
'defaultNetwork': 'ERC20',
|
|
578
578
|
'networks': {
|
|
579
579
|
'ERC20': 'Ethereum',
|
|
580
|
+
'BTC': 'Bitcoin',
|
|
581
|
+
'OMNI': 'Omni',
|
|
582
|
+
'TRC20': 'TRON',
|
|
580
583
|
},
|
|
581
584
|
},
|
|
582
585
|
'commonCurrencies': {
|
|
@@ -709,14 +712,6 @@ class okcoin extends okcoin$1 {
|
|
|
709
712
|
'info': market,
|
|
710
713
|
});
|
|
711
714
|
}
|
|
712
|
-
safeNetwork(networkId) {
|
|
713
|
-
const networksById = {
|
|
714
|
-
'Bitcoin': 'BTC',
|
|
715
|
-
'Omni': 'OMNI',
|
|
716
|
-
'TRON': 'TRC20',
|
|
717
|
-
};
|
|
718
|
-
return this.safeString(networksById, networkId, networkId);
|
|
719
|
-
}
|
|
720
715
|
async fetchCurrencies(params = {}) {
|
|
721
716
|
/**
|
|
722
717
|
* @method
|
|
@@ -760,7 +755,7 @@ class okcoin extends okcoin$1 {
|
|
|
760
755
|
if ((networkId !== undefined) && (networkId.indexOf('-') >= 0)) {
|
|
761
756
|
const parts = networkId.split('-');
|
|
762
757
|
const chainPart = this.safeString(parts, 1, networkId);
|
|
763
|
-
const networkCode = this.
|
|
758
|
+
const networkCode = this.networkIdToCode(chainPart);
|
|
764
759
|
const precision = this.parsePrecision(this.safeString(chain, 'wdTickSz'));
|
|
765
760
|
if (maxPrecision === undefined) {
|
|
766
761
|
maxPrecision = precision;
|
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
|
|
@@ -1641,6 +1641,7 @@ class onetrading extends onetrading$1 {
|
|
|
1641
1641
|
* @method
|
|
1642
1642
|
* @name onetrading#fetchOrder
|
|
1643
1643
|
* @description fetches information on an order made by the user
|
|
1644
|
+
* @param {string} id the order id
|
|
1644
1645
|
* @param {string} symbol not used by onetrading fetchOrder
|
|
1645
1646
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1646
1647
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -2983,6 +2983,7 @@ class phemex extends phemex$1 {
|
|
|
2983
2983
|
* @name phemex#fetchOrder
|
|
2984
2984
|
* @see https://phemex-docs.github.io/#query-orders-by-ids
|
|
2985
2985
|
* @description fetches information on an order made by the user
|
|
2986
|
+
* @param {string} id the order id
|
|
2986
2987
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2987
2988
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2988
2989
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -1415,6 +1415,7 @@ class poloniexfutures extends poloniexfutures$1 {
|
|
|
1415
1415
|
* @description fetches information on an order made by the user
|
|
1416
1416
|
* @see https://api-docs.poloniex.com/futures/api/orders#get-details-of-a-single-order
|
|
1417
1417
|
* @see https://api-docs.poloniex.com/futures/api/orders#get-single-order-by-clientoid
|
|
1418
|
+
* @param {string} id the order id
|
|
1418
1419
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1419
1420
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1420
1421
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -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
|