ccxt-ir 4.9.23 → 4.9.27

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,394 +4,396 @@
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 './abstract/iranexchange.js';
9
- // ---------------------------------------------------------------------------
10
- /**
11
- * @class iranexchange
12
- * @augments Exchange
13
- * @description Set rateLimit to 1000 if fully verified
14
- */
15
- export default class iranexchange extends Exchange {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'iranexchange',
19
- 'name': 'Iran Exchange',
20
- 'countries': ['IR'],
21
- 'rateLimit': 1000,
22
- 'version': '1',
23
- 'certified': false,
24
- 'pro': false,
25
- 'timeout': 30000,
26
- 'has': {
27
- 'CORS': undefined,
28
- 'spot': false,
29
- 'margin': false,
30
- 'swap': false,
31
- 'future': false,
32
- 'option': false,
33
- 'addMargin': false,
34
- 'cancelAllOrders': false,
35
- 'cancelOrder': false,
36
- 'cancelOrders': false,
37
- 'createDepositAddress': false,
38
- 'createOrder': false,
39
- 'createStopLimitOrder': false,
40
- 'createStopMarketOrder': false,
41
- 'createStopOrder': false,
42
- 'editOrder': false,
43
- 'fetchBalance': false,
44
- 'fetchBorrowInterest': false,
45
- 'fetchBorrowRateHistories': false,
46
- 'fetchBorrowRateHistory': false,
47
- 'fetchClosedOrders': false,
48
- 'fetchCrossBorrowRate': false,
49
- 'fetchCrossBorrowRates': false,
50
- 'fetchCurrencies': false,
51
- 'fetchDepositAddress': false,
52
- 'fetchDeposits': false,
53
- 'fetchFundingHistory': false,
54
- 'fetchFundingRate': false,
55
- 'fetchFundingRateHistory': false,
56
- 'fetchFundingRates': false,
57
- 'fetchIndexOHLCV': false,
58
- 'fetchIsolatedBorrowRate': false,
59
- 'fetchIsolatedBorrowRates': false,
60
- 'fetchL2OrderBook': false,
61
- 'fetchLedger': false,
62
- 'fetchLedgerEntry': false,
63
- 'fetchLeverageTiers': false,
64
- 'fetchMarkets': true,
65
- 'fetchMarkOHLCV': false,
66
- 'fetchMyTrades': false,
67
- 'fetchOHLCV': false,
68
- 'fetchOpenInterestHistory': false,
69
- 'fetchOpenOrders': false,
70
- 'fetchOrder': false,
71
- 'fetchOrderBook': false,
72
- 'fetchOrders': false,
73
- 'fetchOrderTrades': 'emulated',
74
- 'fetchPositions': false,
75
- 'fetchPremiumIndexOHLCV': false,
76
- 'fetchTicker': true,
77
- 'fetchTickers': true,
78
- 'fetchTime': false,
79
- 'fetchTrades': false,
80
- 'fetchTradingFee': false,
81
- 'fetchTradingFees': false,
82
- 'fetchWithdrawals': false,
83
- 'otc': true,
84
- 'setLeverage': false,
85
- 'setMarginMode': false,
86
- 'transfer': false,
87
- 'withdraw': false,
88
- },
89
- 'comment': 'This comment is optional',
90
- 'urls': {
91
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/iran-exchange/64x64.png',
92
- 'api': {
93
- 'public': 'https://api.iranexchange.com/api/public/modules/crypto',
94
- },
95
- 'www': 'https://iranexchange.com/',
96
- 'doc': [
97
- 'https://iranexchange.com/',
98
- ],
99
- },
100
- 'api': {
101
- 'public': {
102
- 'get': {
103
- 'v1/client/listProduct': 1,
104
- 'v1/client/getBySymbol': 1,
105
- },
106
- },
107
- },
108
- 'fees': {
109
- 'trading': {
110
- 'tierBased': false,
111
- 'percentage': true,
112
- 'maker': this.parseNumber('0.001'),
113
- 'taker': this.parseNumber('0.001'),
114
- },
115
- },
116
- });
117
- }
118
- async fetchMarkets(params = {}) {
119
- /**
120
- * @method
121
- * @name iranexchange#fetchMarkets
122
- * @description retrieves data on all markets for iranexchange
123
- * @see https://iranexchange.co/
124
- * @param {object} [params] extra parameters specific to the exchange API endpoint
125
- * @returns {object[]} an array of objects representing market data
126
- */
127
- const response = await this.publicGetV1ClientListProduct();
128
- const markets = this.safeList(response, 'data');
129
- const result = [];
130
- for (let i = 0; i < markets.length; i++) {
131
- const market = this.parseMarket(markets[i]);
132
- result.push(market);
133
- }
134
- return result;
135
- }
136
- parseMarket(market) {
137
- // {
138
- // _id: "60b08a57b202353abb592032",
139
- // name: "Bitcoin",
140
- // fa_name: "بیت کوین",
141
- // symbol: "BTC",
142
- // slug: "bitcoin",
143
- // is_sell_to_customer_active: 1,
144
- // is_fast_sell_to_customer_active: 1,
145
- // is_buy_from_customer_active: 1,
146
- // logo: "https://iranexchange.com/strapi/media/BTC_78d99b9d12.png",
147
- // dollar_price: 89240.18,
148
- // sell_to_iranicard_currency_price: 1234526,
149
- // buy_from_iranicard_currency_price: 1239474,
150
- // fast_sell_to_iranicard_currency_price: 1234526,
151
- // buy_from_iranicard_network_list: [
152
- // {
153
- // network: "BTC",
154
- // name: "Bitcoin",
155
- // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
156
- // coin: "BTC",
157
- // withdrawEnable: true,
158
- // depositEnable: true,
159
- // withdrawMin: "0.000100000",
160
- // withdrawMax: null,
161
- // withdrawFee: "0.000100000",
162
- // sameAddress: false,
163
- // memoRegex: null,
164
- // tradeEnable: true
165
- // }
166
- // ],
167
- // sell_to_iranicard_network_list: [
168
- // {
169
- // network: "BTC",
170
- // name: "Bitcoin",
171
- // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
172
- // coin: "BTC",
173
- // withdrawEnable: true,
174
- // depositEnable: true,
175
- // withdrawMin: "0.000100000",
176
- // withdrawMax: null,
177
- // withdrawFee: "0.000100000",
178
- // sameAddress: false,
179
- // memoRegex: null,
180
- // tradeEnable: true
181
- // }
182
- // ],
183
- // is_price_maker_active: 1,
184
- // quotation: {
185
- // maxPrice: "90199.99",
186
- // minPrice: "88925",
187
- // dailyChangePercent: "-0.26"
188
- // },
189
- // dailyChangePercent: -0.26,
190
- // order: 0,
191
- // stock_status: "in_stock",
192
- // stock_label: null,
193
- // stock_description: null
194
- // },
195
- const id = this.safeString(market, 'symbol') + '_' + 'IRT';
196
- let baseId = this.safeString(market, 'symbol');
197
- let quoteId = 'IRT';
198
- const base = this.safeCurrencyCode(baseId);
199
- const quote = this.safeCurrencyCode(quoteId);
200
- baseId = baseId.toLowerCase();
201
- quoteId = quoteId.toLowerCase();
202
- return {
203
- 'id': id,
204
- 'symbol': base + '/' + quote,
205
- 'base': base,
206
- 'quote': quote,
207
- 'settle': undefined,
208
- 'baseId': baseId,
209
- 'quoteId': quoteId,
210
- 'settleId': undefined,
211
- 'type': 'otc',
212
- 'spot': false,
213
- 'margin': false,
214
- 'swap': false,
215
- 'future': false,
216
- 'option': false,
217
- 'active': true,
218
- 'contract': false,
219
- 'linear': undefined,
220
- 'inverse': undefined,
221
- 'contractSize': undefined,
222
- 'expiry': undefined,
223
- 'expiryDatetime': undefined,
224
- 'strike': undefined,
225
- 'optionType': undefined,
226
- 'precision': {
227
- 'amount': undefined,
228
- 'price': undefined,
229
- },
230
- 'limits': {
231
- 'leverage': {
232
- 'min': undefined,
233
- 'max': undefined,
234
- },
235
- 'amount': {
236
- 'min': undefined,
237
- 'max': undefined,
238
- },
239
- 'price': {
240
- 'min': undefined,
241
- 'max': undefined,
242
- },
243
- 'cost': {
244
- 'min': undefined,
245
- 'max': undefined,
246
- },
247
- },
248
- 'created': undefined,
249
- 'info': market,
250
- };
251
- }
252
- async fetchTickers(symbols = undefined, params = {}) {
253
- /**
254
- * @method
255
- * @name iranexchange#fetchTickers
256
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
257
- * @see https://iranexchange.co/
258
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
259
- * @param {object} [params] extra parameters specific to the exchange API endpoint
260
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
261
- */
262
- await this.loadMarkets();
263
- if (symbols !== undefined) {
264
- symbols = this.marketSymbols(symbols);
265
- }
266
- const response = await this.publicGetV1ClientListProduct();
267
- const markets = this.safeList(response, 'data');
268
- const result = {};
269
- for (let i = 0; i < markets.length; i++) {
270
- const ticker = this.parseTicker(markets[i]);
271
- const symbol = ticker['symbol'];
272
- result[symbol] = ticker;
273
- }
274
- return this.filterByArrayTickers(result, 'symbol', symbols);
275
- }
276
- async fetchTicker(symbol, params = {}) {
277
- /**
278
- * @method
279
- * @name iranexchange#fetchTicker
280
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
281
- * @see https://iranexchange.co/
282
- * @param {string} symbol unified symbol of the market to fetch the ticker for
283
- * @param {object} [params] extra parameters specific to the exchange API endpoint
284
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
285
- */
286
- await this.loadMarkets();
287
- const market = this.market(symbol);
288
- const request = {
289
- 'id': market['base'],
290
- };
291
- const response = await this.publicGetV1ClientGetBySymbol(request);
292
- const marketData = this.safeDict(response, 'data');
293
- const ticker = this.parseTicker(marketData);
294
- return ticker;
295
- }
296
- parseTicker(ticker, market = undefined) {
297
- // {
298
- // _id: "60b08a57b202353abb592032",
299
- // name: "Bitcoin",
300
- // fa_name: "بیت کوین",
301
- // symbol: "BTC",
302
- // slug: "bitcoin",
303
- // is_sell_to_customer_active: 1,
304
- // is_fast_sell_to_customer_active: 1,
305
- // is_buy_from_customer_active: 1,
306
- // logo: "https://iranexchange.com/strapi/media/BTC_78d99b9d12.png",
307
- // dollar_price: 89240.18,
308
- // sell_to_iranicard_currency_price: 1234526,
309
- // buy_from_iranicard_currency_price: 1239474,
310
- // fast_sell_to_iranicard_currency_price: 1234526,
311
- // buy_from_iranicard_network_list: [
312
- // {
313
- // network: "BTC",
314
- // name: "Bitcoin",
315
- // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
316
- // coin: "BTC",
317
- // withdrawEnable: true,
318
- // depositEnable: true,
319
- // withdrawMin: "0.000100000",
320
- // withdrawMax: null,
321
- // withdrawFee: "0.000100000",
322
- // sameAddress: false,
323
- // memoRegex: null,
324
- // tradeEnable: true
325
- // }
326
- // ],
327
- // sell_to_iranicard_network_list: [
328
- // {
329
- // network: "BTC",
330
- // name: "Bitcoin",
331
- // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
332
- // coin: "BTC",
333
- // withdrawEnable: true,
334
- // depositEnable: true,
335
- // withdrawMin: "0.000100000",
336
- // withdrawMax: null,
337
- // withdrawFee: "0.000100000",
338
- // sameAddress: false,
339
- // memoRegex: null,
340
- // tradeEnable: true
341
- // }
342
- // ],
343
- // is_price_maker_active: 1,
344
- // quotation: {
345
- // maxPrice: "90199.99",
346
- // minPrice: "88925",
347
- // dailyChangePercent: "-0.26"
348
- // },
349
- // dailyChangePercent: -0.26,
350
- // order: 0,
351
- // stock_status: "in_stock",
352
- // stock_label: null,
353
- // stock_description: null
354
- // }
355
- const marketType = 'otc';
356
- const marketId = this.safeString(ticker, 'symbol') + '_' + 'IRT';
357
- const symbol = this.safeSymbol(marketId, market, undefined, marketType);
358
- const quotation = this.safeValue(ticker, 'quotation', {});
359
- const high = this.safeFloat(quotation, 'maxPrice', 0);
360
- const low = this.safeFloat(quotation, 'minPrice', 0);
361
- const bid = this.safeFloat(ticker, 'sell_to_iranicard_currency_price', 0);
362
- const ask = this.safeFloat(ticker, 'buy_from_iranicard_currency_price', 0);
363
- const last = this.safeFloat(ticker, 'sell_to_iranicard_currency_price', 0);
364
- const change = this.safeFloat(quotation, 'dailyChangePercent', 0);
365
- return this.safeTicker({
366
- 'symbol': symbol,
367
- 'timestamp': undefined,
368
- 'datetime': undefined,
369
- 'high': high,
370
- 'low': low,
371
- 'bid': bid,
372
- 'bidVolume': undefined,
373
- 'ask': ask,
374
- 'askVolume': undefined,
375
- 'vwap': undefined,
376
- 'open': last,
377
- 'close': last,
378
- 'last': last,
379
- 'previousClose': undefined,
380
- 'change': change,
381
- 'percentage': change,
382
- 'average': undefined,
383
- 'baseVolume': undefined,
384
- 'quoteVolume': undefined,
385
- 'info': ticker,
386
- }, market);
387
- }
388
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
389
- const query = this.omit(params, this.extractParams(path));
390
- let url = this.urls['api']['public'] + '/' + path + '?' + this.urlencode(query);
391
- if (params['id'] !== undefined) {
392
- url = this.urls['api']['public'] + '/' + path + '/' + params['id'];
393
- }
394
- headers = { 'Content-Type': 'application/json' };
395
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
396
- }
397
- }
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/iranexchange.js';
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class iranexchange
12
+ * @augments Exchange
13
+ * @description Set rateLimit to 1000 if fully verified
14
+ */
15
+ export default class iranexchange extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'iranexchange',
19
+ 'name': 'Iran Exchange',
20
+ 'countries': ['IR'],
21
+ 'rateLimit': 1000,
22
+ 'version': '1',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'timeout': 30000,
26
+ 'has': {
27
+ 'CORS': undefined,
28
+ 'spot': false,
29
+ 'margin': false,
30
+ 'swap': false,
31
+ 'future': false,
32
+ 'option': false,
33
+ 'addMargin': false,
34
+ 'cancelAllOrders': false,
35
+ 'cancelOrder': false,
36
+ 'cancelOrders': false,
37
+ 'createDepositAddress': false,
38
+ 'createOrder': false,
39
+ 'createStopLimitOrder': false,
40
+ 'createStopMarketOrder': false,
41
+ 'createStopOrder': false,
42
+ 'editOrder': false,
43
+ 'fetchBalance': false,
44
+ 'fetchBorrowInterest': false,
45
+ 'fetchBorrowRateHistories': false,
46
+ 'fetchBorrowRateHistory': false,
47
+ 'fetchClosedOrders': false,
48
+ 'fetchCrossBorrowRate': false,
49
+ 'fetchCrossBorrowRates': false,
50
+ 'fetchCurrencies': false,
51
+ 'fetchDepositAddress': false,
52
+ 'fetchDeposits': false,
53
+ 'fetchFundingHistory': false,
54
+ 'fetchFundingRate': false,
55
+ 'fetchFundingRateHistory': false,
56
+ 'fetchFundingRates': false,
57
+ 'fetchIndexOHLCV': false,
58
+ 'fetchIsolatedBorrowRate': false,
59
+ 'fetchIsolatedBorrowRates': false,
60
+ 'fetchL2OrderBook': false,
61
+ 'fetchLedger': false,
62
+ 'fetchLedgerEntry': false,
63
+ 'fetchLeverageTiers': false,
64
+ 'fetchMarkets': true,
65
+ 'fetchMarkOHLCV': false,
66
+ 'fetchMyTrades': false,
67
+ 'fetchOHLCV': false,
68
+ 'fetchOpenInterestHistory': false,
69
+ 'fetchOpenOrders': false,
70
+ 'fetchOrder': false,
71
+ 'fetchOrderBook': false,
72
+ 'fetchOrders': false,
73
+ 'fetchOrderTrades': 'emulated',
74
+ 'fetchPositions': false,
75
+ 'fetchPremiumIndexOHLCV': false,
76
+ 'fetchTicker': true,
77
+ 'fetchTickers': true,
78
+ 'fetchTime': false,
79
+ 'fetchTrades': false,
80
+ 'fetchTradingFee': false,
81
+ 'fetchTradingFees': false,
82
+ 'fetchWithdrawals': false,
83
+ 'otc': true,
84
+ 'setLeverage': false,
85
+ 'setMarginMode': false,
86
+ 'transfer': false,
87
+ 'withdraw': false,
88
+ },
89
+ 'comment': 'This comment is optional',
90
+ 'urls': {
91
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/iran-exchange/64x64.png',
92
+ 'api': {
93
+ 'public': 'https://api.iranexchange.com/api/public/modules/crypto',
94
+ },
95
+ 'www': 'https://iranexchange.com/',
96
+ 'doc': [
97
+ 'https://iranexchange.com/',
98
+ ],
99
+ },
100
+ 'api': {
101
+ 'public': {
102
+ 'get': {
103
+ 'v1/client/listProduct': 1,
104
+ 'v1/client/getBySymbol': 1,
105
+ },
106
+ },
107
+ },
108
+ 'fees': {
109
+ 'trading': {
110
+ 'tierBased': false,
111
+ 'percentage': true,
112
+ 'maker': this.parseNumber('0.001'),
113
+ 'taker': this.parseNumber('0.001'),
114
+ },
115
+ },
116
+ });
117
+ }
118
+ async fetchMarkets(params = {}) {
119
+ /**
120
+ * @method
121
+ * @name iranexchange#fetchMarkets
122
+ * @description retrieves data on all markets for iranexchange
123
+ * @see https://iranexchange.co/
124
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
125
+ * @returns {object[]} an array of objects representing market data
126
+ */
127
+ const response = await this.publicGetV1ClientListProduct();
128
+ const markets = this.safeList(response, 'data');
129
+ const result = [];
130
+ for (let i = 0; i < markets.length; i++) {
131
+ const market = this.parseMarket(markets[i]);
132
+ result.push(market);
133
+ }
134
+ return result;
135
+ }
136
+ parseMarket(market) {
137
+ // {
138
+ // _id: "60b08a57b202353abb592032",
139
+ // name: "Bitcoin",
140
+ // fa_name: "بیت کوین",
141
+ // symbol: "BTC",
142
+ // slug: "bitcoin",
143
+ // is_sell_to_customer_active: 1,
144
+ // is_fast_sell_to_customer_active: 1,
145
+ // is_buy_from_customer_active: 1,
146
+ // logo: "https://iranexchange.com/strapi/media/BTC_78d99b9d12.png",
147
+ // dollar_price: 89240.18,
148
+ // sell_to_iranicard_currency_price: 1234526,
149
+ // buy_from_iranicard_currency_price: 1239474,
150
+ // fast_sell_to_iranicard_currency_price: 1234526,
151
+ // buy_from_iranicard_network_list: [
152
+ // {
153
+ // network: "BTC",
154
+ // name: "Bitcoin",
155
+ // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
156
+ // coin: "BTC",
157
+ // withdrawEnable: true,
158
+ // depositEnable: true,
159
+ // withdrawMin: "0.000100000",
160
+ // withdrawMax: null,
161
+ // withdrawFee: "0.000100000",
162
+ // sameAddress: false,
163
+ // memoRegex: null,
164
+ // tradeEnable: true
165
+ // }
166
+ // ],
167
+ // sell_to_iranicard_network_list: [
168
+ // {
169
+ // network: "BTC",
170
+ // name: "Bitcoin",
171
+ // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
172
+ // coin: "BTC",
173
+ // withdrawEnable: true,
174
+ // depositEnable: true,
175
+ // withdrawMin: "0.000100000",
176
+ // withdrawMax: null,
177
+ // withdrawFee: "0.000100000",
178
+ // sameAddress: false,
179
+ // memoRegex: null,
180
+ // tradeEnable: true
181
+ // }
182
+ // ],
183
+ // is_price_maker_active: 1,
184
+ // quotation: {
185
+ // maxPrice: "90199.99",
186
+ // minPrice: "88925",
187
+ // dailyChangePercent: "-0.26"
188
+ // },
189
+ // dailyChangePercent: -0.26,
190
+ // order: 0,
191
+ // stock_status: "in_stock",
192
+ // stock_label: null,
193
+ // stock_description: null
194
+ // },
195
+ const id = this.safeString(market, 'symbol') + '_' + 'IRT';
196
+ let baseId = this.safeString(market, 'symbol');
197
+ let quoteId = 'IRT';
198
+ const base = this.safeCurrencyCode(baseId);
199
+ const quote = this.safeCurrencyCode(quoteId);
200
+ baseId = baseId.toLowerCase();
201
+ quoteId = quoteId.toLowerCase();
202
+ return {
203
+ 'id': id,
204
+ 'symbol': base + '/' + quote,
205
+ 'base': base,
206
+ 'quote': quote,
207
+ 'settle': undefined,
208
+ 'baseId': baseId,
209
+ 'quoteId': quoteId,
210
+ 'settleId': undefined,
211
+ 'type': 'otc',
212
+ 'spot': false,
213
+ 'margin': false,
214
+ 'swap': false,
215
+ 'future': false,
216
+ 'option': false,
217
+ 'active': true,
218
+ 'contract': false,
219
+ 'linear': undefined,
220
+ 'inverse': undefined,
221
+ 'contractSize': undefined,
222
+ 'expiry': undefined,
223
+ 'expiryDatetime': undefined,
224
+ 'strike': undefined,
225
+ 'optionType': undefined,
226
+ 'precision': {
227
+ 'amount': undefined,
228
+ 'price': undefined,
229
+ },
230
+ 'limits': {
231
+ 'leverage': {
232
+ 'min': undefined,
233
+ 'max': undefined,
234
+ },
235
+ 'amount': {
236
+ 'min': undefined,
237
+ 'max': undefined,
238
+ },
239
+ 'price': {
240
+ 'min': undefined,
241
+ 'max': undefined,
242
+ },
243
+ 'cost': {
244
+ 'min': undefined,
245
+ 'max': undefined,
246
+ },
247
+ },
248
+ 'created': undefined,
249
+ 'info': market,
250
+ };
251
+ }
252
+ async fetchTickers(symbols = undefined, params = {}) {
253
+ /**
254
+ * @method
255
+ * @name iranexchange#fetchTickers
256
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
257
+ * @see https://iranexchange.co/
258
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
259
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
260
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
261
+ */
262
+ await this.loadMarkets();
263
+ if (symbols !== undefined) {
264
+ symbols = this.marketSymbols(symbols);
265
+ }
266
+ const response = await this.publicGetV1ClientListProduct();
267
+ const markets = this.safeList(response, 'data');
268
+ const result = {};
269
+ for (let i = 0; i < markets.length; i++) {
270
+ const ticker = this.parseTicker(markets[i]);
271
+ const symbol = ticker['symbol'];
272
+ result[symbol] = ticker;
273
+ }
274
+ return this.filterByArrayTickers(result, 'symbol', symbols);
275
+ }
276
+ async fetchTicker(symbol, params = {}) {
277
+ /**
278
+ * @method
279
+ * @name iranexchange#fetchTicker
280
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
281
+ * @see https://iranexchange.co/
282
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
283
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
284
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
285
+ */
286
+ await this.loadMarkets();
287
+ const market = this.market(symbol);
288
+ const request = {
289
+ 'id': market['base'],
290
+ };
291
+ const response = await this.publicGetV1ClientGetBySymbol(request);
292
+ const marketData = this.safeDict(response, 'data');
293
+ const ticker = this.parseTicker(marketData);
294
+ return ticker;
295
+ }
296
+ parseTicker(ticker, market = undefined) {
297
+ // {
298
+ // _id: "60b08a57b202353abb592032",
299
+ // name: "Bitcoin",
300
+ // fa_name: "بیت کوین",
301
+ // symbol: "BTC",
302
+ // slug: "bitcoin",
303
+ // is_sell_to_customer_active: 1,
304
+ // is_fast_sell_to_customer_active: 1,
305
+ // is_buy_from_customer_active: 1,
306
+ // logo: "https://iranexchange.com/strapi/media/BTC_78d99b9d12.png",
307
+ // dollar_price: 89240.18,
308
+ // sell_to_iranicard_currency_price: 1234526,
309
+ // buy_from_iranicard_currency_price: 1239474,
310
+ // fast_sell_to_iranicard_currency_price: 1234526,
311
+ // buy_from_iranicard_network_list: [
312
+ // {
313
+ // network: "BTC",
314
+ // name: "Bitcoin",
315
+ // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
316
+ // coin: "BTC",
317
+ // withdrawEnable: true,
318
+ // depositEnable: true,
319
+ // withdrawMin: "0.000100000",
320
+ // withdrawMax: null,
321
+ // withdrawFee: "0.000100000",
322
+ // sameAddress: false,
323
+ // memoRegex: null,
324
+ // tradeEnable: true
325
+ // }
326
+ // ],
327
+ // sell_to_iranicard_network_list: [
328
+ // {
329
+ // network: "BTC",
330
+ // name: "Bitcoin",
331
+ // addressRegex: "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$",
332
+ // coin: "BTC",
333
+ // withdrawEnable: true,
334
+ // depositEnable: true,
335
+ // withdrawMin: "0.000100000",
336
+ // withdrawMax: null,
337
+ // withdrawFee: "0.000100000",
338
+ // sameAddress: false,
339
+ // memoRegex: null,
340
+ // tradeEnable: true
341
+ // }
342
+ // ],
343
+ // is_price_maker_active: 1,
344
+ // quotation: {
345
+ // maxPrice: "90199.99",
346
+ // minPrice: "88925",
347
+ // dailyChangePercent: "-0.26"
348
+ // },
349
+ // dailyChangePercent: -0.26,
350
+ // order: 0,
351
+ // stock_status: "in_stock",
352
+ // stock_label: null,
353
+ // stock_description: null
354
+ // }
355
+ const marketType = 'otc';
356
+ const marketId = this.safeString(ticker, 'symbol') + '_' + 'IRT';
357
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
358
+ const quotation = this.safeValue(ticker, 'quotation', {});
359
+ const dollar_price = this.safeFloat(ticker, 'dollar_price', 0);
360
+ const high = this.safeFloat(quotation, 'maxPrice', 0) * dollar_price;
361
+ const low = this.safeFloat(quotation, 'minPrice', 0) * dollar_price;
362
+ const bid = this.safeFloat(ticker, 'sell_to_iranicard_currency_price', 0) * dollar_price;
363
+ const ask = this.safeFloat(ticker, 'buy_from_iranicard_currency_price', 0) * dollar_price;
364
+ const last = this.safeFloat(ticker, 'sell_to_iranicard_currency_price', 0) * dollar_price;
365
+ const change = this.safeFloat(quotation, 'dailyChangePercent', 0);
366
+ return this.safeTicker({
367
+ 'symbol': symbol,
368
+ 'timestamp': undefined,
369
+ 'datetime': undefined,
370
+ 'high': high,
371
+ 'low': low,
372
+ 'bid': bid,
373
+ 'bidVolume': undefined,
374
+ 'ask': ask,
375
+ 'askVolume': undefined,
376
+ 'vwap': undefined,
377
+ 'open': last,
378
+ 'close': last,
379
+ 'last': last,
380
+ 'previousClose': undefined,
381
+ 'change': change,
382
+ 'percentage': change,
383
+ 'average': undefined,
384
+ 'baseVolume': undefined,
385
+ 'quoteVolume': undefined,
386
+ 'info': ticker,
387
+ }, market);
388
+ }
389
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
390
+ const query = this.omit(params, this.extractParams(path));
391
+ let url = this.urls['api']['public'] + '/' + path + '?' + this.urlencode(query);
392
+ const pair_id = this.safeString(params, 'id');
393
+ if (pair_id !== undefined) {
394
+ url = this.urls['api']['public'] + '/' + path + '/' + pair_id;
395
+ }
396
+ headers = { 'Content-Type': 'application/json' };
397
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
398
+ }
399
+ }