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