ccxt 4.3.69 → 4.3.70
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 +4 -4
- package/dist/ccxt.browser.min.js +5 -5
- package/dist/cjs/ccxt.js +3 -1
- package/dist/cjs/src/ascendex.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/blofin.js +63 -6
- package/dist/cjs/src/bybit.js +1 -1
- package/dist/cjs/src/coinbaseinternational.js +168 -2
- package/dist/cjs/src/cryptocom.js +9 -1
- package/dist/cjs/src/hitbtc.js +1 -1
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/blofin.js +665 -0
- package/dist/cjs/src/pro/coinbaseinternational.js +154 -9
- package/dist/cjs/src/pro/cryptocom.js +3 -1
- package/dist/cjs/src/pro/hitbtc.js +26 -8
- package/dist/cjs/src/pro/okx.js +7 -0
- package/dist/cjs/src/pro/poloniex.js +37 -12
- package/dist/cjs/src/pro/woo.js +5 -4
- package/js/ccxt.d.ts +4 -1
- package/js/ccxt.js +3 -1
- package/js/src/abstract/coinbaseinternational.d.ts +1 -1
- package/js/src/ascendex.js +1 -1
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +6 -0
- package/js/src/binance.js +1 -1
- package/js/src/blofin.d.ts +1 -1
- package/js/src/blofin.js +63 -6
- package/js/src/bybit.js +1 -1
- package/js/src/coinbaseinternational.d.ts +6 -1
- package/js/src/coinbaseinternational.js +168 -2
- package/js/src/cryptocom.js +10 -2
- package/js/src/hitbtc.js +1 -1
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/blofin.d.ts +39 -0
- package/js/src/pro/blofin.js +668 -0
- package/js/src/pro/coinbaseinternational.d.ts +5 -1
- package/js/src/pro/coinbaseinternational.js +155 -10
- package/js/src/pro/cryptocom.js +4 -2
- package/js/src/pro/hitbtc.d.ts +1 -1
- package/js/src/pro/hitbtc.js +26 -8
- package/js/src/pro/okx.js +7 -0
- package/js/src/pro/poloniex.js +37 -12
- package/js/src/pro/woo.js +5 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import coinbaseinternationalRest from '../coinbaseinternational.js';
|
|
2
|
-
import { Ticker, Int, Trade, OrderBook, Market, Dict, Strings, FundingRate, FundingRates } from '../base/types.js';
|
|
2
|
+
import { Ticker, Int, Trade, OrderBook, Market, Dict, Strings, FundingRate, FundingRates, Tickers, OHLCV } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
5
5
|
describe(): any;
|
|
@@ -8,10 +8,14 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
8
8
|
watchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
|
|
9
9
|
watchFundingRates(symbols: string[], params?: {}): Promise<FundingRates>;
|
|
10
10
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
11
|
+
getActiveSymbols(): any[];
|
|
12
|
+
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
11
13
|
handleInstrument(client: Client, message: any): void;
|
|
12
14
|
parseWsInstrument(ticker: Dict, market?: any): Ticker;
|
|
13
15
|
handleTicker(client: Client, message: any): void;
|
|
14
16
|
parseWsTicker(ticker: object, market?: Market): Ticker;
|
|
17
|
+
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
18
|
+
handleOHLCV(client: Client, message: any): void;
|
|
15
19
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
16
20
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
17
21
|
handleTrade(client: any, message: any): any;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import coinbaseinternationalRest from '../coinbaseinternational.js';
|
|
9
9
|
import { AuthenticationError, ExchangeError, NotSupported } from '../base/errors.js';
|
|
10
10
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
11
|
-
import { ArrayCache } from '../base/ws/Cache.js';
|
|
11
|
+
import { ArrayCache, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
14
14
|
describe() {
|
|
@@ -22,12 +22,12 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
22
22
|
'watchTicker': true,
|
|
23
23
|
'watchBalance': false,
|
|
24
24
|
'watchMyTrades': false,
|
|
25
|
-
'watchOHLCV':
|
|
25
|
+
'watchOHLCV': true,
|
|
26
26
|
'watchOHLCVForSymbols': false,
|
|
27
27
|
'watchOrders': false,
|
|
28
28
|
'watchOrdersForSymbols': false,
|
|
29
29
|
'watchPositions': false,
|
|
30
|
-
'watchTickers':
|
|
30
|
+
'watchTickers': true,
|
|
31
31
|
'createOrderWs': false,
|
|
32
32
|
'editOrderWs': false,
|
|
33
33
|
'cancelOrderWs': false,
|
|
@@ -53,6 +53,14 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
53
53
|
'tradesLimit': 1000,
|
|
54
54
|
'ordersLimit': 1000,
|
|
55
55
|
'myTradesLimit': 1000,
|
|
56
|
+
'timeframes': {
|
|
57
|
+
'1m': 'CANDLES_ONE_MINUTE',
|
|
58
|
+
'5m': 'CANDLES_FIVE_MINUTES',
|
|
59
|
+
'30m': 'CANDLES_THIRTY_MINUTES',
|
|
60
|
+
'1h': 'CANDLES_ONE_HOUR',
|
|
61
|
+
'2h': 'CANDLES_TWO_HOURS',
|
|
62
|
+
'1d': 'CANDLES_ONE_DAY',
|
|
63
|
+
},
|
|
56
64
|
},
|
|
57
65
|
'exceptions': {
|
|
58
66
|
'exact': {
|
|
@@ -76,16 +84,20 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
76
84
|
this.checkRequiredCredentials();
|
|
77
85
|
let market = undefined;
|
|
78
86
|
let messageHash = name;
|
|
79
|
-
let productIds =
|
|
87
|
+
let productIds = undefined;
|
|
80
88
|
if (symbols === undefined) {
|
|
81
|
-
symbols = this.
|
|
89
|
+
symbols = this.getActiveSymbols();
|
|
82
90
|
}
|
|
83
91
|
const symbolsLength = symbols.length;
|
|
92
|
+
const messageHashes = [];
|
|
84
93
|
if (symbolsLength > 1) {
|
|
85
94
|
const parsedSymbols = this.marketSymbols(symbols);
|
|
86
95
|
const marketIds = this.marketIds(parsedSymbols);
|
|
87
96
|
productIds = marketIds;
|
|
88
|
-
|
|
97
|
+
for (let i = 0; i < parsedSymbols.length; i++) {
|
|
98
|
+
messageHashes.push(name + '::' + parsedSymbols[i]);
|
|
99
|
+
}
|
|
100
|
+
// messageHash = messageHash + '::' + parsedSymbols.join (',');
|
|
89
101
|
}
|
|
90
102
|
else if (symbolsLength === 1) {
|
|
91
103
|
market = this.market(symbols[0]);
|
|
@@ -101,13 +113,19 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
101
113
|
const signature = this.hmac(this.encode(auth), this.base64ToBinary(this.secret), sha256, 'base64');
|
|
102
114
|
const subscribe = {
|
|
103
115
|
'type': 'SUBSCRIBE',
|
|
104
|
-
'product_ids': productIds,
|
|
116
|
+
// 'product_ids': productIds,
|
|
105
117
|
'channels': [name],
|
|
106
118
|
'time': timestamp,
|
|
107
119
|
'key': this.apiKey,
|
|
108
120
|
'passphrase': this.password,
|
|
109
121
|
'signature': signature,
|
|
110
122
|
};
|
|
123
|
+
if (productIds !== undefined) {
|
|
124
|
+
subscribe['product_ids'] = productIds;
|
|
125
|
+
}
|
|
126
|
+
if (symbolsLength > 1) {
|
|
127
|
+
return await this.watchMultiple(url, messageHashes, this.extend(subscribe, params), messageHashes);
|
|
128
|
+
}
|
|
111
129
|
return await this.watch(url, messageHash, this.extend(subscribe, params), messageHash);
|
|
112
130
|
}
|
|
113
131
|
async subscribeMultiple(name, symbols = undefined, params = {}) {
|
|
@@ -196,6 +214,7 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
196
214
|
* @see https://docs.cloud.coinbase.com/intx/docs/websocket-channels#instruments-channel
|
|
197
215
|
* @param {string} [symbol] unified symbol of the market to fetch the ticker for
|
|
198
216
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
217
|
+
* @param {string} [params.channel] the channel to watch, 'LEVEL1' or 'INSTRUMENTS', default is 'LEVEL1'
|
|
199
218
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
200
219
|
*/
|
|
201
220
|
await this.loadMarkets();
|
|
@@ -203,6 +222,40 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
203
222
|
[channel, params] = this.handleOptionAndParams(params, 'watchTicker', 'channel', 'LEVEL1');
|
|
204
223
|
return await this.subscribe(channel, [symbol], params);
|
|
205
224
|
}
|
|
225
|
+
getActiveSymbols() {
|
|
226
|
+
const symbols = this.symbols;
|
|
227
|
+
const output = [];
|
|
228
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
229
|
+
const symbol = symbols[i];
|
|
230
|
+
const market = this.markets[symbol];
|
|
231
|
+
if (market['active']) {
|
|
232
|
+
output.push(symbol);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return output;
|
|
236
|
+
}
|
|
237
|
+
async watchTickers(symbols = undefined, params = {}) {
|
|
238
|
+
/**
|
|
239
|
+
* @method
|
|
240
|
+
* @name coinbaseinternational#watchTickers
|
|
241
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
242
|
+
* @see https://docs.cloud.coinbase.com/intx/docs/websocket-channels#instruments-channel
|
|
243
|
+
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
244
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
245
|
+
* @param {string} [params.channel] the channel to watch, 'LEVEL1' or 'INSTRUMENTS', default is 'INSTLEVEL1UMENTS'
|
|
246
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
247
|
+
*/
|
|
248
|
+
await this.loadMarkets();
|
|
249
|
+
let channel = undefined;
|
|
250
|
+
[channel, params] = this.handleOptionAndParams(params, 'watchTickers', 'channel', 'LEVEL1');
|
|
251
|
+
const ticker = await this.subscribe(channel, symbols, params);
|
|
252
|
+
if (this.newUpdates) {
|
|
253
|
+
const result = {};
|
|
254
|
+
result[ticker['symbol']] = ticker;
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
258
|
+
}
|
|
206
259
|
handleInstrument(client, message) {
|
|
207
260
|
//
|
|
208
261
|
// {
|
|
@@ -260,6 +313,33 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
260
313
|
// "channel":"INSTRUMENTS",
|
|
261
314
|
// "type":"SNAPSHOT"
|
|
262
315
|
// }
|
|
316
|
+
// instruments
|
|
317
|
+
// {
|
|
318
|
+
// sequence: 0,
|
|
319
|
+
// instrument_type: 'PERP',
|
|
320
|
+
// instrument_mode: 'standard',
|
|
321
|
+
// base_asset_name: 'BTC',
|
|
322
|
+
// quote_asset_name: 'USDC',
|
|
323
|
+
// base_increment: '0.0001',
|
|
324
|
+
// quote_increment: '0.1',
|
|
325
|
+
// avg_daily_quantity: '502.8845',
|
|
326
|
+
// avg_daily_volume: '3.1495242961566668E7',
|
|
327
|
+
// total30_day_quantity: '15086.535',
|
|
328
|
+
// total30_day_volume: '9.44857288847E8',
|
|
329
|
+
// total24_hour_quantity: '5.0',
|
|
330
|
+
// total24_hour_volume: '337016.5',
|
|
331
|
+
// base_imf: '0.1',
|
|
332
|
+
// min_quantity: '0.0001',
|
|
333
|
+
// position_size_limit: '800',
|
|
334
|
+
// funding_interval: '3600000000000',
|
|
335
|
+
// trading_state: 'trading',
|
|
336
|
+
// last_updated_time: '2024-07-30T15:00:00Z',
|
|
337
|
+
// default_initial_margin: '0.2',
|
|
338
|
+
// base_asset_multiplier: '1.0',
|
|
339
|
+
// channel: 'INSTRUMENTS',
|
|
340
|
+
// type: 'SNAPSHOT',
|
|
341
|
+
// time: '2024-07-30T15:26:56.766Z',
|
|
342
|
+
// }
|
|
263
343
|
//
|
|
264
344
|
const marketId = this.safeString(ticker, 'product_id');
|
|
265
345
|
const datetime = this.safeString(ticker, 'time');
|
|
@@ -282,8 +362,8 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
282
362
|
'change': undefined,
|
|
283
363
|
'percentage': undefined,
|
|
284
364
|
'average': undefined,
|
|
285
|
-
'baseVolume': this.
|
|
286
|
-
'quoteVolume': this.
|
|
365
|
+
'baseVolume': this.safeString2(ticker, 'total_24_hour_quantity', 'total24_hour_quantity'),
|
|
366
|
+
'quoteVolume': this.safeString2(ticker, 'total_24_hour_volume', 'total24_hour_volume'),
|
|
287
367
|
});
|
|
288
368
|
}
|
|
289
369
|
handleTicker(client, message) {
|
|
@@ -355,6 +435,68 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
355
435
|
'previousClose': undefined,
|
|
356
436
|
});
|
|
357
437
|
}
|
|
438
|
+
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
439
|
+
/**
|
|
440
|
+
* @method
|
|
441
|
+
* @name coinbaseinternational#watchOHLCV
|
|
442
|
+
* @description watches historical candlestick data containing the open, high, low, close price, and the volume of a market
|
|
443
|
+
* @see https://docs.cdp.coinbase.com/intx/docs/websocket-channels#candles-channel
|
|
444
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
445
|
+
* @param {string} timeframe the length of time each candle represents
|
|
446
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
447
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
448
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
449
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
450
|
+
*/
|
|
451
|
+
await this.loadMarkets();
|
|
452
|
+
const market = this.market(symbol);
|
|
453
|
+
symbol = market['symbol'];
|
|
454
|
+
const options = this.safeDict(this.options, 'timeframes', {});
|
|
455
|
+
const interval = this.safeString(options, timeframe, timeframe);
|
|
456
|
+
const ohlcv = await this.subscribe(interval, [symbol], params);
|
|
457
|
+
if (this.newUpdates) {
|
|
458
|
+
limit = ohlcv.getLimit(symbol, limit);
|
|
459
|
+
}
|
|
460
|
+
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
461
|
+
}
|
|
462
|
+
handleOHLCV(client, message) {
|
|
463
|
+
//
|
|
464
|
+
// {
|
|
465
|
+
// "sequence": 0,
|
|
466
|
+
// "product_id": "BTC-PERP",
|
|
467
|
+
// "channel": "CANDLES_ONE_MINUTE",
|
|
468
|
+
// "type": "SNAPSHOT",
|
|
469
|
+
// "candles": [
|
|
470
|
+
// {
|
|
471
|
+
// "time": "2023-05-10T14:58:47.000Z",
|
|
472
|
+
// "low": "28787.8",
|
|
473
|
+
// "high": "28788.8",
|
|
474
|
+
// "open": "28788.8",
|
|
475
|
+
// "close": "28787.8",
|
|
476
|
+
// "volume": "0.466"
|
|
477
|
+
// },
|
|
478
|
+
// ]
|
|
479
|
+
// }
|
|
480
|
+
//
|
|
481
|
+
const messageHash = this.safeString(message, 'channel');
|
|
482
|
+
const marketId = this.safeString(message, 'product_id');
|
|
483
|
+
const market = this.safeMarket(marketId);
|
|
484
|
+
const symbol = market['symbol'];
|
|
485
|
+
const timeframe = this.findTimeframe(messageHash);
|
|
486
|
+
this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
|
|
487
|
+
if (this.safeValue(this.ohlcvs[symbol], timeframe) === undefined) {
|
|
488
|
+
const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
|
|
489
|
+
this.ohlcvs[symbol][timeframe] = new ArrayCacheByTimestamp(limit);
|
|
490
|
+
}
|
|
491
|
+
const stored = this.ohlcvs[symbol][timeframe];
|
|
492
|
+
const data = this.safeList(message, 'candles', []);
|
|
493
|
+
for (let i = 0; i < data.length; i++) {
|
|
494
|
+
const tick = data[i];
|
|
495
|
+
const parsed = this.parseOHLCV(tick, market);
|
|
496
|
+
stored.append(parsed);
|
|
497
|
+
}
|
|
498
|
+
client.resolve(stored, messageHash + '::' + symbol);
|
|
499
|
+
}
|
|
358
500
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
359
501
|
/**
|
|
360
502
|
* @method
|
|
@@ -636,7 +778,7 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
636
778
|
if (this.handleErrorMessage(client, message)) {
|
|
637
779
|
return;
|
|
638
780
|
}
|
|
639
|
-
const channel = this.safeString(message, 'channel');
|
|
781
|
+
const channel = this.safeString(message, 'channel', '');
|
|
640
782
|
const methods = {
|
|
641
783
|
'SUBSCRIPTIONS': this.handleSubscriptionStatus,
|
|
642
784
|
'INSTRUMENTS': this.handleInstrument,
|
|
@@ -651,6 +793,9 @@ export default class coinbaseinternational extends coinbaseinternationalRest {
|
|
|
651
793
|
const errorMessage = this.safeString(message, 'message');
|
|
652
794
|
throw new ExchangeError(errorMessage);
|
|
653
795
|
}
|
|
796
|
+
if (channel.indexOf('CANDLES') > -1) {
|
|
797
|
+
this.handleOHLCV(client, message);
|
|
798
|
+
}
|
|
654
799
|
const method = this.safeValue(methods, channel);
|
|
655
800
|
if (method !== undefined) {
|
|
656
801
|
method.call(this, client, message);
|
package/js/src/pro/cryptocom.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import cryptocomRest from '../cryptocom.js';
|
|
9
|
-
import { AuthenticationError, ChecksumError, NetworkError } from '../base/errors.js';
|
|
9
|
+
import { AuthenticationError, ChecksumError, ExchangeError, NetworkError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -889,6 +889,7 @@ export default class cryptocom extends cryptocomRest {
|
|
|
889
889
|
// "message": "invalid channel {"channels":["trade.BTCUSD-PERP"]}"
|
|
890
890
|
// }
|
|
891
891
|
//
|
|
892
|
+
const id = this.safeString(message, 'id');
|
|
892
893
|
const errorCode = this.safeString(message, 'code');
|
|
893
894
|
try {
|
|
894
895
|
if (errorCode && errorCode !== '0') {
|
|
@@ -898,6 +899,7 @@ export default class cryptocom extends cryptocomRest {
|
|
|
898
899
|
if (messageString !== undefined) {
|
|
899
900
|
this.throwBroadlyMatchedException(this.exceptions['broad'], messageString, feedback);
|
|
900
901
|
}
|
|
902
|
+
throw new ExchangeError(feedback);
|
|
901
903
|
}
|
|
902
904
|
return false;
|
|
903
905
|
}
|
|
@@ -910,7 +912,7 @@ export default class cryptocom extends cryptocomRest {
|
|
|
910
912
|
}
|
|
911
913
|
}
|
|
912
914
|
else {
|
|
913
|
-
client.reject(e);
|
|
915
|
+
client.reject(e, id);
|
|
914
916
|
}
|
|
915
917
|
return true;
|
|
916
918
|
}
|
package/js/src/pro/hitbtc.d.ts
CHANGED
|
@@ -38,5 +38,5 @@ export default class hitbtc extends hitbtcRest {
|
|
|
38
38
|
handleOrderRequest(client: Client, message: any): any;
|
|
39
39
|
handleMessage(client: Client, message: any): void;
|
|
40
40
|
handleAuthenticate(client: Client, message: any): any;
|
|
41
|
-
handleError(client: Client, message: any):
|
|
41
|
+
handleError(client: Client, message: any): boolean;
|
|
42
42
|
}
|
package/js/src/pro/hitbtc.js
CHANGED
|
@@ -1215,7 +1215,9 @@ export default class hitbtc extends hitbtcRest {
|
|
|
1215
1215
|
return message;
|
|
1216
1216
|
}
|
|
1217
1217
|
handleMessage(client, message) {
|
|
1218
|
-
this.handleError(client, message)
|
|
1218
|
+
if (this.handleError(client, message)) {
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1219
1221
|
let channel = this.safeString2(message, 'ch', 'method');
|
|
1220
1222
|
if (channel !== undefined) {
|
|
1221
1223
|
const splitChannel = channel.split('/');
|
|
@@ -1294,13 +1296,29 @@ export default class hitbtc extends hitbtcRest {
|
|
|
1294
1296
|
//
|
|
1295
1297
|
const error = this.safeValue(message, 'error');
|
|
1296
1298
|
if (error !== undefined) {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1299
|
+
try {
|
|
1300
|
+
const code = this.safeValue(error, 'code');
|
|
1301
|
+
const errorMessage = this.safeString(error, 'message');
|
|
1302
|
+
const description = this.safeString(error, 'description');
|
|
1303
|
+
const feedback = this.id + ' ' + description;
|
|
1304
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
|
|
1305
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
|
|
1306
|
+
throw new ExchangeError(feedback); // unknown message
|
|
1307
|
+
}
|
|
1308
|
+
catch (e) {
|
|
1309
|
+
if (e instanceof AuthenticationError) {
|
|
1310
|
+
const messageHash = 'authenticated';
|
|
1311
|
+
client.reject(e, messageHash);
|
|
1312
|
+
if (messageHash in client.subscriptions) {
|
|
1313
|
+
delete client.subscriptions[messageHash];
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
else {
|
|
1317
|
+
const id = this.safeString(message, 'id');
|
|
1318
|
+
client.reject(e, id);
|
|
1319
|
+
}
|
|
1320
|
+
return true;
|
|
1321
|
+
}
|
|
1304
1322
|
}
|
|
1305
1323
|
return undefined;
|
|
1306
1324
|
}
|
package/js/src/pro/okx.js
CHANGED
|
@@ -1899,6 +1899,13 @@ export default class okx extends okxRest {
|
|
|
1899
1899
|
}
|
|
1900
1900
|
}
|
|
1901
1901
|
catch (e) {
|
|
1902
|
+
// if the message contains an id, it means it is a response to a request
|
|
1903
|
+
// so we only reject that promise, instead of deleting all futures, destroying the authentication future
|
|
1904
|
+
const id = this.safeString(message, 'id');
|
|
1905
|
+
if (id !== undefined) {
|
|
1906
|
+
client.reject(e, id);
|
|
1907
|
+
return false;
|
|
1908
|
+
}
|
|
1902
1909
|
client.reject(e);
|
|
1903
1910
|
return false;
|
|
1904
1911
|
}
|
package/js/src/pro/poloniex.js
CHANGED
|
@@ -1179,15 +1179,7 @@ export default class poloniex extends poloniexRest {
|
|
|
1179
1179
|
this.handleAuthenticate(client, message);
|
|
1180
1180
|
}
|
|
1181
1181
|
else if (type === undefined) {
|
|
1182
|
-
|
|
1183
|
-
const item = this.safeValue(data, 0);
|
|
1184
|
-
const orderId = this.safeString(item, 'orderId');
|
|
1185
|
-
if (orderId === '0') {
|
|
1186
|
-
this.handleErrorMessage(client, item);
|
|
1187
|
-
}
|
|
1188
|
-
else {
|
|
1189
|
-
this.handleOrderRequest(client, message);
|
|
1190
|
-
}
|
|
1182
|
+
this.handleOrderRequest(client, message);
|
|
1191
1183
|
}
|
|
1192
1184
|
else {
|
|
1193
1185
|
const data = this.safeValue(message, 'data', []);
|
|
@@ -1215,12 +1207,45 @@ export default class poloniex extends poloniexRest {
|
|
|
1215
1207
|
// "event": "error",
|
|
1216
1208
|
// "message": "Platform in maintenance mode"
|
|
1217
1209
|
// }
|
|
1210
|
+
// {
|
|
1211
|
+
// "id":"1722386782048",
|
|
1212
|
+
// "data":[
|
|
1213
|
+
// {
|
|
1214
|
+
// "orderId":0,
|
|
1215
|
+
// "clientOrderId":null,
|
|
1216
|
+
// "message":"available insufficient",
|
|
1217
|
+
// "code":21721
|
|
1218
|
+
// }
|
|
1219
|
+
// ]
|
|
1220
|
+
// }
|
|
1218
1221
|
//
|
|
1222
|
+
const id = this.safeString(message, 'id');
|
|
1219
1223
|
const event = this.safeString(message, 'event');
|
|
1220
|
-
const
|
|
1224
|
+
const data = this.safeList(message, 'data');
|
|
1225
|
+
const first = this.safeDict(data, 0);
|
|
1226
|
+
const orderId = this.safeString(first, 'orderId');
|
|
1221
1227
|
if ((event === 'error') || (orderId === '0')) {
|
|
1222
|
-
|
|
1223
|
-
|
|
1228
|
+
try {
|
|
1229
|
+
const error = this.safeString(first, 'message');
|
|
1230
|
+
const code = this.safeString(first, 'code');
|
|
1231
|
+
const feedback = this.id + ' ' + this.json(message);
|
|
1232
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
|
|
1233
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], error, feedback);
|
|
1234
|
+
throw new ExchangeError(feedback);
|
|
1235
|
+
}
|
|
1236
|
+
catch (e) {
|
|
1237
|
+
if (e instanceof AuthenticationError) {
|
|
1238
|
+
const messageHash = 'authenticated';
|
|
1239
|
+
client.reject(e, messageHash);
|
|
1240
|
+
if (messageHash in client.subscriptions) {
|
|
1241
|
+
delete client.subscriptions[messageHash];
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
else {
|
|
1245
|
+
client.reject(e, id);
|
|
1246
|
+
}
|
|
1247
|
+
return true;
|
|
1248
|
+
}
|
|
1224
1249
|
}
|
|
1225
1250
|
return false;
|
|
1226
1251
|
}
|
package/js/src/pro/woo.js
CHANGED
|
@@ -30,7 +30,7 @@ export default class woo extends wooRest {
|
|
|
30
30
|
'api': {
|
|
31
31
|
'ws': {
|
|
32
32
|
'public': 'wss://wss.woo.org/ws/stream',
|
|
33
|
-
'private': 'wss://wss.woo.
|
|
33
|
+
'private': 'wss://wss.woo.org/v2/ws/private/stream',
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
'test': {
|
|
@@ -75,7 +75,8 @@ export default class woo extends wooRest {
|
|
|
75
75
|
return newValue;
|
|
76
76
|
}
|
|
77
77
|
async watchPublic(messageHash, message) {
|
|
78
|
-
const
|
|
78
|
+
const urlUid = (this.uid) ? '/' + this.uid : '';
|
|
79
|
+
const url = this.urls['api']['ws']['public'] + urlUid;
|
|
79
80
|
const requestId = this.requestId(url);
|
|
80
81
|
const subscribe = {
|
|
81
82
|
'id': requestId,
|
|
@@ -469,7 +470,7 @@ export default class woo extends wooRest {
|
|
|
469
470
|
const marketId = this.safeString(trade, 'symbol');
|
|
470
471
|
market = this.safeMarket(marketId, market);
|
|
471
472
|
const symbol = market['symbol'];
|
|
472
|
-
const price = this.
|
|
473
|
+
const price = this.safeString2(trade, 'executedPrice', 'price');
|
|
473
474
|
const amount = this.safeString2(trade, 'executedQuantity', 'size');
|
|
474
475
|
const cost = Precise.stringMul(price, amount);
|
|
475
476
|
const side = this.safeStringLower(trade, 'side');
|
|
@@ -507,7 +508,7 @@ export default class woo extends wooRest {
|
|
|
507
508
|
checkRequiredUid(error = true) {
|
|
508
509
|
if (!this.uid) {
|
|
509
510
|
if (error) {
|
|
510
|
-
throw new AuthenticationError(this.id + ' requires `uid` credential');
|
|
511
|
+
throw new AuthenticationError(this.id + ' requires `uid` credential (woox calls it `application_id`)');
|
|
511
512
|
}
|
|
512
513
|
else {
|
|
513
514
|
return false;
|
package/package.json
CHANGED