ccxt 4.4.64 → 4.4.65

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,88 +0,0 @@
1
- import currencycomRest from '../currencycom.js';
2
- import type { Int, OrderBook, Trade, Ticker, OHLCV, Balances } from '../base/types.js';
3
- import Client from '../base/ws/Client.js';
4
- export default class currencycom extends currencycomRest {
5
- describe(): any;
6
- ping(client: Client): {
7
- destination: string;
8
- correlationId: any;
9
- payload: {};
10
- };
11
- handlePong(client: Client, message: any): any;
12
- handleBalance(client: Client, message: any, subscription: any): void;
13
- handleTicker(client: Client, message: any, subscription: any): void;
14
- handleTrade(trade: any, market?: any): {
15
- info: any;
16
- timestamp: number;
17
- datetime: string;
18
- symbol: string;
19
- id: string;
20
- order: string;
21
- type: any;
22
- takerOrMaker: any;
23
- side: string;
24
- price: number;
25
- amount: number;
26
- cost: number;
27
- fee: any;
28
- };
29
- handleTrades(client: Client, message: any): void;
30
- findTimeframe(timeframe: any, defaultTimeframes?: any): string;
31
- handleOHLCV(client: Client, message: any): void;
32
- requestId(): any;
33
- watchPublic(destination: any, symbol: any, params?: {}): Promise<any>;
34
- watchPrivate(destination: any, params?: {}): Promise<any>;
35
- /**
36
- * @method
37
- * @name currencycom#watchBalance
38
- * @description watch balance and get the amount of funds available for trading or funds locked in orders
39
- * @param {object} [params] extra parameters specific to the exchange API endpoint
40
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
41
- */
42
- watchBalance(params?: {}): Promise<Balances>;
43
- /**
44
- * @method
45
- * @name currencycom#watchTicker
46
- * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
47
- * @param {string} symbol unified symbol of the market to fetch the ticker for
48
- * @param {object} [params] extra parameters specific to the exchange API endpoint
49
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
50
- */
51
- watchTicker(symbol: string, params?: {}): Promise<Ticker>;
52
- /**
53
- * @method
54
- * @name currencycom#watchTrades
55
- * @description get the list of most recent trades for a particular symbol
56
- * @param {string} symbol unified symbol of the market to fetch trades for
57
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
58
- * @param {int} [limit] the maximum amount of trades to fetch
59
- * @param {object} [params] extra parameters specific to the exchange API endpoint
60
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
61
- */
62
- watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
63
- /**
64
- * @method
65
- * @name currencycom#watchOrderBook
66
- * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
67
- * @param {string} symbol unified symbol of the market to fetch the order book for
68
- * @param {int} [limit] the maximum amount of order book entries to return
69
- * @param {object} [params] extra parameters specific to the exchange API endpoint
70
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
71
- */
72
- watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
73
- /**
74
- * @method
75
- * @name currencycom#watchOHLCV
76
- * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
77
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
78
- * @param {string} timeframe the length of time each candle represents
79
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
80
- * @param {int} [limit] the maximum amount of candles to fetch
81
- * @param {object} [params] extra parameters specific to the exchange API endpoint
82
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
83
- */
84
- watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
85
- handleDeltas(bookside: any, deltas: any): void;
86
- handleOrderBook(client: Client, message: any): void;
87
- handleMessage(client: Client, message: any): void;
88
- }
@@ -1,564 +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 currencycomRest from '../currencycom.js';
9
- import { Precise } from '../base/Precise.js';
10
- import { ArrayCache, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
11
- import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
- // ---------------------------------------------------------------------------
13
- export default class currencycom extends currencycomRest {
14
- describe() {
15
- return this.deepExtend(super.describe(), {
16
- 'has': {
17
- 'ws': true,
18
- 'watchBalance': true,
19
- 'watchTicker': true,
20
- 'watchTickers': false,
21
- 'watchTrades': true,
22
- 'watchOrderBook': true,
23
- // 'watchStatus': true,
24
- // 'watchHeartbeat': true,
25
- 'watchOHLCV': true,
26
- },
27
- 'urls': {
28
- 'api': {
29
- 'ws': 'wss://api-adapter.backend.currency.com/connect',
30
- },
31
- },
32
- 'options': {
33
- 'tradesLimit': 1000,
34
- 'OHLCVLimit': 1000,
35
- // WS timeframes differ from REST timeframes
36
- 'timeframes': {
37
- '1m': 'M1',
38
- '3m': 'M3',
39
- '5m': 'M5',
40
- '15m': 'M15',
41
- '30m': 'M30',
42
- '1h': 'H1',
43
- '4h': 'H4',
44
- '1d': 'D1',
45
- '1w': 'W1',
46
- },
47
- },
48
- 'streaming': {
49
- // okex does not support built-in ws protocol-level ping-pong
50
- // instead it requires a custom text-based ping-pong
51
- 'ping': this.ping,
52
- 'keepAlive': 20000,
53
- },
54
- });
55
- }
56
- ping(client) {
57
- // custom ping-pong
58
- const requestId = this.requestId().toString();
59
- return {
60
- 'destination': 'ping',
61
- 'correlationId': requestId,
62
- 'payload': {},
63
- };
64
- }
65
- handlePong(client, message) {
66
- client.lastPong = this.milliseconds();
67
- return message;
68
- }
69
- handleBalance(client, message, subscription) {
70
- //
71
- // {
72
- // "status": "OK",
73
- // "correlationId": "1",
74
- // "payload": {
75
- // "makerCommission": 0.2,
76
- // "takerCommission": 0.2,
77
- // "buyerCommission": 0.2,
78
- // "sellerCommission": 0.2,
79
- // "canTrade": true,
80
- // "canWithdraw": true,
81
- // "canDeposit": true,
82
- // "updateTime": 1596742699,
83
- // "balances": [
84
- // {
85
- // "accountId": 5470306579272968,
86
- // "collateralCurrency": true,
87
- // "asset": "ETH",
88
- // "free": 0,
89
- // "locked": 0,
90
- // "default": false
91
- // },
92
- // {
93
- // "accountId": 5470310874305732,
94
- // "collateralCurrency": true,
95
- // "asset": "USD",
96
- // "free": 47.82576736,
97
- // "locked": 1.187925,
98
- // "default": true
99
- // },
100
- // ]
101
- // }
102
- // }
103
- //
104
- const payload = this.safeValue(message, 'payload');
105
- const balance = this.parseBalance(payload);
106
- this.balance = this.extend(this.balance, balance);
107
- const messageHash = this.safeString(subscription, 'messageHash');
108
- client.resolve(this.balance, messageHash);
109
- if (messageHash in client.subscriptions) {
110
- delete client.subscriptions[messageHash];
111
- }
112
- }
113
- handleTicker(client, message, subscription) {
114
- //
115
- // {
116
- // "status": "OK",
117
- // "correlationId": "1",
118
- // "payload": {
119
- // "tickers": [
120
- // {
121
- // "symbol": "BTC/USD_LEVERAGE",
122
- // "priceChange": "484.05",
123
- // "priceChangePercent": "4.14",
124
- // "weightedAvgPrice": "11682.83",
125
- // "prevClosePrice": "11197.70",
126
- // "lastPrice": "11682.80",
127
- // "lastQty": "0.25",
128
- // "bidPrice": "11682.80",
129
- // "askPrice": "11682.85",
130
- // "openPrice": "11197.70",
131
- // "highPrice": "11734.05",
132
- // "lowPrice": "11080.95",
133
- // "volume": "299.133",
134
- // "quoteVolume": "3488040.3465",
135
- // "openTime": 1596585600000,
136
- // "closeTime": 1596654452674
137
- // }
138
- // ]
139
- // }
140
- // }
141
- //
142
- const destination = '/api/v1/ticker/24hr';
143
- const payload = this.safeValue(message, 'payload');
144
- const tickers = this.safeValue(payload, 'tickers', []);
145
- for (let i = 0; i < tickers.length; i++) {
146
- const ticker = this.parseTicker(tickers[i]);
147
- const symbol = ticker['symbol'];
148
- this.tickers[symbol] = ticker;
149
- const messageHash = destination + ':' + symbol;
150
- client.resolve(ticker, messageHash);
151
- if (messageHash in client.subscriptions) {
152
- delete client.subscriptions[messageHash];
153
- }
154
- }
155
- }
156
- handleTrade(trade, market = undefined) {
157
- //
158
- // {
159
- // "price": 11668.55,
160
- // "size": 0.001,
161
- // "id": 1600300736,
162
- // "ts": 1596653426822,
163
- // "symbol": "BTC/USD_LEVERAGE",
164
- // "orderId": "00a02503-0079-54c4-0000-00004020163c",
165
- // "clientOrderId": "00a02503-0079-54c4-0000-482f0000754f",
166
- // "buyer": false
167
- // }
168
- //
169
- const marketId = this.safeString(trade, 'symbol');
170
- const symbol = this.safeSymbol(marketId, undefined, '/');
171
- const timestamp = this.safeInteger(trade, 'ts');
172
- const priceString = this.safeString(trade, 'price');
173
- const amountString = this.safeString(trade, 'size');
174
- const cost = this.parseNumber(Precise.stringMul(priceString, amountString));
175
- const price = this.parseNumber(priceString);
176
- const amount = this.parseNumber(amountString);
177
- const id = this.safeString(trade, 'id');
178
- const orderId = this.safeString(trade, 'orderId');
179
- const buyer = this.safeValue(trade, 'buyer');
180
- const side = buyer ? 'buy' : 'sell';
181
- return {
182
- 'info': trade,
183
- 'timestamp': timestamp,
184
- 'datetime': this.iso8601(timestamp),
185
- 'symbol': symbol,
186
- 'id': id,
187
- 'order': orderId,
188
- 'type': undefined,
189
- 'takerOrMaker': undefined,
190
- 'side': side,
191
- 'price': price,
192
- 'amount': amount,
193
- 'cost': cost,
194
- 'fee': undefined,
195
- };
196
- }
197
- handleTrades(client, message) {
198
- //
199
- // {
200
- // "status": "OK",
201
- // "destination": "internal.trade",
202
- // "payload": {
203
- // "price": 11668.55,
204
- // "size": 0.001,
205
- // "id": 1600300736,
206
- // "ts": 1596653426822,
207
- // "symbol": "BTC/USD_LEVERAGE",
208
- // "orderId": "00a02503-0079-54c4-0000-00004020163c",
209
- // "clientOrderId": "00a02503-0079-54c4-0000-482f0000754f",
210
- // "buyer": false
211
- // }
212
- // }
213
- //
214
- const payload = this.safeValue(message, 'payload');
215
- const parsed = this.handleTrade(payload);
216
- const symbol = parsed['symbol'];
217
- // const destination = this.safeString (message, 'destination');
218
- const destination = 'trades.subscribe';
219
- const messageHash = destination + ':' + symbol;
220
- let stored = this.safeValue(this.trades, symbol);
221
- if (stored === undefined) {
222
- const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
223
- stored = new ArrayCache(limit);
224
- this.trades[symbol] = stored;
225
- }
226
- stored.append(parsed);
227
- client.resolve(stored, messageHash);
228
- }
229
- findTimeframe(timeframe, defaultTimeframes = undefined) {
230
- const timeframes = this.safeValue(this.options, 'timeframes', defaultTimeframes);
231
- const keys = Object.keys(timeframes);
232
- for (let i = 0; i < keys.length; i++) {
233
- const key = keys[i];
234
- if (timeframes[key] === timeframe) {
235
- return key;
236
- }
237
- }
238
- return undefined;
239
- }
240
- handleOHLCV(client, message) {
241
- //
242
- // {
243
- // "status": "OK",
244
- // "destination": "ohlc.event",
245
- // "payload": {
246
- // "interval": "M1",
247
- // "symbol": "BTC/USD_LEVERAGE",
248
- // "t": 1596650940000,
249
- // "h": 11670.05,
250
- // "l": 11658.1,
251
- // "o": 11668.55,
252
- // "c": 11666.05
253
- // }
254
- // }
255
- //
256
- // const destination = this.safeString (message, 'destination');
257
- const destination = 'OHLCMarketData.subscribe';
258
- const payload = this.safeValue(message, 'payload', {});
259
- const interval = this.safeString(payload, 'interval');
260
- const timeframe = this.findTimeframe(interval);
261
- const marketId = this.safeString(payload, 'symbol');
262
- const market = this.safeMarket(marketId);
263
- const symbol = market['symbol'];
264
- const messageHash = destination + ':' + timeframe + ':' + symbol;
265
- const result = [
266
- this.safeInteger(payload, 't'),
267
- this.safeNumber(payload, 'o'),
268
- this.safeNumber(payload, 'h'),
269
- this.safeNumber(payload, 'l'),
270
- this.safeNumber(payload, 'c'),
271
- undefined, // no volume v in OHLCV
272
- ];
273
- this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
274
- let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
275
- if (stored === undefined) {
276
- const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
277
- stored = new ArrayCacheByTimestamp(limit);
278
- this.ohlcvs[symbol][timeframe] = stored;
279
- }
280
- stored.append(result);
281
- client.resolve(stored, messageHash);
282
- }
283
- requestId() {
284
- const reqid = this.sum(this.safeInteger(this.options, 'correlationId', 0), 1);
285
- this.options['correlationId'] = reqid;
286
- return reqid;
287
- }
288
- async watchPublic(destination, symbol, params = {}) {
289
- await this.loadMarkets();
290
- const market = this.market(symbol);
291
- symbol = market['symbol'];
292
- const messageHash = destination + ':' + symbol;
293
- const url = this.urls['api']['ws'];
294
- const requestId = this.requestId().toString();
295
- const request = this.deepExtend({
296
- 'destination': destination,
297
- 'correlationId': requestId,
298
- 'payload': {
299
- 'symbols': [market['id']],
300
- },
301
- }, params);
302
- const subscription = this.extend(request, {
303
- 'messageHash': messageHash,
304
- 'symbol': symbol,
305
- });
306
- return await this.watch(url, messageHash, request, messageHash, subscription);
307
- }
308
- async watchPrivate(destination, params = {}) {
309
- await this.loadMarkets();
310
- const messageHash = '/api/v1/account';
311
- const url = this.urls['api']['ws'];
312
- const requestId = this.requestId().toString();
313
- const payload = {
314
- 'timestamp': this.milliseconds(),
315
- 'apiKey': this.apiKey,
316
- };
317
- const auth = this.urlencode(this.keysort(payload));
318
- const request = this.deepExtend({
319
- 'destination': destination,
320
- 'correlationId': requestId,
321
- 'payload': payload,
322
- }, params);
323
- request['payload']['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
324
- const subscription = this.extend(request, {
325
- 'messageHash': messageHash,
326
- });
327
- return await this.watch(url, messageHash, request, messageHash, subscription);
328
- }
329
- /**
330
- * @method
331
- * @name currencycom#watchBalance
332
- * @description watch balance and get the amount of funds available for trading or funds locked in orders
333
- * @param {object} [params] extra parameters specific to the exchange API endpoint
334
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
335
- */
336
- async watchBalance(params = {}) {
337
- await this.loadMarkets();
338
- return await this.watchPrivate('/api/v1/account', params);
339
- }
340
- /**
341
- * @method
342
- * @name currencycom#watchTicker
343
- * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
344
- * @param {string} symbol unified symbol of the market to fetch the ticker for
345
- * @param {object} [params] extra parameters specific to the exchange API endpoint
346
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
347
- */
348
- async watchTicker(symbol, params = {}) {
349
- await this.loadMarkets();
350
- const market = this.market(symbol);
351
- symbol = market['symbol'];
352
- const destination = '/api/v1/ticker/24hr';
353
- const messageHash = destination + ':' + symbol;
354
- const url = this.urls['api']['ws'];
355
- const requestId = this.requestId().toString();
356
- const request = this.deepExtend({
357
- 'destination': destination,
358
- 'correlationId': requestId,
359
- 'payload': {
360
- 'symbol': market['id'],
361
- },
362
- }, params);
363
- const subscription = this.extend(request, {
364
- 'messageHash': messageHash,
365
- 'symbol': symbol,
366
- });
367
- return await this.watch(url, messageHash, request, messageHash, subscription);
368
- }
369
- /**
370
- * @method
371
- * @name currencycom#watchTrades
372
- * @description get the list of most recent trades for a particular symbol
373
- * @param {string} symbol unified symbol of the market to fetch trades for
374
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
375
- * @param {int} [limit] the maximum amount of trades to fetch
376
- * @param {object} [params] extra parameters specific to the exchange API endpoint
377
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
378
- */
379
- async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
380
- await this.loadMarkets();
381
- symbol = this.symbol(symbol);
382
- const trades = await this.watchPublic('trades.subscribe', symbol, params);
383
- if (this.newUpdates) {
384
- limit = trades.getLimit(symbol, limit);
385
- }
386
- return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
387
- }
388
- /**
389
- * @method
390
- * @name currencycom#watchOrderBook
391
- * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
392
- * @param {string} symbol unified symbol of the market to fetch the order book for
393
- * @param {int} [limit] the maximum amount of order book entries to return
394
- * @param {object} [params] extra parameters specific to the exchange API endpoint
395
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
396
- */
397
- async watchOrderBook(symbol, limit = undefined, params = {}) {
398
- await this.loadMarkets();
399
- symbol = this.symbol(symbol);
400
- const orderbook = await this.watchPublic('depthMarketData.subscribe', symbol, params);
401
- return orderbook.limit();
402
- }
403
- /**
404
- * @method
405
- * @name currencycom#watchOHLCV
406
- * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
407
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
408
- * @param {string} timeframe the length of time each candle represents
409
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
410
- * @param {int} [limit] the maximum amount of candles to fetch
411
- * @param {object} [params] extra parameters specific to the exchange API endpoint
412
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
413
- */
414
- async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
415
- await this.loadMarkets();
416
- symbol = this.symbol(symbol);
417
- const destination = 'OHLCMarketData.subscribe';
418
- const messageHash = destination + ':' + timeframe;
419
- const timeframes = this.safeValue(this.options, 'timeframes');
420
- const request = {
421
- 'destination': destination,
422
- 'payload': {
423
- 'intervals': [
424
- timeframes[timeframe],
425
- ],
426
- },
427
- };
428
- const ohlcv = await this.watchPublic(messageHash, symbol, this.extend(request, params));
429
- if (this.newUpdates) {
430
- limit = ohlcv.getLimit(symbol, limit);
431
- }
432
- return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
433
- }
434
- handleDeltas(bookside, deltas) {
435
- const prices = Object.keys(deltas);
436
- for (let i = 0; i < prices.length; i++) {
437
- const price = prices[i];
438
- const amount = deltas[price];
439
- bookside.store(parseFloat(price), parseFloat(amount));
440
- }
441
- }
442
- handleOrderBook(client, message) {
443
- //
444
- // {
445
- // "status": "OK",
446
- // "destination": "marketdepth.event",
447
- // "payload": {
448
- // "data": "{"ts":1596235401337,"bid":{"11366.85":0.2500,"11366.1":5.0000,"11365.6":0.5000,"11363.0":2.0000},"ofr":{"11366.9":0.2500,"11367.65":5.0000,"11368.15":0.5000}}",
449
- // "symbol": "BTC/USD_LEVERAGE"
450
- // }
451
- // }
452
- //
453
- const payload = this.safeValue(message, 'payload', {});
454
- const data = this.safeValue(payload, 'data', {});
455
- const marketId = this.safeString(payload, 'symbol');
456
- const symbol = this.safeSymbol(marketId, undefined, '/');
457
- // const destination = this.safeString (message, 'destination');
458
- const destination = 'depthMarketData.subscribe';
459
- const messageHash = destination + ':' + symbol;
460
- const timestamp = this.safeInteger(data, 'ts');
461
- // let orderbook = this.safeValue (this.orderbooks, symbol);
462
- if (!(symbol in this.orderbooks)) {
463
- this.orderbooks[symbol] = this.orderBook();
464
- }
465
- const orderbook = this.orderbooks[symbol];
466
- orderbook.reset({
467
- 'symbol': symbol,
468
- 'timestamp': timestamp,
469
- 'datetime': this.iso8601(timestamp),
470
- });
471
- const bids = this.safeDict(data, 'bid', {});
472
- const asks = this.safeDict(data, 'ofr', {});
473
- this.handleDeltas(orderbook['bids'], bids);
474
- this.handleDeltas(orderbook['asks'], asks);
475
- this.orderbooks[symbol] = orderbook;
476
- client.resolve(orderbook, messageHash);
477
- }
478
- handleMessage(client, message) {
479
- //
480
- // {
481
- // "status": "OK",
482
- // "correlationId": "1",
483
- // "payload": {
484
- // "tickers": [
485
- // {
486
- // "symbol": "1COV",
487
- // "priceChange": "-0.29",
488
- // "priceChangePercent": "-0.80",
489
- // "prevClosePrice": "36.33",
490
- // "lastPrice": "36.04",
491
- // "openPrice": "36.33",
492
- // "highPrice": "36.46",
493
- // "lowPrice": "35.88",
494
- // "openTime": 1595548800000,
495
- // "closeTime": 1595795305401
496
- // }
497
- // ]
498
- // }
499
- // }
500
- //
501
- // {
502
- // "status": "OK",
503
- // "destination": "marketdepth.event",
504
- // "payload": {
505
- // "data": "{"ts":1596235401337,"bid":{"11366.85":0.2500,"11366.1":5.0000,"11365.6":0.5000,"11363.0":2.0000},"ofr":{"11366.9":0.2500,"11367.65":5.0000,"11368.15":0.5000}}",
506
- // "symbol": "BTC/USD_LEVERAGE"
507
- // }
508
- // }
509
- //
510
- // {
511
- // "status": "OK",
512
- // "destination": "internal.trade",
513
- // "payload": {
514
- // "price": 11634.75,
515
- // "size": 0.001,
516
- // "id": 1605492357,
517
- // "ts": 1596263802399,
518
- // "instrumentId": 45076691096786110,
519
- // "orderId": "00a02503-0079-54c4-0000-0000401fff51",
520
- // "clientOrderId": "00a02503-0079-54c4-0000-482b00002f17",
521
- // "buyer": false
522
- // }
523
- // }
524
- //
525
- const requestId = this.safeString(message, 'correlationId');
526
- if (requestId !== undefined) {
527
- const subscriptionsById = this.indexBy(client.subscriptions, 'correlationId');
528
- const status = this.safeString(message, 'status');
529
- const subscription = this.safeValue(subscriptionsById, requestId);
530
- if (subscription !== undefined) {
531
- if (status === 'OK') {
532
- const subscriptionDestination = this.safeString(subscription, 'destination');
533
- if (subscriptionDestination !== undefined) {
534
- const methods = {
535
- '/api/v1/ticker/24hr': this.handleTicker,
536
- '/api/v1/account': this.handleBalance,
537
- };
538
- const method = this.safeValue(methods, subscriptionDestination);
539
- if (method === undefined) {
540
- return;
541
- }
542
- else {
543
- method.call(this, client, message, subscription);
544
- return;
545
- }
546
- }
547
- }
548
- }
549
- }
550
- const destination = this.safeString(message, 'destination');
551
- if (destination !== undefined) {
552
- const methods = {
553
- 'marketdepth.event': this.handleOrderBook,
554
- 'internal.trade': this.handleTrades,
555
- 'ohlc.event': this.handleOHLCV,
556
- 'ping': this.handlePong,
557
- };
558
- const method = this.safeValue(methods, destination);
559
- if (method !== undefined) {
560
- method.call(this, client, message);
561
- }
562
- }
563
- }
564
- }