ccxt 4.4.72 → 4.4.73

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.
@@ -1,676 +0,0 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
- // ---------------------------------------------------------------------------
8
- import bitfinex1Rest from '../bitfinex1.js';
9
- import { ExchangeError, AuthenticationError } from '../base/errors.js';
10
- import { ArrayCache, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
- import { Precise } from '../base/Precise.js';
12
- import { sha384 } from '../static_dependencies/noble-hashes/sha512.js';
13
- // ---------------------------------------------------------------------------
14
- export default class bitfinex1 extends bitfinex1Rest {
15
- describe() {
16
- return this.deepExtend(super.describe(), {
17
- 'has': {
18
- 'ws': true,
19
- 'watchTicker': true,
20
- 'watchTickers': false,
21
- 'watchOrderBook': true,
22
- 'watchTrades': true,
23
- 'watchTradesForSymbols': false,
24
- 'watchBalance': false,
25
- 'watchOHLCV': false, // missing on the exchange side in v1
26
- },
27
- 'urls': {
28
- 'api': {
29
- 'ws': {
30
- 'public': 'wss://api-pub.bitfinex.com/ws/1',
31
- 'private': 'wss://api.bitfinex.com/ws/1',
32
- },
33
- },
34
- },
35
- 'options': {
36
- 'watchOrderBook': {
37
- 'prec': 'P0',
38
- 'freq': 'F0',
39
- },
40
- 'ordersLimit': 1000,
41
- },
42
- });
43
- }
44
- async subscribe(channel, symbol, params = {}) {
45
- await this.loadMarkets();
46
- const market = this.market(symbol);
47
- const marketId = market['id'];
48
- const url = this.urls['api']['ws']['public'];
49
- const messageHash = channel + ':' + marketId;
50
- // const channel = 'trades';
51
- const request = {
52
- 'event': 'subscribe',
53
- 'channel': channel,
54
- 'symbol': marketId,
55
- 'messageHash': messageHash,
56
- };
57
- return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
58
- }
59
- /**
60
- * @method
61
- * @name bitfinex1#watchTrades
62
- * @description get the list of most recent trades for a particular symbol
63
- * @see https://docs.bitfinex.com/v1/reference/ws-public-trades
64
- * @param {string} symbol unified symbol of the market to fetch trades for
65
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
66
- * @param {int} [limit] the maximum amount of trades to fetch
67
- * @param {object} [params] extra parameters specific to the exchange API endpoint
68
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
69
- */
70
- async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
71
- await this.loadMarkets();
72
- symbol = this.symbol(symbol);
73
- const trades = await this.subscribe('trades', symbol, params);
74
- if (this.newUpdates) {
75
- limit = trades.getLimit(symbol, limit);
76
- }
77
- return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
78
- }
79
- /**
80
- * @method
81
- * @name bitfinex1#watchTicker
82
- * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
83
- * @see https://docs.bitfinex.com/v1/reference/ws-public-ticker
84
- * @param {string} symbol unified symbol of the market to fetch the ticker for
85
- * @param {object} [params] extra parameters specific to the exchange API endpoint
86
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
87
- */
88
- async watchTicker(symbol, params = {}) {
89
- return await this.subscribe('ticker', symbol, params);
90
- }
91
- handleTrades(client, message, subscription) {
92
- //
93
- // initial snapshot
94
- //
95
- // [
96
- // 2,
97
- // [
98
- // [ null, 1580565020, 9374.9, 0.005 ],
99
- // [ null, 1580565004, 9374.9, 0.005 ],
100
- // [ null, 1580565003, 9374.9, 0.005 ],
101
- // ]
102
- // ]
103
- //
104
- // when a trade does not have an id yet
105
- //
106
- // // channel id, update type, seq, time, price, amount
107
- // [ 2, "te", "28462857-BTCUSD", 1580565041, 9374.9, 0.005 ],
108
- //
109
- // when a trade already has an id
110
- //
111
- // // channel id, update type, seq, trade id, time, price, amount
112
- // [ 2, "tu", "28462857-BTCUSD", 413357662, 1580565041, 9374.9, 0.005 ]
113
- //
114
- const channel = this.safeValue(subscription, 'channel');
115
- const marketId = this.safeString(subscription, 'pair');
116
- const messageHash = channel + ':' + marketId;
117
- const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
118
- const market = this.safeMarket(marketId);
119
- const symbol = market['symbol'];
120
- const data = this.safeValue(message, 1);
121
- let stored = this.safeValue(this.trades, symbol);
122
- if (stored === undefined) {
123
- stored = new ArrayCache(tradesLimit);
124
- this.trades[symbol] = stored;
125
- }
126
- if (Array.isArray(data)) {
127
- const trades = this.parseTrades(data, market);
128
- for (let i = 0; i < trades.length; i++) {
129
- stored.append(trades[i]);
130
- }
131
- }
132
- else {
133
- const second = this.safeString(message, 1);
134
- if (second !== 'tu') {
135
- return;
136
- }
137
- const trade = this.parseTrade(message, market);
138
- stored.append(trade);
139
- }
140
- client.resolve(stored, messageHash);
141
- }
142
- parseTrade(trade, market = undefined) {
143
- //
144
- // snapshot trade
145
- //
146
- // // null, time, price, amount
147
- // [ null, 1580565020, 9374.9, 0.005 ],
148
- //
149
- // when a trade does not have an id yet
150
- //
151
- // // channel id, update type, seq, time, price, amount
152
- // [ 2, "te", "28462857-BTCUSD", 1580565041, 9374.9, 0.005 ],
153
- //
154
- // when a trade already has an id
155
- //
156
- // // channel id, update type, seq, trade id, time, price, amount
157
- // [ 2, "tu", "28462857-BTCUSD", 413357662, 1580565041, 9374.9, 0.005 ]
158
- //
159
- if (!Array.isArray(trade)) {
160
- return super.parseTrade(trade, market);
161
- }
162
- const tradeLength = trade.length;
163
- const event = this.safeString(trade, 1);
164
- let id = undefined;
165
- if (event === 'tu') {
166
- id = this.safeString(trade, tradeLength - 4);
167
- }
168
- const timestamp = this.safeTimestamp(trade, tradeLength - 3);
169
- const price = this.safeString(trade, tradeLength - 2);
170
- let amount = this.safeString(trade, tradeLength - 1);
171
- let side = undefined;
172
- if (amount !== undefined) {
173
- side = Precise.stringGt(amount, '0') ? 'buy' : 'sell';
174
- amount = Precise.stringAbs(amount);
175
- }
176
- const seq = this.safeString(trade, 2);
177
- const parts = seq.split('-');
178
- let marketId = this.safeString(parts, 1);
179
- if (marketId !== undefined) {
180
- marketId = marketId.replace('t', '');
181
- }
182
- const symbol = this.safeSymbol(marketId, market);
183
- const takerOrMaker = undefined;
184
- const orderId = undefined;
185
- return this.safeTrade({
186
- 'info': trade,
187
- 'timestamp': timestamp,
188
- 'datetime': this.iso8601(timestamp),
189
- 'symbol': symbol,
190
- 'id': id,
191
- 'order': orderId,
192
- 'type': undefined,
193
- 'takerOrMaker': takerOrMaker,
194
- 'side': side,
195
- 'price': price,
196
- 'amount': amount,
197
- 'cost': undefined,
198
- 'fee': undefined,
199
- });
200
- }
201
- handleTicker(client, message, subscription) {
202
- //
203
- // [
204
- // 2, // 0 CHANNEL_ID integer Channel ID
205
- // 236.62, // 1 BID float Price of last highest bid
206
- // 9.0029, // 2 BID_SIZE float Size of the last highest bid
207
- // 236.88, // 3 ASK float Price of last lowest ask
208
- // 7.1138, // 4 ASK_SIZE float Size of the last lowest ask
209
- // -1.02, // 5 DAILY_CHANGE float Amount that the last price has changed since yesterday
210
- // 0, // 6 DAILY_CHANGE_PERC float Amount that the price has changed expressed in percentage terms
211
- // 236.52, // 7 LAST_PRICE float Price of the last trade.
212
- // 5191.36754297, // 8 VOLUME float Daily volume
213
- // 250.01, // 9 HIGH float Daily high
214
- // 220.05, // 10 LOW float Daily low
215
- // ]
216
- //
217
- const marketId = this.safeString(subscription, 'pair');
218
- const symbol = this.safeSymbol(marketId);
219
- const channel = 'ticker';
220
- const messageHash = channel + ':' + marketId;
221
- const last = this.safeString(message, 7);
222
- const change = this.safeString(message, 5);
223
- let open = undefined;
224
- if ((last !== undefined) && (change !== undefined)) {
225
- open = Precise.stringSub(last, change);
226
- }
227
- const result = this.safeTicker({
228
- 'symbol': symbol,
229
- 'timestamp': undefined,
230
- 'datetime': undefined,
231
- 'high': this.safeString(message, 9),
232
- 'low': this.safeString(message, 10),
233
- 'bid': this.safeString(message, 1),
234
- 'bidVolume': undefined,
235
- 'ask': this.safeString(message, 3),
236
- 'askVolume': undefined,
237
- 'vwap': undefined,
238
- 'open': this.parseNumber(open),
239
- 'close': this.parseNumber(last),
240
- 'last': this.parseNumber(last),
241
- 'previousClose': undefined,
242
- 'change': this.parseNumber(change),
243
- 'percentage': this.safeString(message, 6),
244
- 'average': undefined,
245
- 'baseVolume': this.safeString(message, 8),
246
- 'quoteVolume': undefined,
247
- 'info': message,
248
- });
249
- this.tickers[symbol] = result;
250
- client.resolve(result, messageHash);
251
- }
252
- /**
253
- * @method
254
- * @name bitfinex1#watchOrderBook
255
- * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
256
- * @see https://docs.bitfinex.com/v1/reference/ws-public-order-books
257
- * @param {string} symbol unified symbol of the market to fetch the order book for
258
- * @param {int} [limit] the maximum amount of order book entries to return
259
- * @param {object} [params] extra parameters specific to the exchange API endpoint
260
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
261
- */
262
- async watchOrderBook(symbol, limit = undefined, params = {}) {
263
- if (limit !== undefined) {
264
- if ((limit !== 25) && (limit !== 100)) {
265
- throw new ExchangeError(this.id + ' watchOrderBook limit argument must be undefined, 25 or 100');
266
- }
267
- }
268
- const options = this.safeValue(this.options, 'watchOrderBook', {});
269
- const prec = this.safeString(options, 'prec', 'P0');
270
- const freq = this.safeString(options, 'freq', 'F0');
271
- const request = {
272
- // "event": "subscribe", // added in subscribe()
273
- // "channel": channel, // added in subscribe()
274
- // "symbol": marketId, // added in subscribe()
275
- 'prec': prec,
276
- 'freq': freq,
277
- 'len': limit, // string, number of price points, '25', '100', default = '25'
278
- };
279
- const orderbook = await this.subscribe('book', symbol, this.deepExtend(request, params));
280
- return orderbook.limit();
281
- }
282
- handleOrderBook(client, message, subscription) {
283
- //
284
- // first message (snapshot)
285
- //
286
- // [
287
- // 18691, // channel id
288
- // [
289
- // [ 7364.8, 10, 4.354802 ], // price, count, size > 0 = bid
290
- // [ 7364.7, 1, 0.00288831 ],
291
- // [ 7364.3, 12, 0.048 ],
292
- // [ 7364.9, 3, -0.42028976 ], // price, count, size < 0 = ask
293
- // [ 7365, 1, -0.25 ],
294
- // [ 7365.5, 1, -0.00371937 ],
295
- // ]
296
- // ]
297
- //
298
- // subsequent updates
299
- //
300
- // [
301
- // 30, // channel id
302
- // 9339.9, // price
303
- // 0, // count
304
- // -1, // size > 0 = bid, size < 0 = ask
305
- // ]
306
- //
307
- const marketId = this.safeString(subscription, 'pair');
308
- const symbol = this.safeSymbol(marketId);
309
- const channel = 'book';
310
- const messageHash = channel + ':' + marketId;
311
- const prec = this.safeString(subscription, 'prec', 'P0');
312
- const isRaw = (prec === 'R0');
313
- // if it is an initial snapshot
314
- if (Array.isArray(message[1])) {
315
- const limit = this.safeInteger(subscription, 'len');
316
- if (isRaw) {
317
- // raw order books
318
- this.orderbooks[symbol] = this.indexedOrderBook({}, limit);
319
- }
320
- else {
321
- // P0, P1, P2, P3, P4
322
- this.orderbooks[symbol] = this.countedOrderBook({}, limit);
323
- }
324
- const orderbook = this.orderbooks[symbol];
325
- if (isRaw) {
326
- const deltas = message[1];
327
- for (let i = 0; i < deltas.length; i++) {
328
- const delta = deltas[i];
329
- const id = this.safeString(delta, 0);
330
- const price = this.safeFloat(delta, 1);
331
- const delta2Value = delta[2];
332
- const size = (delta2Value < 0) ? -delta2Value : delta2Value;
333
- const side = (delta2Value < 0) ? 'asks' : 'bids';
334
- const bookside = orderbook[side];
335
- bookside.storeArray([price, size, id]);
336
- }
337
- }
338
- else {
339
- const deltas = message[1];
340
- for (let i = 0; i < deltas.length; i++) {
341
- const delta = deltas[i];
342
- const delta2 = delta[2];
343
- const size = (delta2 < 0) ? -delta2 : delta2;
344
- const side = (delta2 < 0) ? 'asks' : 'bids';
345
- const countedBookSide = orderbook[side];
346
- countedBookSide.storeArray([delta[0], size, delta[1]]);
347
- }
348
- }
349
- client.resolve(orderbook, messageHash);
350
- }
351
- else {
352
- const orderbook = this.orderbooks[symbol];
353
- if (isRaw) {
354
- const id = this.safeString(message, 1);
355
- const price = this.safeString(message, 2);
356
- const message3 = message[3];
357
- const size = (message3 < 0) ? -message3 : message3;
358
- const side = (message3 < 0) ? 'asks' : 'bids';
359
- const bookside = orderbook[side];
360
- // price = 0 means that you have to remove the order from your book
361
- const amount = Precise.stringGt(price, '0') ? size : '0';
362
- bookside.storeArray([this.parseNumber(price), this.parseNumber(amount), id]);
363
- }
364
- else {
365
- const message3Value = message[3];
366
- const size = (message3Value < 0) ? -message3Value : message3Value;
367
- const side = (message3Value < 0) ? 'asks' : 'bids';
368
- const countedBookSide = orderbook[side];
369
- countedBookSide.storeArray([message[1], size, message[2]]);
370
- }
371
- client.resolve(orderbook, messageHash);
372
- }
373
- }
374
- handleHeartbeat(client, message) {
375
- //
376
- // every second (approx) if no other updates are sent
377
- //
378
- // { "event": "heartbeat" }
379
- //
380
- const event = this.safeString(message, 'event');
381
- client.resolve(message, event);
382
- }
383
- handleSystemStatus(client, message) {
384
- //
385
- // todo: answer the question whether handleSystemStatus should be renamed
386
- // and unified as handleStatus for any usage pattern that
387
- // involves system status and maintenance updates
388
- //
389
- // {
390
- // "event": "info",
391
- // "version": 2,
392
- // "serverId": "e293377e-7bb7-427e-b28c-5db045b2c1d1",
393
- // "platform": { status: 1 }, // 1 for operative, 0 for maintenance
394
- // }
395
- //
396
- return message;
397
- }
398
- handleSubscriptionStatus(client, message) {
399
- //
400
- // {
401
- // "event": "subscribed",
402
- // "channel": "book",
403
- // "chanId": 67473,
404
- // "symbol": "tBTCUSD",
405
- // "prec": "P0",
406
- // "freq": "F0",
407
- // "len": "25",
408
- // "pair": "BTCUSD"
409
- // }
410
- //
411
- const channelId = this.safeString(message, 'chanId');
412
- client.subscriptions[channelId] = message;
413
- return message;
414
- }
415
- async authenticate(params = {}) {
416
- const url = this.urls['api']['ws']['private'];
417
- const client = this.client(url);
418
- const future = client.future('authenticated');
419
- const method = 'auth';
420
- const authenticated = this.safeValue(client.subscriptions, method);
421
- if (authenticated === undefined) {
422
- const nonce = this.milliseconds();
423
- const payload = 'AUTH' + nonce.toString();
424
- const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha384, 'hex');
425
- const request = {
426
- 'apiKey': this.apiKey,
427
- 'authSig': signature,
428
- 'authNonce': nonce,
429
- 'authPayload': payload,
430
- 'event': method,
431
- 'filter': [
432
- 'trading',
433
- 'wallet',
434
- ],
435
- };
436
- this.spawn(this.watch, url, method, request, 1);
437
- }
438
- return await future;
439
- }
440
- handleAuthenticationMessage(client, message) {
441
- const status = this.safeString(message, 'status');
442
- if (status === 'OK') {
443
- // we resolve the future here permanently so authentication only happens once
444
- const future = this.safeValue(client.futures, 'authenticated');
445
- future.resolve(true);
446
- }
447
- else {
448
- const error = new AuthenticationError(this.json(message));
449
- client.reject(error, 'authenticated');
450
- // allows further authentication attempts
451
- const method = this.safeString(message, 'event');
452
- if (method in client.subscriptions) {
453
- delete client.subscriptions[method];
454
- }
455
- }
456
- }
457
- async watchOrder(id, symbol = undefined, params = {}) {
458
- await this.loadMarkets();
459
- const url = this.urls['api']['ws']['private'];
460
- await this.authenticate();
461
- return await this.watch(url, id, undefined, 1);
462
- }
463
- /**
464
- * @method
465
- * @name bitfinex1#watchOrders
466
- * @description watches information on multiple orders made by the user
467
- * @see https://docs.bitfinex.com/v1/reference/ws-auth-order-updates
468
- * @see https://docs.bitfinex.com/v1/reference/ws-auth-order-snapshots
469
- * @param {string} symbol unified market symbol of the market orders were made in
470
- * @param {int} [since] the earliest time in ms to fetch orders for
471
- * @param {int} [limit] the maximum number of order structures to retrieve
472
- * @param {object} [params] extra parameters specific to the exchange API endpoint
473
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
474
- */
475
- async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
476
- await this.loadMarkets();
477
- await this.authenticate();
478
- if (symbol !== undefined) {
479
- symbol = this.symbol(symbol);
480
- }
481
- const url = this.urls['api']['ws']['private'];
482
- const orders = await this.watch(url, 'os', undefined, 1);
483
- if (this.newUpdates) {
484
- limit = orders.getLimit(symbol, limit);
485
- }
486
- return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
487
- }
488
- handleOrders(client, message, subscription) {
489
- //
490
- // order snapshot
491
- //
492
- // [
493
- // 0,
494
- // "os",
495
- // [
496
- // [
497
- // 45287766631,
498
- // "ETHUST",
499
- // -0.07,
500
- // -0.07,
501
- // "EXCHANGE LIMIT",
502
- // "ACTIVE",
503
- // 210,
504
- // 0,
505
- // "2020-05-16T13:17:46Z",
506
- // 0,
507
- // 0,
508
- // 0
509
- // ]
510
- // ]
511
- // ]
512
- //
513
- // order cancel
514
- //
515
- // [
516
- // 0,
517
- // "oc",
518
- // [
519
- // 45287766631,
520
- // "ETHUST",
521
- // -0.07,
522
- // -0.07,
523
- // "EXCHANGE LIMIT",
524
- // "CANCELED",
525
- // 210,
526
- // 0,
527
- // "2020-05-16T13:17:46Z",
528
- // 0,
529
- // 0,
530
- // 0,
531
- // ]
532
- // ]
533
- //
534
- const data = this.safeValue(message, 2, []);
535
- const messageType = this.safeString(message, 1);
536
- if (messageType === 'os') {
537
- for (let i = 0; i < data.length; i++) {
538
- const value = data[i];
539
- this.handleOrder(client, value);
540
- }
541
- }
542
- else {
543
- this.handleOrder(client, data);
544
- }
545
- if (this.orders !== undefined) {
546
- client.resolve(this.orders, 'os');
547
- }
548
- }
549
- parseWsOrderStatus(status) {
550
- const statuses = {
551
- 'ACTIVE': 'open',
552
- 'CANCELED': 'canceled',
553
- };
554
- return this.safeString(statuses, status, status);
555
- }
556
- handleOrder(client, order) {
557
- // [ 45287766631,
558
- // "ETHUST",
559
- // -0.07,
560
- // -0.07,
561
- // "EXCHANGE LIMIT",
562
- // "CANCELED",
563
- // 210,
564
- // 0,
565
- // "2020-05-16T13:17:46Z",
566
- // 0,
567
- // 0,
568
- // 0 ]
569
- const id = this.safeString(order, 0);
570
- const marketId = this.safeString(order, 1);
571
- const symbol = this.safeSymbol(marketId);
572
- let amount = this.safeString(order, 2);
573
- let remaining = this.safeString(order, 3);
574
- let side = 'buy';
575
- if (Precise.stringLt(amount, '0')) {
576
- amount = Precise.stringAbs(amount);
577
- remaining = Precise.stringAbs(remaining);
578
- side = 'sell';
579
- }
580
- let type = this.safeString(order, 4);
581
- if (type.indexOf('LIMIT') > -1) {
582
- type = 'limit';
583
- }
584
- else if (type.indexOf('MARKET') > -1) {
585
- type = 'market';
586
- }
587
- const status = this.parseWsOrderStatus(this.safeString(order, 5));
588
- const price = this.safeString(order, 6);
589
- const rawDatetime = this.safeString(order, 8);
590
- const timestamp = this.parse8601(rawDatetime);
591
- const parsed = this.safeOrder({
592
- 'info': order,
593
- 'id': id,
594
- 'clientOrderId': undefined,
595
- 'timestamp': timestamp,
596
- 'datetime': this.iso8601(timestamp),
597
- 'lastTradeTimestamp': undefined,
598
- 'symbol': symbol,
599
- 'type': type,
600
- 'side': side,
601
- 'price': price,
602
- 'stopPrice': undefined,
603
- 'triggerPrice': undefined,
604
- 'average': undefined,
605
- 'amount': amount,
606
- 'remaining': remaining,
607
- 'filled': undefined,
608
- 'status': status,
609
- 'fee': undefined,
610
- 'cost': undefined,
611
- 'trades': undefined,
612
- });
613
- if (this.orders === undefined) {
614
- const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
615
- this.orders = new ArrayCacheBySymbolById(limit);
616
- }
617
- const orders = this.orders;
618
- orders.append(parsed);
619
- client.resolve(parsed, id);
620
- return parsed;
621
- }
622
- handleMessage(client, message) {
623
- if (Array.isArray(message)) {
624
- const channelId = this.safeString(message, 0);
625
- //
626
- // [
627
- // 1231,
628
- // "hb",
629
- // ]
630
- //
631
- if (message[1] === 'hb') {
632
- return; // skip heartbeats within subscription channels for now
633
- }
634
- const subscription = this.safeValue(client.subscriptions, channelId, {});
635
- const channel = this.safeString(subscription, 'channel');
636
- const name = this.safeString(message, 1);
637
- const methods = {
638
- 'book': this.handleOrderBook,
639
- // 'ohlc': this.handleOHLCV,
640
- 'ticker': this.handleTicker,
641
- 'trades': this.handleTrades,
642
- 'os': this.handleOrders,
643
- 'on': this.handleOrders,
644
- 'oc': this.handleOrders,
645
- };
646
- const method = this.safeValue2(methods, channel, name);
647
- if (method !== undefined) {
648
- method.call(this, client, message, subscription);
649
- }
650
- }
651
- else {
652
- // todo add bitfinex handleErrorMessage
653
- //
654
- // {
655
- // "event": "info",
656
- // "version": 2,
657
- // "serverId": "e293377e-7bb7-427e-b28c-5db045b2c1d1",
658
- // "platform": { status: 1 }, // 1 for operative, 0 for maintenance
659
- // }
660
- //
661
- const event = this.safeString(message, 'event');
662
- if (event !== undefined) {
663
- const methods = {
664
- 'info': this.handleSystemStatus,
665
- // 'book': 'handleOrderBook',
666
- 'subscribed': this.handleSubscriptionStatus,
667
- 'auth': this.handleAuthenticationMessage,
668
- };
669
- const method = this.safeValue(methods, event);
670
- if (method !== undefined) {
671
- method.call(this, client, message);
672
- }
673
- }
674
- }
675
- }
676
- }