ccxt 4.2.9 → 4.2.10
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.js +267 -143
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +37 -8
- package/dist/cjs/src/binance.js +6 -1
- package/dist/cjs/src/bl3p.js +1 -1
- package/dist/cjs/src/btcalpha.js +1 -1
- package/dist/cjs/src/cryptocom.js +3 -1
- package/dist/cjs/src/deribit.js +39 -22
- package/dist/cjs/src/kraken.js +1 -1
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/lykke.js +1 -1
- package/dist/cjs/src/ndax.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +49 -27
- package/dist/cjs/src/pro/blockchaincom.js +2 -28
- package/dist/cjs/src/pro/coinbasepro.js +9 -16
- package/dist/cjs/src/pro/cryptocom.js +110 -28
- package/dist/cjs/src/pro/luno.js +5 -5
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +4 -3
- package/js/src/base/Exchange.js +37 -8
- package/js/src/binance.js +6 -1
- package/js/src/bl3p.d.ts +2 -2
- package/js/src/bl3p.js +1 -1
- package/js/src/btcalpha.d.ts +2 -2
- package/js/src/btcalpha.js +1 -1
- package/js/src/cryptocom.js +3 -1
- package/js/src/deribit.js +39 -22
- package/js/src/kraken.d.ts +2 -2
- package/js/src/kraken.js +1 -1
- package/js/src/kucoin.js +1 -1
- package/js/src/lykke.d.ts +2 -2
- package/js/src/lykke.js +1 -1
- package/js/src/ndax.d.ts +2 -2
- package/js/src/ndax.js +1 -1
- package/js/src/pro/bitmart.d.ts +1 -0
- package/js/src/pro/bitmart.js +49 -27
- package/js/src/pro/blockchaincom.d.ts +1 -11
- package/js/src/pro/blockchaincom.js +2 -28
- package/js/src/pro/coinbasepro.js +9 -16
- package/js/src/pro/cryptocom.d.ts +3 -1
- package/js/src/pro/cryptocom.js +111 -29
- package/js/src/pro/luno.d.ts +4 -4
- package/js/src/pro/luno.js +5 -5
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -169,7 +169,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
169
169
|
|
|
170
170
|
//-----------------------------------------------------------------------------
|
|
171
171
|
// this is updated by vss.js when building
|
|
172
|
-
const version = '4.2.
|
|
172
|
+
const version = '4.2.10';
|
|
173
173
|
Exchange["default"].ccxtVersion = version;
|
|
174
174
|
const exchanges = {
|
|
175
175
|
'ace': ace,
|
|
@@ -2862,11 +2862,11 @@ class Exchange {
|
|
|
2862
2862
|
}
|
|
2863
2863
|
return result;
|
|
2864
2864
|
}
|
|
2865
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
|
|
2865
|
+
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
2866
2866
|
bidasks = this.toArray(bidasks);
|
|
2867
2867
|
const result = [];
|
|
2868
2868
|
for (let i = 0; i < bidasks.length; i++) {
|
|
2869
|
-
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey));
|
|
2869
|
+
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey, countOrIdKey));
|
|
2870
2870
|
}
|
|
2871
2871
|
return result;
|
|
2872
2872
|
}
|
|
@@ -3035,9 +3035,9 @@ class Exchange {
|
|
|
3035
3035
|
const value = this.safeString2(dictionary, key1, key2);
|
|
3036
3036
|
return this.parseNumber(value, d);
|
|
3037
3037
|
}
|
|
3038
|
-
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1) {
|
|
3039
|
-
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey);
|
|
3040
|
-
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey);
|
|
3038
|
+
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3039
|
+
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countOrIdKey);
|
|
3040
|
+
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey, countOrIdKey);
|
|
3041
3041
|
return {
|
|
3042
3042
|
'symbol': symbol,
|
|
3043
3043
|
'bids': this.sortBy(bids, 0, true),
|
|
@@ -3352,10 +3352,15 @@ class Exchange {
|
|
|
3352
3352
|
async fetchBidsAsks(symbols = undefined, params = {}) {
|
|
3353
3353
|
throw new errors.NotSupported(this.id + ' fetchBidsAsks() is not supported yet');
|
|
3354
3354
|
}
|
|
3355
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
3355
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3356
3356
|
const price = this.safeNumber(bidask, priceKey);
|
|
3357
3357
|
const amount = this.safeNumber(bidask, amountKey);
|
|
3358
|
-
|
|
3358
|
+
const countOrId = this.safeInteger(bidask, countOrIdKey);
|
|
3359
|
+
const bidAsk = [price, amount];
|
|
3360
|
+
if (countOrId !== undefined) {
|
|
3361
|
+
bidAsk.push(countOrId);
|
|
3362
|
+
}
|
|
3363
|
+
return bidAsk;
|
|
3359
3364
|
}
|
|
3360
3365
|
safeCurrency(currencyId, currency = undefined) {
|
|
3361
3366
|
if ((currencyId === undefined) && (currency !== undefined)) {
|
|
@@ -3403,7 +3408,7 @@ class Exchange {
|
|
|
3403
3408
|
}
|
|
3404
3409
|
}
|
|
3405
3410
|
}
|
|
3406
|
-
else if (delimiter !== undefined) {
|
|
3411
|
+
else if (delimiter !== undefined && delimiter !== '') {
|
|
3407
3412
|
const parts = marketId.split(delimiter);
|
|
3408
3413
|
const partsLength = parts.length;
|
|
3409
3414
|
if (partsLength === 2) {
|
|
@@ -3564,6 +3569,30 @@ class Exchange {
|
|
|
3564
3569
|
}
|
|
3565
3570
|
return [value, params];
|
|
3566
3571
|
}
|
|
3572
|
+
handleOptionAndParams2(params, methodName, methodName2, optionName, defaultValue = undefined) {
|
|
3573
|
+
// This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
|
|
3574
|
+
const defaultOptionName = 'default' + this.capitalize(optionName); // we also need to check the 'defaultXyzWhatever'
|
|
3575
|
+
// check if params contain the key
|
|
3576
|
+
let value = this.safeValue2(params, optionName, defaultOptionName);
|
|
3577
|
+
if (value !== undefined) {
|
|
3578
|
+
params = this.omit(params, [optionName, defaultOptionName]);
|
|
3579
|
+
}
|
|
3580
|
+
else {
|
|
3581
|
+
// check if exchange has properties for this method
|
|
3582
|
+
const exchangeWideMethodOptions = this.safeValue2(this.options, methodName, methodName2);
|
|
3583
|
+
if (exchangeWideMethodOptions !== undefined) {
|
|
3584
|
+
// check if the option is defined inside this method's props
|
|
3585
|
+
value = this.safeValue2(exchangeWideMethodOptions, optionName, defaultOptionName);
|
|
3586
|
+
}
|
|
3587
|
+
if (value === undefined) {
|
|
3588
|
+
// if it's still undefined, check if global exchange-wide option exists
|
|
3589
|
+
value = this.safeValue2(this.options, optionName, defaultOptionName);
|
|
3590
|
+
}
|
|
3591
|
+
// if it's still undefined, use the default value
|
|
3592
|
+
value = (value !== undefined) ? value : defaultValue;
|
|
3593
|
+
}
|
|
3594
|
+
return [value, params];
|
|
3595
|
+
}
|
|
3567
3596
|
handleOption(methodName, optionName, defaultValue = undefined) {
|
|
3568
3597
|
// eslint-disable-next-line no-unused-vars
|
|
3569
3598
|
const [result, empty] = this.handleOptionAndParams({}, methodName, optionName, defaultValue);
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -3145,7 +3145,12 @@ class binance extends binance$1 {
|
|
|
3145
3145
|
response = await this.dapiPublicGetTickerBookTicker(params);
|
|
3146
3146
|
}
|
|
3147
3147
|
else {
|
|
3148
|
-
|
|
3148
|
+
const request = {};
|
|
3149
|
+
if (symbols !== undefined) {
|
|
3150
|
+
const marketIds = this.marketIds(symbols);
|
|
3151
|
+
request['symbols'] = this.json(marketIds);
|
|
3152
|
+
}
|
|
3153
|
+
response = await this.publicGetTickerBookTicker(this.extend(request, params));
|
|
3149
3154
|
}
|
|
3150
3155
|
return this.parseTickers(response, symbols);
|
|
3151
3156
|
}
|
package/dist/cjs/src/bl3p.js
CHANGED
|
@@ -146,7 +146,7 @@ class bl3p extends bl3p$1 {
|
|
|
146
146
|
const response = await this.privatePostGENMKTMoneyInfo(params);
|
|
147
147
|
return this.parseBalance(response);
|
|
148
148
|
}
|
|
149
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
149
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
150
150
|
const price = this.safeString(bidask, priceKey);
|
|
151
151
|
const size = this.safeString(bidask, amountKey);
|
|
152
152
|
return [
|
package/dist/cjs/src/btcalpha.js
CHANGED
|
@@ -359,7 +359,7 @@ class btcalpha extends btcalpha$1 {
|
|
|
359
359
|
const response = await this.publicGetOrderbookPairName(this.extend(request, params));
|
|
360
360
|
return this.parseOrderBook(response, market['symbol'], undefined, 'buy', 'sell', 'price', 'amount');
|
|
361
361
|
}
|
|
362
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
|
|
362
|
+
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
363
363
|
const result = [];
|
|
364
364
|
for (let i = 0; i < bidasks.length; i++) {
|
|
365
365
|
const bidask = bidasks[i];
|
|
@@ -770,6 +770,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
770
770
|
// "p": "26386.00",
|
|
771
771
|
// "q": "0.00453",
|
|
772
772
|
// "t": 1686944282062,
|
|
773
|
+
// "tn" : 1704476468851524373,
|
|
773
774
|
// "d": "4611686018455979970",
|
|
774
775
|
// "i": "BTC_USD"
|
|
775
776
|
// },
|
|
@@ -1940,7 +1941,8 @@ class cryptocom extends cryptocom$1 {
|
|
|
1940
1941
|
// "s": "sell",
|
|
1941
1942
|
// "p": "26386.00",
|
|
1942
1943
|
// "q": "0.00453",
|
|
1943
|
-
// "
|
|
1944
|
+
// "tn": 1686944282062,
|
|
1945
|
+
// "tn": 1704476468851524373,
|
|
1944
1946
|
// "d": "4611686018455979970",
|
|
1945
1947
|
// "i": "BTC_USD"
|
|
1946
1948
|
// }
|
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -1723,27 +1723,18 @@ class deribit extends deribit$1 {
|
|
|
1723
1723
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
1724
1724
|
* @param {string} type 'market' or 'limit'
|
|
1725
1725
|
* @param {string} side 'buy' or 'sell'
|
|
1726
|
-
* @param {float} amount how much
|
|
1726
|
+
* @param {float} amount how much you want to trade in units of the base currency. For inverse perpetual and futures the amount is in the quote currency USD. For options it is in the underlying assets base currency.
|
|
1727
1727
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1728
1728
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1729
|
+
* @param {string} [params.trigger] the trigger type 'index_price', 'mark_price', or 'last_price', default is 'last_price'
|
|
1730
|
+
* @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
1729
1731
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1730
1732
|
*/
|
|
1731
1733
|
await this.loadMarkets();
|
|
1732
1734
|
const market = this.market(symbol);
|
|
1733
|
-
if (market['inverse']) {
|
|
1734
|
-
amount = this.amountToPrecision(symbol, amount);
|
|
1735
|
-
}
|
|
1736
|
-
else if (market['settle'] === 'USDC') {
|
|
1737
|
-
amount = this.amountToPrecision(symbol, amount);
|
|
1738
|
-
}
|
|
1739
|
-
else {
|
|
1740
|
-
amount = this.currencyToPrecision(symbol, amount);
|
|
1741
|
-
}
|
|
1742
1735
|
const request = {
|
|
1743
1736
|
'instrument_name': market['id'],
|
|
1744
|
-
|
|
1745
|
-
// for options it is in corresponding cryptocurrency contracts, e.g., BTC or ETH
|
|
1746
|
-
'amount': amount,
|
|
1737
|
+
'amount': this.amountToPrecision(symbol, amount),
|
|
1747
1738
|
'type': type, // limit, stop_limit, market, stop_market, default is limit
|
|
1748
1739
|
// 'label': 'string', // user-defined label for the order (maximum 64 characters)
|
|
1749
1740
|
// 'price': this.priceToPrecision (symbol, 123.45), // only for limit and stop_limit orders
|
|
@@ -1756,12 +1747,15 @@ class deribit extends deribit$1 {
|
|
|
1756
1747
|
// 'trigger': 'index_price', // mark_price, last_price, required for stop_limit orders
|
|
1757
1748
|
// 'advanced': 'usd', // 'implv', advanced option order type, options only
|
|
1758
1749
|
};
|
|
1750
|
+
const trigger = this.safeString(params, 'trigger', 'last_price');
|
|
1759
1751
|
const timeInForce = this.safeStringUpper(params, 'timeInForce');
|
|
1760
1752
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
1761
1753
|
// only stop loss sell orders are allowed when price crossed from above
|
|
1762
1754
|
const stopLossPrice = this.safeValue(params, 'stopLossPrice');
|
|
1763
1755
|
// only take profit buy orders are allowed when price crossed from below
|
|
1764
1756
|
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
|
|
1757
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
|
|
1758
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1765
1759
|
const isStopLimit = type === 'stop_limit';
|
|
1766
1760
|
const isStopMarket = type === 'stop_market';
|
|
1767
1761
|
const isTakeLimit = type === 'take_limit';
|
|
@@ -1783,10 +1777,15 @@ class deribit extends deribit$1 {
|
|
|
1783
1777
|
else {
|
|
1784
1778
|
request['type'] = 'market';
|
|
1785
1779
|
}
|
|
1786
|
-
if (
|
|
1780
|
+
if (isTrailingAmountOrder) {
|
|
1781
|
+
request['trigger'] = trigger;
|
|
1782
|
+
request['type'] = 'trailing_stop';
|
|
1783
|
+
request['trigger_offset'] = this.parseToNumeric(trailingAmount);
|
|
1784
|
+
}
|
|
1785
|
+
else if (isStopOrder) {
|
|
1787
1786
|
const triggerPrice = (stopLossPrice !== undefined) ? stopLossPrice : takeProfitPrice;
|
|
1788
1787
|
request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
|
|
1789
|
-
request['trigger'] =
|
|
1788
|
+
request['trigger'] = trigger;
|
|
1790
1789
|
if (isStopLossOrder) {
|
|
1791
1790
|
if (isMarketOrder) {
|
|
1792
1791
|
// stop_market (sell only)
|
|
@@ -1826,7 +1825,7 @@ class deribit extends deribit$1 {
|
|
|
1826
1825
|
request['time_in_force'] = 'fill_or_kill';
|
|
1827
1826
|
}
|
|
1828
1827
|
}
|
|
1829
|
-
params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly']);
|
|
1828
|
+
params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly', 'trailingAmount']);
|
|
1830
1829
|
let response = undefined;
|
|
1831
1830
|
if (this.capitalize(side) === 'Buy') {
|
|
1832
1831
|
response = await this.privateGetBuy(this.extend(request, params));
|
|
@@ -1893,25 +1892,43 @@ class deribit extends deribit$1 {
|
|
|
1893
1892
|
return this.parseOrder(order, market);
|
|
1894
1893
|
}
|
|
1895
1894
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
1895
|
+
/**
|
|
1896
|
+
* @method
|
|
1897
|
+
* @name deribit#editOrder
|
|
1898
|
+
* @description edit a trade order
|
|
1899
|
+
* @see https://docs.deribit.com/#private-edit
|
|
1900
|
+
* @param {string} id edit order id
|
|
1901
|
+
* @param {string} [symbol] unified symbol of the market to edit an order in
|
|
1902
|
+
* @param {string} [type] 'market' or 'limit'
|
|
1903
|
+
* @param {string} [side] 'buy' or 'sell'
|
|
1904
|
+
* @param {float} amount how much you want to trade in units of the base currency, inverse swap and future use the quote currency
|
|
1905
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
|
|
1906
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1907
|
+
* @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
1908
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1909
|
+
*/
|
|
1896
1910
|
if (amount === undefined) {
|
|
1897
1911
|
throw new errors.ArgumentsRequired(this.id + ' editOrder() requires an amount argument');
|
|
1898
1912
|
}
|
|
1899
|
-
if (price === undefined) {
|
|
1900
|
-
throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a price argument');
|
|
1901
|
-
}
|
|
1902
1913
|
await this.loadMarkets();
|
|
1903
1914
|
const request = {
|
|
1904
1915
|
'order_id': id,
|
|
1905
|
-
// for perpetual and futures the amount is in USD
|
|
1906
|
-
// for options it is in corresponding cryptocurrency contracts, e.g., BTC or ETH
|
|
1907
1916
|
'amount': this.amountToPrecision(symbol, amount),
|
|
1908
|
-
'price': this.priceToPrecision(symbol, price), // required
|
|
1909
1917
|
// 'post_only': false, // if the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below the spread.
|
|
1910
1918
|
// 'reject_post_only': false, // if true the order is put to order book unmodified or request is rejected
|
|
1911
1919
|
// 'reduce_only': false, // if true, the order is intended to only reduce a current position
|
|
1912
1920
|
// 'stop_price': false, // stop price, required for stop_limit orders
|
|
1913
1921
|
// 'advanced': 'usd', // 'implv', advanced option order type, options only
|
|
1914
1922
|
};
|
|
1923
|
+
if (price !== undefined) {
|
|
1924
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1925
|
+
}
|
|
1926
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
|
|
1927
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1928
|
+
if (isTrailingAmountOrder) {
|
|
1929
|
+
request['trigger_offset'] = this.parseToNumeric(trailingAmount);
|
|
1930
|
+
params = this.omit(params, 'trigger_offset');
|
|
1931
|
+
}
|
|
1915
1932
|
const response = await this.privateGetEdit(this.extend(request, params));
|
|
1916
1933
|
const result = this.safeValue(response, 'result', {});
|
|
1917
1934
|
const order = this.safeValue(result, 'order');
|
package/dist/cjs/src/kraken.js
CHANGED
|
@@ -751,7 +751,7 @@ class kraken extends kraken$1 {
|
|
|
751
751
|
'tierBased': true,
|
|
752
752
|
};
|
|
753
753
|
}
|
|
754
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
754
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
755
755
|
const price = this.safeNumber(bidask, priceKey);
|
|
756
756
|
const amount = this.safeNumber(bidask, amountKey);
|
|
757
757
|
const timestamp = this.safeInteger(bidask, 2);
|
package/dist/cjs/src/kucoin.js
CHANGED
|
@@ -2419,7 +2419,7 @@ class kucoin extends kucoin$1 {
|
|
|
2419
2419
|
// }
|
|
2420
2420
|
// }
|
|
2421
2421
|
const responseData = this.safeValue(response, 'data', {});
|
|
2422
|
-
const orders = this.safeValue(responseData, 'items',
|
|
2422
|
+
const orders = this.safeValue(responseData, 'items', responseData);
|
|
2423
2423
|
return this.parseOrders(orders, market, since, limit);
|
|
2424
2424
|
}
|
|
2425
2425
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
package/dist/cjs/src/lykke.js
CHANGED
|
@@ -1078,7 +1078,7 @@ class lykke extends lykke$1 {
|
|
|
1078
1078
|
//
|
|
1079
1079
|
return this.parseTrades(payload, market, since, limit);
|
|
1080
1080
|
}
|
|
1081
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
1081
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
1082
1082
|
const price = this.safeString(bidask, priceKey);
|
|
1083
1083
|
const amount = Precise["default"].stringAbs(this.safeString(bidask, amountKey));
|
|
1084
1084
|
return [this.parseNumber(price), this.parseNumber(amount)];
|
package/dist/cjs/src/ndax.js
CHANGED
|
@@ -518,7 +518,7 @@ class ndax extends ndax$1 {
|
|
|
518
518
|
'info': market,
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
|
-
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8) {
|
|
521
|
+
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8, countOrIdKey = 2) {
|
|
522
522
|
let nonce = undefined;
|
|
523
523
|
const result = {
|
|
524
524
|
'symbol': symbol,
|
|
@@ -290,25 +290,39 @@ class bitmart extends bitmart$1 {
|
|
|
290
290
|
const market = this.getMarketFromSymbols(symbols);
|
|
291
291
|
let type = 'spot';
|
|
292
292
|
[type, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
|
|
293
|
-
symbols = this.marketSymbols(symbols);
|
|
294
|
-
if (type === 'spot') {
|
|
295
|
-
throw new errors.NotSupported(this.id + ' watchTickers() does not support ' + type + ' markets. Use watchTicker() instead');
|
|
296
|
-
}
|
|
297
293
|
const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
let messageHash = 'tickers';
|
|
294
|
+
symbols = this.marketSymbols(symbols);
|
|
295
|
+
let messageHash = 'tickers::' + type;
|
|
302
296
|
if (symbols !== undefined) {
|
|
303
297
|
messageHash += '::' + symbols.join(',');
|
|
304
298
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
299
|
+
let request = undefined;
|
|
300
|
+
let tickers = undefined;
|
|
301
|
+
const isSpot = (type === 'spot');
|
|
302
|
+
if (isSpot) {
|
|
303
|
+
if (symbols === undefined) {
|
|
304
|
+
throw new errors.ArgumentsRequired(this.id + ' watchTickers() for ' + type + ' market type requires symbols argument to be provided');
|
|
305
|
+
}
|
|
306
|
+
const marketIds = this.marketIds(symbols);
|
|
307
|
+
const finalArray = [];
|
|
308
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
309
|
+
finalArray.push('spot/ticker:' + marketIds[i]);
|
|
310
|
+
}
|
|
311
|
+
request = {
|
|
312
|
+
'op': 'subscribe',
|
|
313
|
+
'args': finalArray,
|
|
314
|
+
};
|
|
315
|
+
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
request = {
|
|
319
|
+
'action': 'subscribe',
|
|
320
|
+
'args': ['futures/ticker'],
|
|
321
|
+
};
|
|
322
|
+
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
323
|
+
}
|
|
310
324
|
if (this.newUpdates) {
|
|
311
|
-
return
|
|
325
|
+
return tickers;
|
|
312
326
|
}
|
|
313
327
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
314
328
|
}
|
|
@@ -893,28 +907,36 @@ class bitmart extends bitmart$1 {
|
|
|
893
907
|
const messageHash = table + ':' + marketId;
|
|
894
908
|
this.tickers[symbol] = ticker;
|
|
895
909
|
client.resolve(ticker, messageHash);
|
|
910
|
+
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
896
911
|
}
|
|
897
912
|
}
|
|
898
913
|
else {
|
|
914
|
+
// on each update for contract markets, single ticker is provided
|
|
899
915
|
const ticker = this.parseWsSwapTicker(data);
|
|
900
916
|
const symbol = this.safeString(ticker, 'symbol');
|
|
901
917
|
this.tickers[symbol] = ticker;
|
|
902
|
-
client.resolve(ticker, 'tickers');
|
|
903
|
-
|
|
904
|
-
for (let i = 0; i < messageHashes.length; i++) {
|
|
905
|
-
const messageHash = messageHashes[i];
|
|
906
|
-
const parts = messageHash.split('::');
|
|
907
|
-
const symbolsString = parts[1];
|
|
908
|
-
const symbols = symbolsString.split(',');
|
|
909
|
-
if (this.inArray(symbol, symbols)) {
|
|
910
|
-
const response = {};
|
|
911
|
-
response[symbol] = ticker;
|
|
912
|
-
client.resolve(response, messageHash);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
918
|
+
client.resolve(ticker, 'tickers::swap');
|
|
919
|
+
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
915
920
|
}
|
|
916
921
|
return message;
|
|
917
922
|
}
|
|
923
|
+
resolveMessageHashesForSymbol(client, symbol, result, prexif) {
|
|
924
|
+
const prefixSeparator = '::';
|
|
925
|
+
const symbolsSeparator = ',';
|
|
926
|
+
const messageHashes = this.findMessageHashes(client, prexif);
|
|
927
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
928
|
+
const messageHash = messageHashes[i];
|
|
929
|
+
const parts = messageHash.split(prefixSeparator);
|
|
930
|
+
const length = parts.length;
|
|
931
|
+
const symbolsString = parts[length - 1];
|
|
932
|
+
const symbols = symbolsString.split(symbolsSeparator);
|
|
933
|
+
if (this.inArray(symbol, symbols)) {
|
|
934
|
+
const response = {};
|
|
935
|
+
response[symbol] = result;
|
|
936
|
+
client.resolve(response, messageHash);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
918
940
|
parseWsSwapTicker(ticker, market = undefined) {
|
|
919
941
|
//
|
|
920
942
|
// {
|
|
@@ -695,7 +695,7 @@ class blockchaincom extends blockchaincom$1 {
|
|
|
695
695
|
return message;
|
|
696
696
|
}
|
|
697
697
|
else if (event === 'snapshot') {
|
|
698
|
-
const snapshot = this.
|
|
698
|
+
const snapshot = this.parseOrderBook(message, symbol, timestamp, 'bids', 'asks', 'px', 'qty', 'num');
|
|
699
699
|
storedOrderBook.reset(snapshot);
|
|
700
700
|
}
|
|
701
701
|
else if (event === 'updated') {
|
|
@@ -711,34 +711,8 @@ class blockchaincom extends blockchaincom$1 {
|
|
|
711
711
|
}
|
|
712
712
|
client.resolve(storedOrderBook, messageHash);
|
|
713
713
|
}
|
|
714
|
-
parseCountedBidAsk(bidAsk, priceKey = 0, amountKey = 1, countKey = 2) {
|
|
715
|
-
const price = this.safeNumber(bidAsk, priceKey);
|
|
716
|
-
const amount = this.safeNumber(bidAsk, amountKey);
|
|
717
|
-
const count = this.safeNumber(bidAsk, countKey);
|
|
718
|
-
return [price, amount, count];
|
|
719
|
-
}
|
|
720
|
-
parseCountedBidsAsks(bidasks, priceKey = 0, amountKey = 1, countKey = 2) {
|
|
721
|
-
bidasks = this.toArray(bidasks);
|
|
722
|
-
const result = [];
|
|
723
|
-
for (let i = 0; i < bidasks.length; i++) {
|
|
724
|
-
result.push(this.parseCountedBidAsk(bidasks[i], priceKey, amountKey, countKey));
|
|
725
|
-
}
|
|
726
|
-
return result;
|
|
727
|
-
}
|
|
728
|
-
parseCountedOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, countKey = 2) {
|
|
729
|
-
const bids = this.parseCountedBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countKey);
|
|
730
|
-
const asks = this.parseCountedBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey, countKey);
|
|
731
|
-
return {
|
|
732
|
-
'symbol': symbol,
|
|
733
|
-
'bids': this.sortBy(bids, 0, true),
|
|
734
|
-
'asks': this.sortBy(asks, 0),
|
|
735
|
-
'timestamp': timestamp,
|
|
736
|
-
'datetime': this.iso8601(timestamp),
|
|
737
|
-
'nonce': undefined,
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
714
|
handleDelta(bookside, delta) {
|
|
741
|
-
const bookArray = this.
|
|
715
|
+
const bookArray = this.parseBidAsk(delta, 'px', 'qty', 'num');
|
|
742
716
|
bookside.storeArray(bookArray);
|
|
743
717
|
}
|
|
744
718
|
handleDeltas(bookside, deltas) {
|
|
@@ -89,7 +89,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
89
89
|
const symbol = symbols[i];
|
|
90
90
|
market = this.market(symbol);
|
|
91
91
|
productIds.push(market['id']);
|
|
92
|
-
messageHashes.push(messageHashStart + ':' + market['
|
|
92
|
+
messageHashes.push(messageHashStart + ':' + market['symbol']);
|
|
93
93
|
}
|
|
94
94
|
let url = this.urls['api']['ws'];
|
|
95
95
|
if ('signature' in params) {
|
|
@@ -134,10 +134,12 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
134
134
|
throw new errors.BadSymbol(this.id + ' watchTickers requires a non-empty symbols array');
|
|
135
135
|
}
|
|
136
136
|
const channel = 'ticker';
|
|
137
|
-
const messageHash = '
|
|
138
|
-
const
|
|
137
|
+
const messageHash = 'ticker';
|
|
138
|
+
const ticker = await this.subscribeMultiple(channel, symbols, messageHash, params);
|
|
139
139
|
if (this.newUpdates) {
|
|
140
|
-
|
|
140
|
+
const result = {};
|
|
141
|
+
result[ticker['symbol']] = ticker;
|
|
142
|
+
return result;
|
|
141
143
|
}
|
|
142
144
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
143
145
|
}
|
|
@@ -749,19 +751,10 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
749
751
|
const ticker = this.parseTicker(message);
|
|
750
752
|
const symbol = ticker['symbol'];
|
|
751
753
|
this.tickers[symbol] = ticker;
|
|
752
|
-
const
|
|
753
|
-
const
|
|
754
|
+
const messageHash = 'ticker:' + symbol;
|
|
755
|
+
const idMessageHash = 'ticker:' + marketId;
|
|
754
756
|
client.resolve(ticker, messageHash);
|
|
755
|
-
|
|
756
|
-
for (let i = 0; i < messageHashes.length; i++) {
|
|
757
|
-
const currentMessageHash = messageHashes[i];
|
|
758
|
-
const parts = currentMessageHash.split('::');
|
|
759
|
-
const symbolsString = parts[1];
|
|
760
|
-
const symbols = symbolsString.split(',');
|
|
761
|
-
if (this.inArray(symbol, symbols)) {
|
|
762
|
-
client.resolve(ticker, currentMessageHash);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
757
|
+
client.resolve(ticker, idMessageHash);
|
|
765
758
|
}
|
|
766
759
|
return message;
|
|
767
760
|
}
|