ccxt 4.4.11 → 4.4.13
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 -4
- package/dist/ccxt.browser.min.js +4 -4
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/bigone.js +2 -0
- package/dist/cjs/src/binance.js +61 -3
- package/dist/cjs/src/bingx.js +96 -6
- package/dist/cjs/src/bitget.js +2 -0
- package/dist/cjs/src/bitmex.js +1 -0
- package/dist/cjs/src/bybit.js +4 -1
- package/dist/cjs/src/coinbaseinternational.js +2 -0
- package/dist/cjs/src/coinex.js +2 -0
- package/dist/cjs/src/delta.js +2 -0
- package/dist/cjs/src/deribit.js +2 -0
- package/dist/cjs/src/digifinex.js +2 -0
- package/dist/cjs/src/gate.js +2 -0
- package/dist/cjs/src/htx.js +8 -2
- package/dist/cjs/src/kraken.js +4 -4
- package/dist/cjs/src/krakenfutures.js +2 -0
- package/dist/cjs/src/kucoinfutures.js +2 -0
- package/dist/cjs/src/mexc.js +19 -4
- package/dist/cjs/src/okx.js +56 -23
- package/dist/cjs/src/oxfun.js +1 -0
- package/dist/cjs/src/paradex.js +1 -0
- package/dist/cjs/src/phemex.js +13 -4
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/binance.js +80 -5
- package/dist/cjs/src/pro/bitfinex.js +8 -8
- package/dist/cjs/src/pro/krakenfutures.js +2 -0
- package/dist/cjs/src/pro/phemex.js +2 -0
- package/dist/cjs/src/pro/woo.js +73 -0
- package/examples/README.md +4 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +6 -0
- package/js/src/base/types.d.ts +18 -16
- package/js/src/bigone.js +2 -0
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +61 -3
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +96 -6
- package/js/src/bitget.js +2 -0
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +4 -1
- package/js/src/coinbaseinternational.js +2 -0
- package/js/src/coinex.js +2 -0
- package/js/src/delta.js +2 -0
- package/js/src/deribit.js +2 -0
- package/js/src/digifinex.js +2 -0
- package/js/src/gate.js +2 -0
- package/js/src/htx.js +8 -2
- package/js/src/kraken.js +4 -4
- package/js/src/krakenfutures.js +2 -0
- package/js/src/kucoinfutures.js +2 -0
- package/js/src/mexc.js +19 -4
- package/js/src/okx.d.ts +1 -0
- package/js/src/okx.js +56 -23
- package/js/src/oxfun.js +1 -0
- package/js/src/paradex.js +1 -0
- package/js/src/phemex.js +13 -4
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/binance.d.ts +5 -0
- package/js/src/pro/binance.js +80 -5
- package/js/src/pro/bitfinex.js +8 -8
- package/js/src/pro/krakenfutures.js +2 -0
- package/js/src/pro/phemex.js +2 -0
- package/js/src/pro/woo.d.ts +3 -0
- package/js/src/pro/woo.js +73 -0
- package/package.json +2 -2
package/js/src/okx.js
CHANGED
|
@@ -98,6 +98,7 @@ export default class okx extends Exchange {
|
|
|
98
98
|
'fetchMarketLeverageTiers': true,
|
|
99
99
|
'fetchMarkets': true,
|
|
100
100
|
'fetchMarkOHLCV': true,
|
|
101
|
+
'fetchMarkPrices': true,
|
|
101
102
|
'fetchMySettlementHistory': false,
|
|
102
103
|
'fetchMyTrades': true,
|
|
103
104
|
'fetchOHLCV': true,
|
|
@@ -1804,6 +1805,13 @@ export default class okx extends Exchange {
|
|
|
1804
1805
|
return this.parseOrderBook(first, symbol, timestamp);
|
|
1805
1806
|
}
|
|
1806
1807
|
parseTicker(ticker, market = undefined) {
|
|
1808
|
+
//
|
|
1809
|
+
// {
|
|
1810
|
+
// "instType":"SWAP",
|
|
1811
|
+
// "instId":"BTC-USDT-SWAP",
|
|
1812
|
+
// "markPx":"200",
|
|
1813
|
+
// "ts":"1597026383085"
|
|
1814
|
+
// }
|
|
1807
1815
|
//
|
|
1808
1816
|
// {
|
|
1809
1817
|
// "instType": "SPOT",
|
|
@@ -1855,6 +1863,7 @@ export default class okx extends Exchange {
|
|
|
1855
1863
|
'average': undefined,
|
|
1856
1864
|
'baseVolume': baseVolume,
|
|
1857
1865
|
'quoteVolume': quoteVolume,
|
|
1866
|
+
'markPrice': this.safeString(ticker, 'markPx'),
|
|
1858
1867
|
'info': ticker,
|
|
1859
1868
|
}, market);
|
|
1860
1869
|
}
|
|
@@ -1962,6 +1971,38 @@ export default class okx extends Exchange {
|
|
|
1962
1971
|
const tickers = this.safeList(response, 'data', []);
|
|
1963
1972
|
return this.parseTickers(tickers, symbols);
|
|
1964
1973
|
}
|
|
1974
|
+
async fetchMarkPrices(symbols = undefined, params = {}) {
|
|
1975
|
+
/**
|
|
1976
|
+
* @method
|
|
1977
|
+
* @name okx#fetchMarkPrices
|
|
1978
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1979
|
+
* @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price
|
|
1980
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1981
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1982
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1983
|
+
*/
|
|
1984
|
+
await this.loadMarkets();
|
|
1985
|
+
symbols = this.marketSymbols(symbols);
|
|
1986
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1987
|
+
let marketType = undefined;
|
|
1988
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params, 'swap');
|
|
1989
|
+
const request = {
|
|
1990
|
+
'instType': this.convertToInstrumentType(marketType),
|
|
1991
|
+
};
|
|
1992
|
+
if (marketType === 'option') {
|
|
1993
|
+
const defaultUnderlying = this.safeString(this.options, 'defaultUnderlying', 'BTC-USD');
|
|
1994
|
+
const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
|
|
1995
|
+
if (currencyId === undefined) {
|
|
1996
|
+
throw new ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
|
|
1997
|
+
}
|
|
1998
|
+
else {
|
|
1999
|
+
request['uly'] = currencyId;
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
const response = await this.publicGetPublicMarkPrice(this.extend(request, params));
|
|
2003
|
+
const tickers = this.safeList(response, 'data', []);
|
|
2004
|
+
return this.parseTickers(tickers, symbols);
|
|
2005
|
+
}
|
|
1965
2006
|
parseTrade(trade, market = undefined) {
|
|
1966
2007
|
//
|
|
1967
2008
|
// public fetchTrades
|
|
@@ -2940,7 +2981,7 @@ export default class okx extends Exchange {
|
|
|
2940
2981
|
* @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
|
|
2941
2982
|
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
2942
2983
|
* @param {string} [params.tpOrdKind] 'condition' or 'limit', the default is 'condition'
|
|
2943
|
-
* @param {
|
|
2984
|
+
* @param {bool} [params.hedged] *swap and future only* true for hedged mode, false for one way mode
|
|
2944
2985
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2945
2986
|
*/
|
|
2946
2987
|
await this.loadMarkets();
|
|
@@ -4828,38 +4869,30 @@ export default class okx extends Exchange {
|
|
|
4828
4869
|
* @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-deposit-address
|
|
4829
4870
|
* @param {string} code unified currency code
|
|
4830
4871
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4872
|
+
* @param {string} [params.network] the network name for the deposit address
|
|
4831
4873
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
4832
4874
|
*/
|
|
4875
|
+
await this.loadMarkets();
|
|
4833
4876
|
const rawNetwork = this.safeStringUpper(params, 'network');
|
|
4834
|
-
const networks = this.safeValue(this.options, 'networks', {});
|
|
4835
|
-
const network = this.safeString(networks, rawNetwork, rawNetwork);
|
|
4836
4877
|
params = this.omit(params, 'network');
|
|
4878
|
+
code = this.safeCurrencyCode(code);
|
|
4879
|
+
const network = this.networkIdToCode(rawNetwork, code);
|
|
4837
4880
|
const response = await this.fetchDepositAddressesByNetwork(code, params);
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
result = this.safeValue(response, code);
|
|
4881
|
+
if (network !== undefined) {
|
|
4882
|
+
const result = this.safeDict(response, network);
|
|
4841
4883
|
if (result === undefined) {
|
|
4842
|
-
|
|
4843
|
-
result = this.safeValue(response, alias);
|
|
4844
|
-
if (result === undefined) {
|
|
4845
|
-
const defaultNetwork = this.safeString(this.options, 'defaultNetwork', 'ERC20');
|
|
4846
|
-
result = this.safeValue(response, defaultNetwork);
|
|
4847
|
-
if (result === undefined) {
|
|
4848
|
-
const values = Object.values(response);
|
|
4849
|
-
result = this.safeValue(values, 0);
|
|
4850
|
-
if (result === undefined) {
|
|
4851
|
-
throw new InvalidAddress(this.id + ' fetchDepositAddress() cannot find deposit address for ' + code);
|
|
4852
|
-
}
|
|
4853
|
-
}
|
|
4854
|
-
}
|
|
4884
|
+
throw new InvalidAddress(this.id + ' fetchDepositAddress() cannot find ' + network + ' deposit address for ' + code);
|
|
4855
4885
|
}
|
|
4856
4886
|
return result;
|
|
4857
4887
|
}
|
|
4858
|
-
|
|
4859
|
-
if (
|
|
4860
|
-
|
|
4888
|
+
const codeNetwork = this.networkIdToCode(code, code);
|
|
4889
|
+
if (codeNetwork in response) {
|
|
4890
|
+
return response[codeNetwork];
|
|
4861
4891
|
}
|
|
4862
|
-
return
|
|
4892
|
+
// if the network is not specified, return the first address
|
|
4893
|
+
const keys = Object.keys(response);
|
|
4894
|
+
const first = this.safeString(keys, 0);
|
|
4895
|
+
return this.safeDict(response, first);
|
|
4863
4896
|
}
|
|
4864
4897
|
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
4865
4898
|
/**
|
package/js/src/oxfun.js
CHANGED
|
@@ -862,6 +862,7 @@ export default class oxfun extends Exchange {
|
|
|
862
862
|
'average': undefined,
|
|
863
863
|
'baseVolume': this.safeString(ticker, 'currencyVolume24h'),
|
|
864
864
|
'quoteVolume': undefined,
|
|
865
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
865
866
|
'info': ticker,
|
|
866
867
|
}, market);
|
|
867
868
|
}
|
package/js/src/paradex.js
CHANGED
|
@@ -671,6 +671,7 @@ export default class paradex extends Exchange {
|
|
|
671
671
|
'average': undefined,
|
|
672
672
|
'baseVolume': undefined,
|
|
673
673
|
'quoteVolume': this.safeString(ticker, 'volume_24h'),
|
|
674
|
+
'markPrice': this.safeString(ticker, 'mark_price'),
|
|
674
675
|
'info': ticker,
|
|
675
676
|
}, market);
|
|
676
677
|
}
|
package/js/src/phemex.js
CHANGED
|
@@ -2498,6 +2498,8 @@ export default class phemex extends Exchange {
|
|
|
2498
2498
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
2499
2499
|
* @param {object} [params.stopLoss] *swap only* *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
|
|
2500
2500
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
2501
|
+
* @param {string} [params.posSide] *swap only* "Merged" for one way mode, "Long" for buy side of hedged mode, "Short" for sell side of hedged mode
|
|
2502
|
+
* @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode, default is false
|
|
2501
2503
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2502
2504
|
*/
|
|
2503
2505
|
await this.loadMarkets();
|
|
@@ -2599,15 +2601,22 @@ export default class phemex extends Exchange {
|
|
|
2599
2601
|
}
|
|
2600
2602
|
}
|
|
2601
2603
|
else if (market['swap']) {
|
|
2604
|
+
const hedged = this.safeBool(params, 'hedged', false);
|
|
2605
|
+
params = this.omit(params, 'hedged');
|
|
2602
2606
|
let posSide = this.safeStringLower(params, 'posSide');
|
|
2603
2607
|
if (posSide === undefined) {
|
|
2604
|
-
|
|
2608
|
+
if (hedged) {
|
|
2609
|
+
if (reduceOnly) {
|
|
2610
|
+
side = (side === 'buy') ? 'sell' : 'buy';
|
|
2611
|
+
}
|
|
2612
|
+
posSide = (side === 'buy') ? 'Long' : 'Short';
|
|
2613
|
+
}
|
|
2614
|
+
else {
|
|
2615
|
+
posSide = 'Merged';
|
|
2616
|
+
}
|
|
2605
2617
|
}
|
|
2606
2618
|
posSide = this.capitalize(posSide);
|
|
2607
2619
|
request['posSide'] = posSide;
|
|
2608
|
-
if (reduceOnly !== undefined) {
|
|
2609
|
-
request['reduceOnly'] = reduceOnly;
|
|
2610
|
-
}
|
|
2611
2620
|
if (market['settle'] === 'USDT') {
|
|
2612
2621
|
request['orderQtyRq'] = amount;
|
|
2613
2622
|
}
|
package/js/src/poloniex.js
CHANGED
|
@@ -630,6 +630,7 @@ export default class poloniex extends Exchange {
|
|
|
630
630
|
'average': undefined,
|
|
631
631
|
'baseVolume': this.safeString(ticker, 'quantity'),
|
|
632
632
|
'quoteVolume': this.safeString(ticker, 'amount'),
|
|
633
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
633
634
|
'info': ticker,
|
|
634
635
|
}, market);
|
|
635
636
|
}
|
package/js/src/pro/binance.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export default class binance extends binanceRest {
|
|
|
22
22
|
watchPositions: boolean;
|
|
23
23
|
watchTicker: boolean;
|
|
24
24
|
watchTickers: boolean;
|
|
25
|
+
watchMarkPrices: boolean;
|
|
26
|
+
watchMarkPrice: boolean;
|
|
25
27
|
watchTrades: boolean;
|
|
26
28
|
watchTradesForSymbols: boolean;
|
|
27
29
|
createOrderWs: boolean;
|
|
@@ -136,6 +138,7 @@ export default class binance extends binanceRest {
|
|
|
136
138
|
tickerChannelsMap: {
|
|
137
139
|
'24hrTicker': string;
|
|
138
140
|
'24hrMiniTicker': string;
|
|
141
|
+
markPriceUpdate: string;
|
|
139
142
|
'1hTicker': string;
|
|
140
143
|
'4hTicker': string;
|
|
141
144
|
'1dTicker': string;
|
|
@@ -181,6 +184,8 @@ export default class binance extends binanceRest {
|
|
|
181
184
|
fetchOHLCVWs(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
182
185
|
handleFetchOHLCV(client: Client, message: any): void;
|
|
183
186
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
187
|
+
watchMarkPrice(symbol: string, params?: {}): Promise<Ticker>;
|
|
188
|
+
watchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
184
189
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
185
190
|
unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
|
|
186
191
|
unWatchTicker(symbol: string, params?: {}): Promise<any>;
|
package/js/src/pro/binance.js
CHANGED
|
@@ -39,6 +39,8 @@ export default class binance extends binanceRest {
|
|
|
39
39
|
'watchPositions': true,
|
|
40
40
|
'watchTicker': true,
|
|
41
41
|
'watchTickers': true,
|
|
42
|
+
'watchMarkPrices': true,
|
|
43
|
+
'watchMarkPrice': true,
|
|
42
44
|
'watchTrades': true,
|
|
43
45
|
'watchTradesForSymbols': true,
|
|
44
46
|
'createOrderWs': true,
|
|
@@ -155,6 +157,7 @@ export default class binance extends binanceRest {
|
|
|
155
157
|
'tickerChannelsMap': {
|
|
156
158
|
'24hrTicker': 'ticker',
|
|
157
159
|
'24hrMiniTicker': 'miniTicker',
|
|
160
|
+
'markPriceUpdate': 'markPrice',
|
|
158
161
|
// rolling window tickers
|
|
159
162
|
'1hTicker': 'ticker_1h',
|
|
160
163
|
'4hTicker': 'ticker_4h',
|
|
@@ -1770,6 +1773,44 @@ export default class binance extends binanceRest {
|
|
|
1770
1773
|
const tickers = await this.watchTickers([symbol], this.extend(params, { 'callerMethodName': 'watchTicker' }));
|
|
1771
1774
|
return tickers[symbol];
|
|
1772
1775
|
}
|
|
1776
|
+
async watchMarkPrice(symbol, params = {}) {
|
|
1777
|
+
/**
|
|
1778
|
+
* @method
|
|
1779
|
+
* @name binance#watchMarkPrice
|
|
1780
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-market-streams/Mark-Price-Stream
|
|
1781
|
+
* @description watches a mark price for a specific market
|
|
1782
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1783
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1784
|
+
* @param {boolean} [params.use1sFreq] *default is true* if set to true, the mark price will be updated every second, otherwise every 3 seconds
|
|
1785
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1786
|
+
*/
|
|
1787
|
+
await this.loadMarkets();
|
|
1788
|
+
symbol = this.symbol(symbol);
|
|
1789
|
+
const tickers = await this.watchMarkPrices([symbol], this.extend(params, { 'callerMethodName': 'watchMarkPrice' }));
|
|
1790
|
+
return tickers[symbol];
|
|
1791
|
+
}
|
|
1792
|
+
async watchMarkPrices(symbols = undefined, params = {}) {
|
|
1793
|
+
/**
|
|
1794
|
+
* @method
|
|
1795
|
+
* @name binance#watchMarkPrices
|
|
1796
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-market-streams/Mark-Price-Stream-for-All-market
|
|
1797
|
+
* @description watches the mark price for all markets
|
|
1798
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
1799
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1800
|
+
* @param {boolean} [params.use1sFreq] *default is true* if set to true, the mark price will be updated every second, otherwise every 3 seconds
|
|
1801
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1802
|
+
*/
|
|
1803
|
+
let channelName = undefined;
|
|
1804
|
+
// for now watchmarkPrice uses the same messageHash as watchTicker
|
|
1805
|
+
// so it's impossible to watch both at the same time
|
|
1806
|
+
// refactor this to use different messageHashes
|
|
1807
|
+
[channelName, params] = this.handleOptionAndParams(params, 'watchMarkPrices', 'name', 'markPrice');
|
|
1808
|
+
const newTickers = await this.watchMultiTickerHelper('watchMarkPrices', channelName, symbols, params);
|
|
1809
|
+
if (this.newUpdates) {
|
|
1810
|
+
return newTickers;
|
|
1811
|
+
}
|
|
1812
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
1813
|
+
}
|
|
1773
1814
|
async watchTickers(symbols = undefined, params = {}) {
|
|
1774
1815
|
/**
|
|
1775
1816
|
* @method
|
|
@@ -1928,13 +1969,17 @@ export default class binance extends binanceRest {
|
|
|
1928
1969
|
async watchMultiTickerHelper(methodName, channelName, symbols = undefined, params = {}) {
|
|
1929
1970
|
await this.loadMarkets();
|
|
1930
1971
|
symbols = this.marketSymbols(symbols, undefined, true, false, true);
|
|
1972
|
+
const isBidAsk = (channelName === 'bookTicker');
|
|
1973
|
+
const isMarkPrice = (channelName === 'markPrice');
|
|
1974
|
+
const use1sFreq = this.safeBool(params, 'use1sFreq', true);
|
|
1931
1975
|
let firstMarket = undefined;
|
|
1932
1976
|
let marketType = undefined;
|
|
1933
1977
|
const symbolsDefined = (symbols !== undefined);
|
|
1934
1978
|
if (symbolsDefined) {
|
|
1935
1979
|
firstMarket = this.market(symbols[0]);
|
|
1936
1980
|
}
|
|
1937
|
-
|
|
1981
|
+
const defaultMarket = (isMarkPrice) ? 'swap' : 'spot';
|
|
1982
|
+
[marketType, params] = this.handleMarketTypeAndParams(methodName, firstMarket, params, defaultMarket);
|
|
1938
1983
|
let subType = undefined;
|
|
1939
1984
|
[subType, params] = this.handleSubTypeAndParams(methodName, firstMarket, params);
|
|
1940
1985
|
let rawMarketType = undefined;
|
|
@@ -1950,14 +1995,17 @@ export default class binance extends binanceRest {
|
|
|
1950
1995
|
else {
|
|
1951
1996
|
throw new NotSupported(this.id + ' ' + methodName + '() does not support options markets');
|
|
1952
1997
|
}
|
|
1953
|
-
const isBidAsk = (channelName === 'bookTicker');
|
|
1954
1998
|
const subscriptionArgs = [];
|
|
1955
1999
|
const messageHashes = [];
|
|
2000
|
+
let suffix = '';
|
|
2001
|
+
if (isMarkPrice) {
|
|
2002
|
+
suffix = (use1sFreq) ? '@1s' : '';
|
|
2003
|
+
}
|
|
1956
2004
|
if (symbolsDefined) {
|
|
1957
2005
|
for (let i = 0; i < symbols.length; i++) {
|
|
1958
2006
|
const symbol = symbols[i];
|
|
1959
2007
|
const market = this.market(symbol);
|
|
1960
|
-
subscriptionArgs.push(market['lowercaseId'] + '@' + channelName);
|
|
2008
|
+
subscriptionArgs.push(market['lowercaseId'] + '@' + channelName + suffix);
|
|
1961
2009
|
messageHashes.push(this.getMessageHash(channelName, market['symbol'], isBidAsk));
|
|
1962
2010
|
}
|
|
1963
2011
|
}
|
|
@@ -1968,6 +2016,9 @@ export default class binance extends binanceRest {
|
|
|
1968
2016
|
}
|
|
1969
2017
|
subscriptionArgs.push('!' + channelName);
|
|
1970
2018
|
}
|
|
2019
|
+
else if (isMarkPrice) {
|
|
2020
|
+
subscriptionArgs.push('!' + channelName + '@arr' + suffix);
|
|
2021
|
+
}
|
|
1971
2022
|
else {
|
|
1972
2023
|
subscriptionArgs.push('!' + channelName + '@arr');
|
|
1973
2024
|
}
|
|
@@ -2000,6 +2051,17 @@ export default class binance extends binanceRest {
|
|
|
2000
2051
|
}
|
|
2001
2052
|
}
|
|
2002
2053
|
parseWsTicker(message, marketType) {
|
|
2054
|
+
// markPrice
|
|
2055
|
+
// {
|
|
2056
|
+
// "e": "markPriceUpdate", // Event type
|
|
2057
|
+
// "E": 1562305380000, // Event time
|
|
2058
|
+
// "s": "BTCUSDT", // Symbol
|
|
2059
|
+
// "p": "11794.15000000", // Mark price
|
|
2060
|
+
// "i": "11784.62659091", // Index price
|
|
2061
|
+
// "P": "11784.25641265", // Estimated Settle Price, only useful in the last hour before the settlement starts
|
|
2062
|
+
// "r": "0.00038167", // Funding rate
|
|
2063
|
+
// "T": 1562306400000 // Next funding time
|
|
2064
|
+
// }
|
|
2003
2065
|
//
|
|
2004
2066
|
// ticker
|
|
2005
2067
|
// {
|
|
@@ -2057,10 +2119,23 @@ export default class binance extends binanceRest {
|
|
|
2057
2119
|
// "time":1589437530011,
|
|
2058
2120
|
// }
|
|
2059
2121
|
//
|
|
2122
|
+
const marketId = this.safeString2(message, 's', 'symbol');
|
|
2123
|
+
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
|
2060
2124
|
let event = this.safeString(message, 'e', 'bookTicker');
|
|
2061
2125
|
if (event === '24hrTicker') {
|
|
2062
2126
|
event = 'ticker';
|
|
2063
2127
|
}
|
|
2128
|
+
if (event === 'markPriceUpdate') {
|
|
2129
|
+
// handle this separately because some fields clash with the ticker fields
|
|
2130
|
+
return this.safeTicker({
|
|
2131
|
+
'symbol': symbol,
|
|
2132
|
+
'timestamp': this.safeInteger(message, 'E'),
|
|
2133
|
+
'datetime': this.iso8601(this.safeInteger(message, 'E')),
|
|
2134
|
+
'info': message,
|
|
2135
|
+
'markPrice': this.safeString(message, 'p'),
|
|
2136
|
+
'indexPrice': this.safeString(message, 'i'),
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2064
2139
|
let timestamp = undefined;
|
|
2065
2140
|
if (event === 'bookTicker') {
|
|
2066
2141
|
// take the event timestamp, if available, for spot tickers it is not
|
|
@@ -2070,8 +2145,6 @@ export default class binance extends binanceRest {
|
|
|
2070
2145
|
// take the timestamp of the closing price for candlestick streams
|
|
2071
2146
|
timestamp = this.safeIntegerN(message, ['C', 'E', 'time']);
|
|
2072
2147
|
}
|
|
2073
|
-
const marketId = this.safeString2(message, 's', 'symbol');
|
|
2074
|
-
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
|
2075
2148
|
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
2076
2149
|
const last = this.safeString2(message, 'c', 'price');
|
|
2077
2150
|
return this.safeTicker({
|
|
@@ -4240,6 +4313,8 @@ export default class binance extends binanceRest {
|
|
|
4240
4313
|
'1dTicker': this.handleTickers,
|
|
4241
4314
|
'24hrTicker': this.handleTickers,
|
|
4242
4315
|
'24hrMiniTicker': this.handleTickers,
|
|
4316
|
+
'markPriceUpdate': this.handleTickers,
|
|
4317
|
+
'markPriceUpdate@arr': this.handleTickers,
|
|
4243
4318
|
'bookTicker': this.handleBidsAsks,
|
|
4244
4319
|
'outboundAccountPosition': this.handleBalance,
|
|
4245
4320
|
'balanceUpdate': this.handleBalance,
|
package/js/src/pro/bitfinex.js
CHANGED
|
@@ -224,15 +224,15 @@ export default class bitfinex extends bitfinexRest {
|
|
|
224
224
|
if ((last !== undefined) && (change !== undefined)) {
|
|
225
225
|
open = Precise.stringSub(last, change);
|
|
226
226
|
}
|
|
227
|
-
const result = {
|
|
227
|
+
const result = this.safeTicker({
|
|
228
228
|
'symbol': symbol,
|
|
229
229
|
'timestamp': undefined,
|
|
230
230
|
'datetime': undefined,
|
|
231
|
-
'high': this.
|
|
232
|
-
'low': this.
|
|
233
|
-
'bid': this.
|
|
231
|
+
'high': this.safeString(message, 9),
|
|
232
|
+
'low': this.safeString(message, 10),
|
|
233
|
+
'bid': this.safeString(message, 1),
|
|
234
234
|
'bidVolume': undefined,
|
|
235
|
-
'ask': this.
|
|
235
|
+
'ask': this.safeString(message, 3),
|
|
236
236
|
'askVolume': undefined,
|
|
237
237
|
'vwap': undefined,
|
|
238
238
|
'open': this.parseNumber(open),
|
|
@@ -240,12 +240,12 @@ export default class bitfinex extends bitfinexRest {
|
|
|
240
240
|
'last': this.parseNumber(last),
|
|
241
241
|
'previousClose': undefined,
|
|
242
242
|
'change': this.parseNumber(change),
|
|
243
|
-
'percentage': this.
|
|
243
|
+
'percentage': this.safeString(message, 6),
|
|
244
244
|
'average': undefined,
|
|
245
|
-
'baseVolume': this.
|
|
245
|
+
'baseVolume': this.safeString(message, 8),
|
|
246
246
|
'quoteVolume': undefined,
|
|
247
247
|
'info': message,
|
|
248
|
-
};
|
|
248
|
+
});
|
|
249
249
|
this.tickers[symbol] = result;
|
|
250
250
|
client.resolve(result, messageHash);
|
|
251
251
|
}
|
|
@@ -1065,6 +1065,8 @@ export default class krakenfutures extends krakenfuturesRest {
|
|
|
1065
1065
|
'average': undefined,
|
|
1066
1066
|
'baseVolume': this.safeString(ticker, 'volume'),
|
|
1067
1067
|
'quoteVolume': this.safeString(ticker, 'volumeQuote'),
|
|
1068
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
1069
|
+
'indexPrice': this.safeString(ticker, 'index'),
|
|
1068
1070
|
});
|
|
1069
1071
|
}
|
|
1070
1072
|
handleOrderBookSnapshot(client, message) {
|
package/js/src/pro/phemex.js
CHANGED
|
@@ -134,6 +134,8 @@ export default class phemex extends phemexRest {
|
|
|
134
134
|
'average': average,
|
|
135
135
|
'baseVolume': baseVolume,
|
|
136
136
|
'quoteVolume': quoteVolume,
|
|
137
|
+
'markPrice': this.parseNumber(this.fromEp(this.safeString(ticker, 'markPrice'), market)),
|
|
138
|
+
'indexPrice': this.parseNumber(this.fromEp(this.safeString(ticker, 'indexPrice'), market)),
|
|
137
139
|
'info': ticker,
|
|
138
140
|
};
|
|
139
141
|
return result;
|
package/js/src/pro/woo.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export default class woo extends wooRest {
|
|
|
17
17
|
handleTicker(client: Client, message: any): any;
|
|
18
18
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
19
19
|
handleTickers(client: Client, message: any): void;
|
|
20
|
+
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
21
|
+
handleBidAsk(client: Client, message: any): void;
|
|
22
|
+
parseWsBidAsk(ticker: any, market?: any): Ticker;
|
|
20
23
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
21
24
|
handleOHLCV(client: Client, message: any): void;
|
|
22
25
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
package/js/src/pro/woo.js
CHANGED
|
@@ -23,6 +23,7 @@ export default class woo extends wooRest {
|
|
|
23
23
|
'watchOrders': true,
|
|
24
24
|
'watchTicker': true,
|
|
25
25
|
'watchTickers': true,
|
|
26
|
+
'watchBidsAsks': true,
|
|
26
27
|
'watchTrades': true,
|
|
27
28
|
'watchTradesForSymbols': false,
|
|
28
29
|
'watchPositions': true,
|
|
@@ -404,6 +405,77 @@ export default class woo extends wooRest {
|
|
|
404
405
|
}
|
|
405
406
|
client.resolve(result, topic);
|
|
406
407
|
}
|
|
408
|
+
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
409
|
+
/**
|
|
410
|
+
* @method
|
|
411
|
+
* @name woo#watchBidsAsks
|
|
412
|
+
* @see https://docs.woox.io/#bbos
|
|
413
|
+
* @description watches best bid & ask for symbols
|
|
414
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
415
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
416
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
417
|
+
*/
|
|
418
|
+
await this.loadMarkets();
|
|
419
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
420
|
+
const name = 'bbos';
|
|
421
|
+
const topic = name;
|
|
422
|
+
const request = {
|
|
423
|
+
'event': 'subscribe',
|
|
424
|
+
'topic': topic,
|
|
425
|
+
};
|
|
426
|
+
const message = this.extend(request, params);
|
|
427
|
+
const tickers = await this.watchPublic(topic, message);
|
|
428
|
+
if (this.newUpdates) {
|
|
429
|
+
return tickers;
|
|
430
|
+
}
|
|
431
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
432
|
+
}
|
|
433
|
+
handleBidAsk(client, message) {
|
|
434
|
+
//
|
|
435
|
+
// {
|
|
436
|
+
// "topic": "bbos",
|
|
437
|
+
// "ts": 1618822376000,
|
|
438
|
+
// "data": [
|
|
439
|
+
// {
|
|
440
|
+
// "symbol": "SPOT_FIL_USDT",
|
|
441
|
+
// "ask": 159.0318,
|
|
442
|
+
// "askSize": 370.43,
|
|
443
|
+
// "bid": 158.9158,
|
|
444
|
+
// "bidSize": 16
|
|
445
|
+
// }
|
|
446
|
+
// ]
|
|
447
|
+
// }
|
|
448
|
+
//
|
|
449
|
+
const topic = this.safeString(message, 'topic');
|
|
450
|
+
const data = this.safeList(message, 'data', []);
|
|
451
|
+
const timestamp = this.safeInteger(message, 'ts');
|
|
452
|
+
const result = {};
|
|
453
|
+
for (let i = 0; i < data.length; i++) {
|
|
454
|
+
const ticker = this.safeDict(data, i);
|
|
455
|
+
ticker['ts'] = timestamp;
|
|
456
|
+
const parsedTicker = this.parseWsBidAsk(ticker);
|
|
457
|
+
const symbol = parsedTicker['symbol'];
|
|
458
|
+
this.bidsasks[symbol] = parsedTicker;
|
|
459
|
+
result[symbol] = parsedTicker;
|
|
460
|
+
}
|
|
461
|
+
client.resolve(result, topic);
|
|
462
|
+
}
|
|
463
|
+
parseWsBidAsk(ticker, market = undefined) {
|
|
464
|
+
const marketId = this.safeString(ticker, 'symbol');
|
|
465
|
+
market = this.safeMarket(marketId, market);
|
|
466
|
+
const symbol = this.safeString(market, 'symbol');
|
|
467
|
+
const timestamp = this.safeInteger(ticker, 'ts');
|
|
468
|
+
return this.safeTicker({
|
|
469
|
+
'symbol': symbol,
|
|
470
|
+
'timestamp': timestamp,
|
|
471
|
+
'datetime': this.iso8601(timestamp),
|
|
472
|
+
'ask': this.safeString(ticker, 'ask'),
|
|
473
|
+
'askVolume': this.safeString(ticker, 'askSize'),
|
|
474
|
+
'bid': this.safeString(ticker, 'bid'),
|
|
475
|
+
'bidVolume': this.safeString(ticker, 'bidSize'),
|
|
476
|
+
'info': ticker,
|
|
477
|
+
}, market);
|
|
478
|
+
}
|
|
407
479
|
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
408
480
|
/**
|
|
409
481
|
* @method
|
|
@@ -1184,6 +1256,7 @@ export default class woo extends wooRest {
|
|
|
1184
1256
|
'trade': this.handleTrade,
|
|
1185
1257
|
'balance': this.handleBalance,
|
|
1186
1258
|
'position': this.handlePositions,
|
|
1259
|
+
'bbos': this.handleBidAsk,
|
|
1187
1260
|
};
|
|
1188
1261
|
const event = this.safeString(message, 'event');
|
|
1189
1262
|
let method = this.safeValue(methods, event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccxt",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.13",
|
|
4
4
|
"description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
|
|
5
5
|
"unpkg": "dist/ccxt.browser.min.js",
|
|
6
6
|
"type": "module",
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"as-table": "1.0.37",
|
|
164
164
|
"asciichart": "^1.5.25",
|
|
165
165
|
"assert": "^2.0.0",
|
|
166
|
-
"ast-transpiler": "^0.0.
|
|
166
|
+
"ast-transpiler": "^0.0.56",
|
|
167
167
|
"docsify": "^4.11.4",
|
|
168
168
|
"eslint": "8.22.0",
|
|
169
169
|
"eslint-config-airbnb-base": "15.0.0",
|