ccxt 4.2.58 → 4.2.59
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/CHANGELOG.md +83 -0
- package/README.md +3 -3
- package/cleanup.sh +3 -0
- package/dist/ccxt.browser.js +311 -218
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +2 -0
- package/dist/cjs/src/binance.js +2 -2
- package/dist/cjs/src/bingx.js +3 -3
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/bitmex.js +1 -1
- package/dist/cjs/src/blofin.js +1 -1
- package/dist/cjs/src/coinbase.js +24 -14
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/mexc.js +1 -1
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/bitfinex2.js +1 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +51 -89
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coinex.js +1 -1
- package/dist/cjs/src/pro/cryptocom.js +1 -1
- package/dist/cjs/src/pro/deribit.js +201 -84
- package/dist/cjs/src/pro/gate.js +1 -1
- package/dist/cjs/src/pro/independentreserve.js +1 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/mexc.js +5 -3
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/woo.js +1 -1
- package/dist/cjs/src/woo.js +2 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.js +2 -0
- package/js/src/binance.js +2 -2
- package/js/src/bingx.js +3 -3
- package/js/src/bitget.js +1 -1
- package/js/src/bitmex.js +1 -1
- package/js/src/blofin.js +1 -1
- package/js/src/coinbase.js +24 -14
- package/js/src/lbank.js +1 -1
- package/js/src/mexc.js +1 -1
- package/js/src/okx.js +1 -1
- package/js/src/phemex.js +1 -1
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/bitfinex2.js +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.d.ts +2 -2
- package/js/src/pro/bitmart.js +51 -89
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coinex.js +1 -1
- package/js/src/pro/cryptocom.js +1 -1
- package/js/src/pro/deribit.d.ts +5 -0
- package/js/src/pro/deribit.js +202 -85
- package/js/src/pro/gate.js +1 -1
- package/js/src/pro/independentreserve.js +1 -1
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/kucoinfutures.js +1 -1
- package/js/src/pro/mexc.js +6 -4
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/woo.js +1 -1
- package/js/src/woo.js +2 -2
- package/package.json +1 -1
- package/skip-tests.json +2 -2
package/js/src/coinbase.js
CHANGED
|
@@ -3068,10 +3068,12 @@ export default class coinbase extends Exchange {
|
|
|
3068
3068
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
3069
3069
|
*/
|
|
3070
3070
|
await this.loadMarkets();
|
|
3071
|
+
const maxLimit = 300;
|
|
3072
|
+
limit = (limit === undefined) ? maxLimit : Math.min(limit, maxLimit);
|
|
3071
3073
|
let paginate = false;
|
|
3072
3074
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
|
|
3073
3075
|
if (paginate) {
|
|
3074
|
-
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params,
|
|
3076
|
+
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimit - 1);
|
|
3075
3077
|
}
|
|
3076
3078
|
const market = this.market(symbol);
|
|
3077
3079
|
const request = {
|
|
@@ -3081,20 +3083,20 @@ export default class coinbase extends Exchange {
|
|
|
3081
3083
|
const until = this.safeValueN(params, ['until', 'till', 'end']);
|
|
3082
3084
|
params = this.omit(params, ['until', 'till']);
|
|
3083
3085
|
const duration = this.parseTimeframe(timeframe);
|
|
3084
|
-
const
|
|
3086
|
+
const requestedDuration = limit * duration;
|
|
3085
3087
|
let sinceString = undefined;
|
|
3086
3088
|
if (since !== undefined) {
|
|
3087
3089
|
sinceString = this.numberToString(this.parseToInt(since / 1000));
|
|
3088
3090
|
}
|
|
3089
3091
|
else {
|
|
3090
3092
|
const now = this.seconds().toString();
|
|
3091
|
-
sinceString = Precise.stringSub(now,
|
|
3093
|
+
sinceString = Precise.stringSub(now, requestedDuration.toString());
|
|
3092
3094
|
}
|
|
3093
3095
|
request['start'] = sinceString;
|
|
3094
3096
|
let endString = this.numberToString(until);
|
|
3095
3097
|
if (until === undefined) {
|
|
3096
3098
|
// 300 candles max
|
|
3097
|
-
endString = Precise.stringAdd(sinceString,
|
|
3099
|
+
endString = Precise.stringAdd(sinceString, requestedDuration.toString());
|
|
3098
3100
|
}
|
|
3099
3101
|
request['end'] = endString;
|
|
3100
3102
|
const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
|
|
@@ -3154,8 +3156,19 @@ export default class coinbase extends Exchange {
|
|
|
3154
3156
|
const request = {
|
|
3155
3157
|
'product_id': market['id'],
|
|
3156
3158
|
};
|
|
3159
|
+
if (since !== undefined) {
|
|
3160
|
+
request['start'] = this.numberToString(this.parseToInt(since / 1000));
|
|
3161
|
+
}
|
|
3157
3162
|
if (limit !== undefined) {
|
|
3158
|
-
request['limit'] = limit;
|
|
3163
|
+
request['limit'] = Math.min(limit, 1000);
|
|
3164
|
+
}
|
|
3165
|
+
let until = undefined;
|
|
3166
|
+
[until, params] = this.handleOptionAndParams(params, 'fetchTrades', 'until');
|
|
3167
|
+
if (until !== undefined) {
|
|
3168
|
+
request['end'] = this.numberToString(this.parseToInt(until / 1000));
|
|
3169
|
+
}
|
|
3170
|
+
else if (since !== undefined) {
|
|
3171
|
+
throw new ArgumentsRequired(this.id + ' fetchTrades() requires a `until` parameter when you use `since` argument');
|
|
3159
3172
|
}
|
|
3160
3173
|
const response = await this.v3PrivateGetBrokerageProductsProductIdTicker(this.extend(request, params));
|
|
3161
3174
|
//
|
|
@@ -3289,7 +3302,7 @@ export default class coinbase extends Exchange {
|
|
|
3289
3302
|
// }
|
|
3290
3303
|
// }
|
|
3291
3304
|
//
|
|
3292
|
-
const data = this.
|
|
3305
|
+
const data = this.safeDict(response, 'pricebook', {});
|
|
3293
3306
|
const time = this.safeString(data, 'time');
|
|
3294
3307
|
const timestamp = this.parse8601(time);
|
|
3295
3308
|
return this.parseOrderBook(data, symbol, timestamp, 'bids', 'asks', 'price', 'size');
|
|
@@ -3742,7 +3755,7 @@ export default class coinbase extends Exchange {
|
|
|
3742
3755
|
}
|
|
3743
3756
|
else {
|
|
3744
3757
|
this.checkRequiredCredentials();
|
|
3745
|
-
const
|
|
3758
|
+
const timestampString = this.seconds().toString();
|
|
3746
3759
|
let payload = '';
|
|
3747
3760
|
if (method !== 'GET') {
|
|
3748
3761
|
if (Object.keys(query).length) {
|
|
@@ -3750,17 +3763,14 @@ export default class coinbase extends Exchange {
|
|
|
3750
3763
|
payload = body;
|
|
3751
3764
|
}
|
|
3752
3765
|
}
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
}
|
|
3757
|
-
}
|
|
3758
|
-
const auth = nonce + method + savedPath + payload;
|
|
3766
|
+
// 'GET' doesn't need payload in the signature. inside url is enough
|
|
3767
|
+
// https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
|
|
3768
|
+
const auth = timestampString + method + savedPath + payload;
|
|
3759
3769
|
const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
|
|
3760
3770
|
headers = {
|
|
3761
3771
|
'CB-ACCESS-KEY': this.apiKey,
|
|
3762
3772
|
'CB-ACCESS-SIGN': signature,
|
|
3763
|
-
'CB-ACCESS-TIMESTAMP':
|
|
3773
|
+
'CB-ACCESS-TIMESTAMP': timestampString,
|
|
3764
3774
|
'Content-Type': 'application/json',
|
|
3765
3775
|
};
|
|
3766
3776
|
}
|
package/js/src/lbank.js
CHANGED
|
@@ -2694,7 +2694,7 @@ export default class lbank extends Exchange {
|
|
|
2694
2694
|
const uppercaseHash = hash.toUpperCase();
|
|
2695
2695
|
let sign = undefined;
|
|
2696
2696
|
if (signatureMethod === 'RSA') {
|
|
2697
|
-
const cacheSecretAsPem = this.
|
|
2697
|
+
const cacheSecretAsPem = this.safeBool(this.options, 'cacheSecretAsPem', true);
|
|
2698
2698
|
let pem = undefined;
|
|
2699
2699
|
if (cacheSecretAsPem) {
|
|
2700
2700
|
pem = this.safeValue(this.options, 'pem');
|
package/js/src/mexc.js
CHANGED
|
@@ -5500,7 +5500,7 @@ export default class mexc extends Exchange {
|
|
|
5500
5500
|
'source': this.safeString(this.options, 'broker', 'CCXT'),
|
|
5501
5501
|
};
|
|
5502
5502
|
}
|
|
5503
|
-
if ((method === 'POST') || (method === 'PUT')) {
|
|
5503
|
+
if ((method === 'POST') || (method === 'PUT') || (method === 'DELETE')) {
|
|
5504
5504
|
headers['Content-Type'] = 'application/json';
|
|
5505
5505
|
}
|
|
5506
5506
|
}
|
package/js/src/okx.js
CHANGED
|
@@ -1560,7 +1560,7 @@ export default class okx extends Exchange {
|
|
|
1560
1560
|
// while fetchCurrencies is a public API method by design
|
|
1561
1561
|
// therefore we check the keys here
|
|
1562
1562
|
// and fallback to generating the currencies from the markets
|
|
1563
|
-
const isSandboxMode = this.
|
|
1563
|
+
const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
1564
1564
|
if (!this.checkRequiredCredentials(false) || isSandboxMode) {
|
|
1565
1565
|
return undefined;
|
|
1566
1566
|
}
|
package/js/src/phemex.js
CHANGED
|
@@ -2422,7 +2422,7 @@ export default class phemex extends Exchange {
|
|
|
2422
2422
|
}
|
|
2423
2423
|
parseOrder(order, market = undefined) {
|
|
2424
2424
|
const isSwap = this.safeBool(market, 'swap', false);
|
|
2425
|
-
const hasPnl = ('closedPnl' in order);
|
|
2425
|
+
const hasPnl = ('closedPnl' in order) || ('closedPnlRv' in order) || ('totalPnlRv' in order);
|
|
2426
2426
|
if (isSwap || hasPnl) {
|
|
2427
2427
|
return this.parseSwapOrder(order, market);
|
|
2428
2428
|
}
|
package/js/src/pro/binance.js
CHANGED
|
@@ -2468,7 +2468,7 @@ export default class binance extends binanceRest {
|
|
|
2468
2468
|
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
2469
2469
|
this.setPositionsCache(client, type, symbols, isPortfolioMargin);
|
|
2470
2470
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
2471
|
-
const awaitPositionsSnapshot = this.
|
|
2471
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
2472
2472
|
const cache = this.safeValue(this.positions, type);
|
|
2473
2473
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
|
|
2474
2474
|
const snapshot = await client.future(type + ':fetchPositionsSnapshot');
|
package/js/src/pro/bitfinex2.js
CHANGED
|
@@ -56,7 +56,7 @@ export default class bitfinex2 extends bitfinex2Rest {
|
|
|
56
56
|
'symbol': marketId,
|
|
57
57
|
};
|
|
58
58
|
const result = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash, { 'checksum': false });
|
|
59
|
-
const checksum = this.
|
|
59
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
60
60
|
if (checksum && !client.subscriptions[messageHash]['checksum'] && (channel === 'book')) {
|
|
61
61
|
client.subscriptions[messageHash]['checksum'] = true;
|
|
62
62
|
await client.send({
|
package/js/src/pro/bitget.js
CHANGED
|
@@ -539,7 +539,7 @@ export default class bitget extends bitgetRest {
|
|
|
539
539
|
this.handleDeltas(storedOrderBook['bids'], bids);
|
|
540
540
|
storedOrderBook['timestamp'] = timestamp;
|
|
541
541
|
storedOrderBook['datetime'] = this.iso8601(timestamp);
|
|
542
|
-
const checksum = this.
|
|
542
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
543
543
|
const isSnapshot = this.safeString(message, 'action') === 'snapshot'; // snapshot does not have a checksum
|
|
544
544
|
if (!isSnapshot && checksum) {
|
|
545
545
|
const storedAsks = storedOrderBook['asks'];
|
package/js/src/pro/bitmart.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import Client from '../base/ws/Client.js';
|
|
|
4
4
|
export default class bitmart extends bitmartRest {
|
|
5
5
|
describe(): any;
|
|
6
6
|
subscribe(channel: any, symbol: any, type: any, params?: {}): Promise<any>;
|
|
7
|
-
subscribeMultiple(channel: string, type: string, symbols
|
|
7
|
+
subscribeMultiple(channel: string, type: string, symbols?: Strings, params?: {}): Promise<any>;
|
|
8
8
|
watchBalance(params?: {}): Promise<Balances>;
|
|
9
9
|
setBalanceCache(client: Client, type: any, subscribeHash: any): void;
|
|
10
10
|
loadBalanceSnapshot(client: any, messageHash: any, type: any): Promise<void>;
|
|
@@ -23,9 +23,9 @@ export default class bitmart extends bitmartRest {
|
|
|
23
23
|
handlePositions(client: Client, message: any): void;
|
|
24
24
|
parseWsPosition(position: any, market?: Market): Position;
|
|
25
25
|
handleTrade(client: Client, message: any): void;
|
|
26
|
+
handleTradeLoop(entry: any): string;
|
|
26
27
|
parseWsTrade(trade: any, market?: Market): Trade;
|
|
27
28
|
handleTicker(client: Client, message: any): void;
|
|
28
|
-
resolveMessageHashesForSymbol(client: any, symbol: any, result: any, prexif: any): void;
|
|
29
29
|
parseWsSwapTicker(ticker: any, market?: Market): Ticker;
|
|
30
30
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
31
31
|
handleOHLCV(client: Client, message: any): void;
|
package/js/src/pro/bitmart.js
CHANGED
|
@@ -110,11 +110,12 @@ export default class bitmart extends bitmartRest {
|
|
|
110
110
|
}
|
|
111
111
|
return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
112
112
|
}
|
|
113
|
-
async subscribeMultiple(channel, type, symbols, params = {}) {
|
|
113
|
+
async subscribeMultiple(channel, type, symbols = undefined, params = {}) {
|
|
114
|
+
symbols = this.marketSymbols(symbols, type, false, true);
|
|
114
115
|
const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
|
|
115
116
|
const channelType = (type === 'spot') ? 'spot' : 'futures';
|
|
116
117
|
const actionType = (type === 'spot') ? 'op' : 'action';
|
|
117
|
-
|
|
118
|
+
let rawSubscriptions = [];
|
|
118
119
|
const messageHashes = [];
|
|
119
120
|
for (let i = 0; i < symbols.length; i++) {
|
|
120
121
|
const market = this.market(symbols[i]);
|
|
@@ -122,6 +123,10 @@ export default class bitmart extends bitmartRest {
|
|
|
122
123
|
rawSubscriptions.push(message);
|
|
123
124
|
messageHashes.push(channel + ':' + market['symbol']);
|
|
124
125
|
}
|
|
126
|
+
// as an exclusion, futures "tickers" need one generic request for all symbols
|
|
127
|
+
if ((type !== 'spot') && (channel === 'ticker')) {
|
|
128
|
+
rawSubscriptions = [channelType + '/' + channel];
|
|
129
|
+
}
|
|
125
130
|
const request = {
|
|
126
131
|
'args': rawSubscriptions,
|
|
127
132
|
};
|
|
@@ -324,13 +329,8 @@ export default class bitmart extends bitmartRest {
|
|
|
324
329
|
*/
|
|
325
330
|
await this.loadMarkets();
|
|
326
331
|
symbol = this.symbol(symbol);
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
[type, params] = this.handleMarketTypeAndParams('watchTicker', market, params);
|
|
330
|
-
if (type === 'swap') {
|
|
331
|
-
throw new NotSupported(this.id + ' watchTicker() does not support ' + type + ' markets. Use watchTickers() instead');
|
|
332
|
-
}
|
|
333
|
-
return await this.subscribe('ticker', symbol, type, params);
|
|
332
|
+
const tickers = await this.watchTickers([symbol], params);
|
|
333
|
+
return tickers[symbol];
|
|
334
334
|
}
|
|
335
335
|
async watchTickers(symbols = undefined, params = {}) {
|
|
336
336
|
/**
|
|
@@ -344,40 +344,12 @@ export default class bitmart extends bitmartRest {
|
|
|
344
344
|
*/
|
|
345
345
|
await this.loadMarkets();
|
|
346
346
|
const market = this.getMarketFromSymbols(symbols);
|
|
347
|
-
let
|
|
348
|
-
[
|
|
349
|
-
const
|
|
350
|
-
symbols = this.marketSymbols(symbols);
|
|
351
|
-
let messageHash = 'tickers::' + type;
|
|
352
|
-
if (symbols !== undefined) {
|
|
353
|
-
messageHash += '::' + symbols.join(',');
|
|
354
|
-
}
|
|
355
|
-
let request = undefined;
|
|
356
|
-
let tickers = undefined;
|
|
357
|
-
const isSpot = (type === 'spot');
|
|
358
|
-
if (isSpot) {
|
|
359
|
-
if (symbols === undefined) {
|
|
360
|
-
throw new ArgumentsRequired(this.id + ' watchTickers() for ' + type + ' market type requires symbols argument to be provided');
|
|
361
|
-
}
|
|
362
|
-
const marketIds = this.marketIds(symbols);
|
|
363
|
-
const finalArray = [];
|
|
364
|
-
for (let i = 0; i < marketIds.length; i++) {
|
|
365
|
-
finalArray.push('spot/ticker:' + marketIds[i]);
|
|
366
|
-
}
|
|
367
|
-
request = {
|
|
368
|
-
'op': 'subscribe',
|
|
369
|
-
'args': finalArray,
|
|
370
|
-
};
|
|
371
|
-
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
374
|
-
request = {
|
|
375
|
-
'action': 'subscribe',
|
|
376
|
-
'args': ['futures/ticker'],
|
|
377
|
-
};
|
|
378
|
-
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
379
|
-
}
|
|
347
|
+
let marketType = undefined;
|
|
348
|
+
[marketType, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
|
|
349
|
+
const ticker = await this.subscribeMultiple('ticker', marketType, symbols, params);
|
|
380
350
|
if (this.newUpdates) {
|
|
351
|
+
const tickers = {};
|
|
352
|
+
tickers[ticker['symbol']] = ticker;
|
|
381
353
|
return tickers;
|
|
382
354
|
}
|
|
383
355
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
@@ -853,21 +825,34 @@ export default class bitmart extends bitmartRest {
|
|
|
853
825
|
if (data === undefined) {
|
|
854
826
|
return;
|
|
855
827
|
}
|
|
856
|
-
let stored = undefined;
|
|
857
828
|
let symbol = undefined;
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
829
|
+
const length = data.length;
|
|
830
|
+
const isSwap = ('group' in message);
|
|
831
|
+
if (isSwap) {
|
|
832
|
+
// in swap, chronologically decreasing: 1709536849322, 1709536848954,
|
|
833
|
+
const maxLen = Math.max(length - 1, 0);
|
|
834
|
+
for (let i = maxLen; i >= 0; i--) {
|
|
835
|
+
symbol = this.handleTradeLoop(data[i]);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
// in spot, chronologically increasing: 1709536771200, 1709536771226,
|
|
840
|
+
for (let i = 0; i < length; i++) {
|
|
841
|
+
symbol = this.handleTradeLoop(data[i]);
|
|
866
842
|
}
|
|
867
|
-
stored.append(trade);
|
|
868
843
|
}
|
|
869
|
-
|
|
870
|
-
|
|
844
|
+
client.resolve(this.trades[symbol], 'trade:' + symbol);
|
|
845
|
+
}
|
|
846
|
+
handleTradeLoop(entry) {
|
|
847
|
+
const trade = this.parseWsTrade(entry);
|
|
848
|
+
const symbol = trade['symbol'];
|
|
849
|
+
const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
850
|
+
if (this.safeValue(this.trades, symbol) === undefined) {
|
|
851
|
+
this.trades[symbol] = new ArrayCache(tradesLimit);
|
|
852
|
+
}
|
|
853
|
+
const stored = this.trades[symbol];
|
|
854
|
+
stored.append(trade);
|
|
855
|
+
return symbol;
|
|
871
856
|
}
|
|
872
857
|
parseWsTrade(trade, market = undefined) {
|
|
873
858
|
// spot
|
|
@@ -946,45 +931,22 @@ export default class bitmart extends bitmartRest {
|
|
|
946
931
|
//
|
|
947
932
|
const table = this.safeString(message, 'table');
|
|
948
933
|
const isSpot = (table !== undefined);
|
|
949
|
-
|
|
950
|
-
if (data === undefined) {
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
934
|
+
let rawTickers = [];
|
|
953
935
|
if (isSpot) {
|
|
954
|
-
|
|
955
|
-
const ticker = this.parseTicker(data[i]);
|
|
956
|
-
const symbol = ticker['symbol'];
|
|
957
|
-
const marketId = this.safeString(ticker['info'], 'symbol');
|
|
958
|
-
const messageHash = table + ':' + marketId;
|
|
959
|
-
this.tickers[symbol] = ticker;
|
|
960
|
-
client.resolve(ticker, messageHash);
|
|
961
|
-
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
962
|
-
}
|
|
936
|
+
rawTickers = this.safeList(message, 'data', []);
|
|
963
937
|
}
|
|
964
938
|
else {
|
|
965
|
-
|
|
966
|
-
const ticker = this.parseWsSwapTicker(data);
|
|
967
|
-
const symbol = this.safeString(ticker, 'symbol');
|
|
968
|
-
this.tickers[symbol] = ticker;
|
|
969
|
-
client.resolve(ticker, 'tickers::swap');
|
|
970
|
-
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
939
|
+
rawTickers = [this.safeValue(message, 'data', {})];
|
|
971
940
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
const symbolsString = parts[length - 1];
|
|
982
|
-
const symbols = symbolsString.split(symbolsSeparator);
|
|
983
|
-
if (this.inArray(symbol, symbols)) {
|
|
984
|
-
const response = {};
|
|
985
|
-
response[symbol] = result;
|
|
986
|
-
client.resolve(response, messageHash);
|
|
987
|
-
}
|
|
941
|
+
if (!rawTickers.length) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
for (let i = 0; i < rawTickers.length; i++) {
|
|
945
|
+
const ticker = isSpot ? this.parseTicker(rawTickers[i]) : this.parseWsSwapTicker(rawTickers[i]);
|
|
946
|
+
const symbol = ticker['symbol'];
|
|
947
|
+
this.tickers[symbol] = ticker;
|
|
948
|
+
const messageHash = 'ticker:' + symbol;
|
|
949
|
+
client.resolve(ticker, messageHash);
|
|
988
950
|
}
|
|
989
951
|
}
|
|
990
952
|
parseWsSwapTicker(ticker, market = undefined) {
|
package/js/src/pro/bitvavo.js
CHANGED
|
@@ -1087,7 +1087,7 @@ export default class bitvavo extends bitvavoRest {
|
|
|
1087
1087
|
return messageHash;
|
|
1088
1088
|
}
|
|
1089
1089
|
checkMessageHashDoesNotExist(messageHash) {
|
|
1090
|
-
const supressMultipleWsRequestsError = this.
|
|
1090
|
+
const supressMultipleWsRequestsError = this.safeBool(this.options, 'supressMultipleWsRequestsError', false);
|
|
1091
1091
|
if (!supressMultipleWsRequestsError) {
|
|
1092
1092
|
const client = this.safeValue(this.clients, this.urls['api']['ws']);
|
|
1093
1093
|
if (client !== undefined) {
|
package/js/src/pro/bybit.js
CHANGED
|
@@ -942,7 +942,7 @@ export default class bybit extends bybitRest {
|
|
|
942
942
|
this.setPositionsCache(client, symbols);
|
|
943
943
|
const cache = this.positions;
|
|
944
944
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
945
|
-
const awaitPositionsSnapshot = this.
|
|
945
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
946
946
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
|
|
947
947
|
const snapshot = await client.future('fetchPositionsSnapshot');
|
|
948
948
|
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
package/js/src/pro/coinex.js
CHANGED
|
@@ -549,7 +549,7 @@ export default class coinex extends coinexRest {
|
|
|
549
549
|
}
|
|
550
550
|
const url = this.urls['api']['ws'][type];
|
|
551
551
|
const messageHash = 'ohlcv';
|
|
552
|
-
const watchOHLCVWarning = this.
|
|
552
|
+
const watchOHLCVWarning = this.safeBool(this.options, 'watchOHLCVWarning', true);
|
|
553
553
|
const client = this.safeValue(this.clients, url, {});
|
|
554
554
|
const clientSub = this.safeValue(client, 'subscriptions', {});
|
|
555
555
|
const existingSubscription = this.safeValue(clientSub, messageHash);
|
package/js/src/pro/cryptocom.js
CHANGED
|
@@ -556,7 +556,7 @@ export default class cryptocom extends cryptocomRest {
|
|
|
556
556
|
const client = this.client(url);
|
|
557
557
|
this.setPositionsCache(client, symbols);
|
|
558
558
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
559
|
-
const awaitPositionsSnapshot = this.
|
|
559
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
560
560
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
|
|
561
561
|
const snapshot = await client.future('fetchPositionsSnapshot');
|
|
562
562
|
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
package/js/src/pro/deribit.d.ts
CHANGED
|
@@ -9,10 +9,12 @@ export default class deribit extends deribitRest {
|
|
|
9
9
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
10
10
|
handleTicker(client: Client, message: any): void;
|
|
11
11
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
12
|
+
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
12
13
|
handleTrades(client: Client, message: any): void;
|
|
13
14
|
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
14
15
|
handleMyTrades(client: Client, message: any): void;
|
|
15
16
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
17
|
+
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
16
18
|
handleOrderBook(client: Client, message: any): void;
|
|
17
19
|
cleanOrderBook(data: any): any;
|
|
18
20
|
handleDelta(bookside: any, delta: any): void;
|
|
@@ -20,7 +22,10 @@ export default class deribit extends deribitRest {
|
|
|
20
22
|
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
21
23
|
handleOrders(client: Client, message: any): void;
|
|
22
24
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
25
|
+
watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").Dictionary<OHLCV[]>>>;
|
|
23
26
|
handleOHLCV(client: Client, message: any): void;
|
|
27
|
+
parseWsOHLCV(ohlcv: any, market?: any): OHLCV;
|
|
28
|
+
watchMultipleWrapper(channelName: string, channelDescriptor: string, symbolsArray?: any, params?: {}): Promise<any>;
|
|
24
29
|
handleMessage(client: Client, message: any): void;
|
|
25
30
|
handleAuthenticationMessage(client: Client, message: any): any;
|
|
26
31
|
authenticate(params?: {}): Promise<any>;
|