ccxt-ir 4.16.1 → 4.16.3

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.
@@ -4,354 +4,366 @@
4
4
  // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
- // ---------------------------------------------------------------------------
8
- import Exchange from './base/Exchange.js';
9
- import Precise from './base/Precise.js';
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class asacoine
13
- * @augments Exchange
14
- */
15
- export default class asacoine extends Exchange {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'asacoine',
19
- 'name': 'Asacoine',
20
- 'countries': ['IR'],
21
- 'rateLimit': 1000,
22
- 'version': 'v1',
23
- 'certified': false,
24
- 'pro': false,
25
- 'has': {
26
- 'CORS': undefined,
27
- 'spot': true,
28
- 'margin': false,
29
- 'swap': false,
30
- 'future': false,
31
- 'option': false,
32
- 'fetchMarkets': true,
33
- 'fetchTicker': true,
34
- 'fetchTickers': true,
35
- 'otc': true,
36
- },
37
- 'urls': {
38
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/asacoine/64x64.png',
39
- 'api': {
40
- 'public': 'https://api.asacoine.com/api',
41
- },
42
- 'www': 'https://asacoine.com',
43
- 'doc': 'https://api.asacoine.com/api/v1/market/pairs/pricing',
44
- },
45
- 'api': {
46
- 'public': {
47
- 'get': {
48
- 'v1/market/pairs/pricing': 1,
49
- 'v1/market/pairs/cumulative': 1,
50
- },
51
- },
52
- },
53
- 'commonCurrencies': {
54
- 'TMN': 'IRT',
55
- },
56
- 'fees': {
57
- 'trading': {
58
- 'tierBased': false,
59
- 'percentage': true,
60
- 'maker': this.parseNumber('0'),
61
- 'taker': this.parseNumber('0'),
62
- },
63
- },
64
- });
65
- }
66
- parseMarket(market) {
67
- const baseId = this.safeString(market, 'baseId');
68
- const quoteId = this.safeString(market, 'quoteId');
69
- const base = this.safeCurrencyCode(baseId);
70
- const quote = this.safeCurrencyCode(quoteId);
71
- return {
72
- 'id': baseId + '/' + quoteId,
73
- 'symbol': base + '/' + quote,
74
- 'base': base,
75
- 'quote': quote,
76
- 'settle': undefined,
77
- 'baseId': baseId,
78
- 'quoteId': quoteId,
79
- 'settleId': undefined,
80
- 'type': 'spot',
81
- 'spot': true,
82
- 'margin': false,
83
- 'swap': false,
84
- 'future': false,
85
- 'option': false,
86
- 'active': true,
87
- 'contract': false,
88
- 'linear': undefined,
89
- 'inverse': undefined,
90
- 'contractSize': undefined,
91
- 'expiry': undefined,
92
- 'expiryDatetime': undefined,
93
- 'strike': undefined,
94
- 'optionType': undefined,
95
- 'precision': {
96
- 'amount': undefined,
97
- 'price': undefined,
98
- },
99
- 'limits': {
100
- 'leverage': {
101
- 'min': undefined,
102
- 'max': undefined,
103
- },
104
- 'amount': {
105
- 'min': undefined,
106
- 'max': undefined,
107
- },
108
- 'price': {
109
- 'min': undefined,
110
- 'max': undefined,
111
- },
112
- 'cost': {
113
- 'min': undefined,
114
- 'max': undefined,
115
- },
116
- },
117
- 'created': undefined,
118
- 'info': this.safeValue(market, 'info', market),
119
- };
120
- }
121
- parseOtcMarket(market) {
122
- const baseId = this.safeString(market, 'baseId');
123
- const quoteId = this.safeString(market, 'quoteId');
124
- const base = this.safeCurrencyCode(baseId);
125
- const quote = this.safeCurrencyCode(quoteId);
126
- return {
127
- 'id': baseId + '/' + quoteId,
128
- 'symbol': base + '/' + quote,
129
- 'base': base,
130
- 'quote': quote,
131
- 'settle': undefined,
132
- 'baseId': baseId,
133
- 'quoteId': quoteId,
134
- 'settleId': undefined,
135
- 'type': 'otc',
136
- 'spot': false,
137
- 'margin': false,
138
- 'swap': false,
139
- 'future': false,
140
- 'option': false,
141
- 'active': true,
142
- 'contract': false,
143
- 'linear': undefined,
144
- 'inverse': undefined,
145
- 'contractSize': undefined,
146
- 'expiry': undefined,
147
- 'expiryDatetime': undefined,
148
- 'strike': undefined,
149
- 'optionType': undefined,
150
- 'precision': {
151
- 'amount': undefined,
152
- 'price': undefined,
153
- },
154
- 'limits': {
155
- 'leverage': {
156
- 'min': undefined,
157
- 'max': undefined,
158
- },
159
- 'amount': {
160
- 'min': undefined,
161
- 'max': undefined,
162
- },
163
- 'price': {
164
- 'min': undefined,
165
- 'max': undefined,
166
- },
167
- 'cost': {
168
- 'min': undefined,
169
- 'max': undefined,
170
- },
171
- },
172
- 'created': undefined,
173
- 'info': this.safeValue(market, 'info', market),
174
- };
175
- }
176
- parseMarkets(response) {
177
- const data = this.safeDict(response, 'data', {});
178
- const baseIds = Object.keys(data);
179
- const result = [];
180
- for (let i = 0; i < baseIds.length; i++) {
181
- const baseId = baseIds[i];
182
- const quotes = this.safeDict(data, baseId, {});
183
- const quoteIds = Object.keys(quotes);
184
- for (let j = 0; j < quoteIds.length; j++) {
185
- const quoteId = quoteIds[j];
186
- const ticker = this.safeDict(quotes, quoteId, {});
187
- result.push(this.parseMarket({ 'baseId': baseId, 'quoteId': quoteId, 'info': ticker }));
188
- }
189
- }
190
- return result;
191
- }
192
- parseCumulativeMarkets(response) {
193
- const data = this.safeDict(response, 'data', {});
194
- const keys = this.safeList(data, 'keys', []);
195
- const values = this.safeList(data, 'values', []);
196
- const result = [];
197
- for (let i = 0; i < values.length; i++) {
198
- const row = values[i];
199
- const market = {};
200
- for (let j = 0; j < keys.length; j++) {
201
- market[keys[j]] = row[j];
202
- }
203
- const marketTypes = this.safeList(market, 'marketTypes', []);
204
- if (!this.inArray('otc', marketTypes)) {
205
- continue;
206
- }
207
- const name = this.safeString(market, 'name');
208
- const [baseId, quoteId] = name.split('-');
209
- market['baseId'] = baseId;
210
- market['quoteId'] = quoteId;
211
- result.push(this.parseOtcMarket(market));
212
- }
213
- return result;
214
- }
215
- async fetchMarkets(params = {}) {
216
- /**
217
- * @method
218
- * @name asacoine#fetchMarkets
219
- * @description retrieves data on all markets for asacoine
220
- * @see https://api.asacoine.com/api/v1/market/pairs/pricing
221
- * @param {object} [params] extra parameters specific to the exchange API endpoint
222
- * @returns {object[]} an array of objects representing market data
223
- */
224
- const type = this.safeString(params, 'type', 'spot');
225
- const request = this.omit(params, ['type']);
226
- if (type === 'otc') {
227
- const cumulativeResponse = await this.publicGetV1MarketPairsCumulative(request);
228
- return this.parseCumulativeMarkets(cumulativeResponse);
229
- }
230
- const response = await this.publicGetV1MarketPairsPricing(request);
231
- return this.parseMarkets(response);
232
- }
233
- parseTicker(ticker, market = undefined) {
234
- const bid = this.safeList(ticker, 'bid', []);
235
- const ask = this.safeList(ticker, 'ask', []);
236
- const nestedOrderBook = this.safeDict(ticker, 'orderBook');
237
- const cumulativeOrderBook = nestedOrderBook === undefined && this.safeString(ticker, 'bestBid') !== undefined ? ticker : nestedOrderBook;
238
- const orderBook = cumulativeOrderBook === undefined ? {} : cumulativeOrderBook;
239
- const bidPriceString = cumulativeOrderBook === undefined ? this.safeString(bid, 0) : this.safeString(orderBook, 'bestBid');
240
- const askPriceString = cumulativeOrderBook === undefined ? this.safeString(ask, 0) : this.safeString(orderBook, 'bestAsk');
241
- const bidPrice = this.parseNumber(bidPriceString);
242
- const askPrice = this.parseNumber(askPriceString);
243
- const bidVolume = cumulativeOrderBook === undefined ? this.safeNumber(bid, 1) : this.safeNumber(orderBook, 'bidSize');
244
- const askVolume = cumulativeOrderBook === undefined ? this.safeNumber(ask, 1) : this.safeNumber(orderBook, 'askSize');
245
- let last = undefined;
246
- if ((bidPriceString !== undefined) && (askPriceString !== undefined)) {
247
- last = this.parseNumber(Precise.stringDiv(Precise.stringAdd(bidPriceString, askPriceString), '2'));
248
- }
249
- return this.safeTicker({
250
- 'symbol': this.safeString(market, 'symbol'),
251
- 'timestamp': undefined,
252
- 'datetime': undefined,
253
- 'high': undefined,
254
- 'low': undefined,
255
- 'bid': bidPrice,
256
- 'bidVolume': bidVolume,
257
- 'ask': askPrice,
258
- 'askVolume': askVolume,
259
- 'vwap': undefined,
260
- 'open': undefined,
261
- 'close': last,
262
- 'last': last,
263
- 'previousClose': undefined,
264
- 'change': undefined,
265
- 'percentage': undefined,
266
- 'average': last,
267
- 'baseVolume': undefined,
268
- 'quoteVolume': undefined,
269
- 'info': ticker,
270
- }, market);
271
- }
272
- async fetchTickers(symbols = undefined, params = {}) {
273
- /**
274
- * @method
275
- * @name asacoine#fetchTickers
276
- * @description fetches price tickers for multiple markets
277
- * @see https://api.asacoine.com/api/v1/market/pairs/pricing
278
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the tickers for, all market tickers are returned if not assigned
279
- * @param {object} [params] extra parameters specific to the exchange API endpoint
280
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
281
- */
282
- const type = this.safeString(params, 'type', 'spot');
283
- const request = this.omit(params, ['type']);
284
- await this.loadMarkets(false, { 'type': type });
285
- if (symbols !== undefined) {
286
- symbols = this.marketSymbols(symbols);
287
- }
288
- let response;
289
- if (type === 'otc') {
290
- response = await this.publicGetV1MarketPairsCumulative(request);
291
- }
292
- else {
293
- response = await this.publicGetV1MarketPairsPricing(request);
294
- }
295
- if (type === 'otc') {
296
- const cumulativeData = this.safeDict(response, 'data', {});
297
- const keys = this.safeList(cumulativeData, 'keys', []);
298
- const values = this.safeList(cumulativeData, 'values', []);
299
- const cumulativeTickers = {};
300
- for (let i = 0; i < values.length; i++) {
301
- const row = values[i];
302
- const raw = {};
303
- for (let j = 0; j < keys.length; j++) {
304
- raw[keys[j]] = row[j];
305
- }
306
- const name = this.safeString(raw, 'name');
307
- const [baseId, quoteId] = name.split('-');
308
- const base = this.safeCurrencyCode(baseId);
309
- const quote = this.safeCurrencyCode(quoteId);
310
- const market = this.safeMarket(base + '/' + quote);
311
- const parsed = this.parseTicker(this.safeDict(raw, 'orderBook', {}), market);
312
- cumulativeTickers[parsed['symbol']] = parsed;
313
- }
314
- return this.filterByArrayTickers(cumulativeTickers, 'symbol', symbols);
315
- }
316
- const data = this.safeDict(response, 'data', {});
317
- const baseIds = Object.keys(data);
318
- const result = {};
319
- for (let i = 0; i < baseIds.length; i++) {
320
- const baseId = baseIds[i];
321
- const quotes = this.safeDict(data, baseId, {});
322
- const quoteIds = Object.keys(quotes);
323
- for (let j = 0; j < quoteIds.length; j++) {
324
- const quoteId = quoteIds[j];
325
- const ticker = this.safeDict(quotes, quoteId, {});
326
- const market = this.safeMarket(baseId + '/' + quoteId);
327
- const parsed = this.parseTicker(ticker, market);
328
- result[parsed['symbol']] = parsed;
329
- }
330
- }
331
- return this.filterByArrayTickers(result, 'symbol', symbols);
332
- }
333
- async fetchTicker(symbol, params = {}) {
334
- /**
335
- * @method
336
- * @name asacoine#fetchTicker
337
- * @description fetches a price ticker, a statistical calculation for a specific market
338
- * @see https://api.asacoine.com/api/v1/market/pairs/pricing
339
- * @param {string} symbol unified symbol of the market to fetch the ticker for
340
- * @param {object} [params] extra parameters specific to the exchange API endpoint
341
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
342
- */
343
- const tickers = await this.fetchTickers([symbol], params);
344
- return tickers[symbol];
345
- }
346
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
347
- const query = this.omit(params, this.extractParams(path));
348
- let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
349
- if (Object.keys(query).length) {
350
- url += '?' + this.urlencode(query);
351
- }
352
- headers = {
353
- 'Content-Type': 'application/json',
354
- };
355
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
356
- }
357
- }
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './base/Exchange.js';
9
+ import Precise from './base/Precise.js';
10
+ // ---------------------------------------------------------------------------
11
+ /**
12
+ * @class asacoine
13
+ * @augments Exchange
14
+ */
15
+ export default class asacoine extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'asacoine',
19
+ 'name': 'Asacoine',
20
+ 'countries': ['IR'],
21
+ 'rateLimit': 1000,
22
+ 'version': 'v1',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'has': {
26
+ 'CORS': undefined,
27
+ 'spot': true,
28
+ 'margin': false,
29
+ 'swap': false,
30
+ 'future': false,
31
+ 'option': false,
32
+ 'fetchMarkets': true,
33
+ 'fetchTicker': true,
34
+ 'fetchTickers': true,
35
+ 'otc': true,
36
+ },
37
+ 'urls': {
38
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/asacoine/64x64.png',
39
+ 'api': {
40
+ 'public': 'https://api.asacoine.com/api',
41
+ },
42
+ 'www': 'https://asacoine.com',
43
+ 'doc': 'https://api.asacoine.com/api/v1/market/pairs/pricing',
44
+ },
45
+ 'api': {
46
+ 'public': {
47
+ 'get': {
48
+ 'v1/market/pairs/pricing': 1,
49
+ 'v1/market/pairs/cumulative': 1,
50
+ },
51
+ },
52
+ },
53
+ 'commonCurrencies': {
54
+ 'TMN': 'IRT',
55
+ },
56
+ 'fees': {
57
+ 'trading': {
58
+ 'tierBased': false,
59
+ 'percentage': true,
60
+ 'maker': this.parseNumber('0'),
61
+ 'taker': this.parseNumber('0'),
62
+ },
63
+ },
64
+ });
65
+ }
66
+ parseMarket(market) {
67
+ const baseId = this.safeString(market, 'baseId');
68
+ const quoteId = this.safeString(market, 'quoteId');
69
+ const base = this.safeCurrencyCode(baseId);
70
+ const quote = this.safeCurrencyCode(quoteId);
71
+ return {
72
+ 'id': baseId + '/' + quoteId,
73
+ 'symbol': base + '/' + quote,
74
+ 'base': base,
75
+ 'quote': quote,
76
+ 'settle': undefined,
77
+ 'baseId': baseId,
78
+ 'quoteId': quoteId,
79
+ 'settleId': undefined,
80
+ 'type': 'spot',
81
+ 'spot': true,
82
+ 'margin': false,
83
+ 'swap': false,
84
+ 'future': false,
85
+ 'option': false,
86
+ 'active': true,
87
+ 'contract': false,
88
+ 'linear': undefined,
89
+ 'inverse': undefined,
90
+ 'contractSize': undefined,
91
+ 'expiry': undefined,
92
+ 'expiryDatetime': undefined,
93
+ 'strike': undefined,
94
+ 'optionType': undefined,
95
+ 'precision': {
96
+ 'amount': undefined,
97
+ 'price': undefined,
98
+ },
99
+ 'limits': {
100
+ 'leverage': {
101
+ 'min': undefined,
102
+ 'max': undefined,
103
+ },
104
+ 'amount': {
105
+ 'min': undefined,
106
+ 'max': undefined,
107
+ },
108
+ 'price': {
109
+ 'min': undefined,
110
+ 'max': undefined,
111
+ },
112
+ 'cost': {
113
+ 'min': undefined,
114
+ 'max': undefined,
115
+ },
116
+ },
117
+ 'created': undefined,
118
+ 'info': this.safeValue(market, 'info', market),
119
+ };
120
+ }
121
+ parseOtcMarket(market) {
122
+ const baseId = this.safeString(market, 'baseId');
123
+ const quoteId = this.safeString(market, 'quoteId');
124
+ const base = this.safeCurrencyCode(baseId);
125
+ const quote = this.safeCurrencyCode(quoteId);
126
+ return {
127
+ 'id': baseId + '/' + quoteId,
128
+ 'symbol': base + '/' + quote,
129
+ 'base': base,
130
+ 'quote': quote,
131
+ 'settle': undefined,
132
+ 'baseId': baseId,
133
+ 'quoteId': quoteId,
134
+ 'settleId': undefined,
135
+ 'type': 'otc',
136
+ 'spot': false,
137
+ 'margin': false,
138
+ 'swap': false,
139
+ 'future': false,
140
+ 'option': false,
141
+ 'active': true,
142
+ 'contract': false,
143
+ 'linear': undefined,
144
+ 'inverse': undefined,
145
+ 'contractSize': undefined,
146
+ 'expiry': undefined,
147
+ 'expiryDatetime': undefined,
148
+ 'strike': undefined,
149
+ 'optionType': undefined,
150
+ 'precision': {
151
+ 'amount': undefined,
152
+ 'price': undefined,
153
+ },
154
+ 'limits': {
155
+ 'leverage': {
156
+ 'min': undefined,
157
+ 'max': undefined,
158
+ },
159
+ 'amount': {
160
+ 'min': undefined,
161
+ 'max': undefined,
162
+ },
163
+ 'price': {
164
+ 'min': undefined,
165
+ 'max': undefined,
166
+ },
167
+ 'cost': {
168
+ 'min': undefined,
169
+ 'max': undefined,
170
+ },
171
+ },
172
+ 'created': undefined,
173
+ 'info': this.safeValue(market, 'info', market),
174
+ };
175
+ }
176
+ parseMarkets(response) {
177
+ const data = this.safeDict(response, 'data', {});
178
+ const baseIds = Object.keys(data);
179
+ const result = [];
180
+ for (let i = 0; i < baseIds.length; i++) {
181
+ const baseId = baseIds[i];
182
+ const quotes = this.safeDict(data, baseId, {});
183
+ const quoteIds = Object.keys(quotes);
184
+ for (let j = 0; j < quoteIds.length; j++) {
185
+ const quoteId = quoteIds[j];
186
+ const ticker = this.safeDict(quotes, quoteId, {});
187
+ result.push(this.parseMarket({ 'baseId': baseId, 'quoteId': quoteId, 'info': ticker }));
188
+ }
189
+ }
190
+ return result;
191
+ }
192
+ parseCumulativeMarkets(response) {
193
+ const data = this.safeDict(response, 'data', {});
194
+ const keys = this.safeList(data, 'keys', []);
195
+ const values = this.safeList(data, 'values', []);
196
+ const result = [];
197
+ for (let i = 0; i < values.length; i++) {
198
+ const row = values[i];
199
+ const market = {};
200
+ for (let j = 0; j < keys.length; j++) {
201
+ market[keys[j]] = row[j];
202
+ }
203
+ const marketTypes = this.safeList(market, 'marketTypes', []);
204
+ if (!this.inArray('otc', marketTypes)) {
205
+ continue;
206
+ }
207
+ const name = this.safeString(market, 'name');
208
+ const [baseId, quoteId] = name.split('-');
209
+ market['baseId'] = baseId;
210
+ market['quoteId'] = quoteId;
211
+ result.push(this.parseOtcMarket(market));
212
+ }
213
+ return result;
214
+ }
215
+ async fetchMarkets(params = {}) {
216
+ /**
217
+ * @method
218
+ * @name asacoine#fetchMarkets
219
+ * @description retrieves data on all markets for asacoine
220
+ * @see https://api.asacoine.com/api/v1/market/pairs/pricing
221
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
222
+ * @returns {object[]} an array of objects representing market data
223
+ */
224
+ const type = this.safeString(params, 'type', 'spot');
225
+ const request = this.omit(params, ['type']);
226
+ if (type === 'otc') {
227
+ const cumulativeResponse = await this.publicGetV1MarketPairsCumulative(request);
228
+ return this.parseCumulativeMarkets(cumulativeResponse);
229
+ }
230
+ const response = await this.publicGetV1MarketPairsPricing(request);
231
+ return this.parseMarkets(response);
232
+ }
233
+ parseTicker(ticker, market = undefined) {
234
+ const bid = this.safeList(ticker, 'bid', []);
235
+ const ask = this.safeList(ticker, 'ask', []);
236
+ const nestedOrderBook = this.safeDict(ticker, 'orderBook');
237
+ let cumulativeOrderBook = nestedOrderBook;
238
+ if ((nestedOrderBook === undefined) && (this.safeString(ticker, 'bestBid') !== undefined)) {
239
+ cumulativeOrderBook = ticker;
240
+ }
241
+ let orderBook = cumulativeOrderBook;
242
+ if (orderBook === undefined) {
243
+ orderBook = {};
244
+ }
245
+ let bidPriceString = this.safeString(orderBook, 'bestBid');
246
+ let askPriceString = this.safeString(orderBook, 'bestAsk');
247
+ let bidVolume = this.safeNumber(orderBook, 'bidSize');
248
+ let askVolume = this.safeNumber(orderBook, 'askSize');
249
+ if (cumulativeOrderBook === undefined) {
250
+ bidPriceString = this.safeString(bid, 0);
251
+ askPriceString = this.safeString(ask, 0);
252
+ bidVolume = this.safeNumber(bid, 1);
253
+ askVolume = this.safeNumber(ask, 1);
254
+ }
255
+ const bidPrice = this.parseNumber(bidPriceString);
256
+ const askPrice = this.parseNumber(askPriceString);
257
+ let last = undefined;
258
+ if ((bidPriceString !== undefined) && (askPriceString !== undefined)) {
259
+ last = this.parseNumber(Precise.stringDiv(Precise.stringAdd(bidPriceString, askPriceString), '2'));
260
+ }
261
+ return this.safeTicker({
262
+ 'symbol': this.safeString(market, 'symbol'),
263
+ 'timestamp': undefined,
264
+ 'datetime': undefined,
265
+ 'high': undefined,
266
+ 'low': undefined,
267
+ 'bid': bidPrice,
268
+ 'bidVolume': bidVolume,
269
+ 'ask': askPrice,
270
+ 'askVolume': askVolume,
271
+ 'vwap': undefined,
272
+ 'open': undefined,
273
+ 'close': last,
274
+ 'last': last,
275
+ 'previousClose': undefined,
276
+ 'change': undefined,
277
+ 'percentage': undefined,
278
+ 'average': last,
279
+ 'baseVolume': undefined,
280
+ 'quoteVolume': undefined,
281
+ 'info': ticker,
282
+ }, market);
283
+ }
284
+ async fetchTickers(symbols = undefined, params = {}) {
285
+ /**
286
+ * @method
287
+ * @name asacoine#fetchTickers
288
+ * @description fetches price tickers for multiple markets
289
+ * @see https://api.asacoine.com/api/v1/market/pairs/pricing
290
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the tickers for, all market tickers are returned if not assigned
291
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
292
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
293
+ */
294
+ const type = this.safeString(params, 'type', 'spot');
295
+ const request = this.omit(params, ['type']);
296
+ await this.loadMarkets(false, { 'type': type });
297
+ if (symbols !== undefined) {
298
+ symbols = this.marketSymbols(symbols);
299
+ }
300
+ let response = {};
301
+ if (type === 'otc') {
302
+ response = await this.publicGetV1MarketPairsCumulative(request);
303
+ }
304
+ else {
305
+ response = await this.publicGetV1MarketPairsPricing(request);
306
+ }
307
+ if (type === 'otc') {
308
+ const cumulativeData = this.safeDict(response, 'data', {});
309
+ const keys = this.safeList(cumulativeData, 'keys', []);
310
+ const values = this.safeList(cumulativeData, 'values', []);
311
+ const cumulativeTickers = {};
312
+ for (let i = 0; i < values.length; i++) {
313
+ const row = values[i];
314
+ const raw = {};
315
+ for (let j = 0; j < keys.length; j++) {
316
+ raw[keys[j]] = row[j];
317
+ }
318
+ const name = this.safeString(raw, 'name');
319
+ const [baseId, quoteId] = name.split('-');
320
+ const base = this.safeCurrencyCode(baseId);
321
+ const quote = this.safeCurrencyCode(quoteId);
322
+ const market = this.safeMarket(base + '/' + quote);
323
+ const parsed = this.parseTicker(this.safeDict(raw, 'orderBook', {}), market);
324
+ cumulativeTickers[parsed['symbol']] = parsed;
325
+ }
326
+ return this.filterByArrayTickers(cumulativeTickers, 'symbol', symbols);
327
+ }
328
+ const data = this.safeDict(response, 'data', {});
329
+ const baseIds = Object.keys(data);
330
+ const result = {};
331
+ for (let i = 0; i < baseIds.length; i++) {
332
+ const baseId = baseIds[i];
333
+ const quotes = this.safeDict(data, baseId, {});
334
+ const quoteIds = Object.keys(quotes);
335
+ for (let j = 0; j < quoteIds.length; j++) {
336
+ const quoteId = quoteIds[j];
337
+ const ticker = this.safeDict(quotes, quoteId, {});
338
+ const market = this.safeMarket(baseId + '/' + quoteId);
339
+ const parsed = this.parseTicker(ticker, market);
340
+ result[parsed['symbol']] = parsed;
341
+ }
342
+ }
343
+ return this.filterByArrayTickers(result, 'symbol', symbols);
344
+ }
345
+ async fetchTicker(symbol, params = {}) {
346
+ /**
347
+ * @method
348
+ * @name asacoine#fetchTicker
349
+ * @description fetches a price ticker, a statistical calculation for a specific market
350
+ * @see https://api.asacoine.com/api/v1/market/pairs/pricing
351
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
352
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
353
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
354
+ */
355
+ const tickers = await this.fetchTickers([symbol], params);
356
+ return tickers[symbol];
357
+ }
358
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
359
+ const query = this.omit(params, this.extractParams(path));
360
+ let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
361
+ if (Object.keys(query).length) {
362
+ url += '?' + this.urlencode(query);
363
+ }
364
+ headers = {
365
+ 'Content-Type': 'application/json',
366
+ };
367
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
368
+ }
369
+ }