ccxt-ir 4.9.16 → 4.9.19

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.
@@ -5,504 +5,507 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var ompfinex$1 = require('./abstract/ompfinex.js');
6
6
 
7
7
  // ----------------------------------------------------------------------------
8
- // ---------------------------------------------------------------------------
9
- /**
10
- * @class ompfinex
11
- * @augments Exchange
12
- * @description Set rateLimit to 1000 if fully verified
13
- */
14
- class ompfinex extends ompfinex$1["default"] {
15
- describe() {
16
- return this.deepExtend(super.describe(), {
17
- 'id': 'ompfinex',
18
- 'name': 'OMPFinex',
19
- 'countries': ['IR'],
20
- 'rateLimit': 1000,
21
- 'version': '1',
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
- 'addMargin': false,
32
- 'cancelAllOrders': false,
33
- 'cancelOrder': false,
34
- 'cancelOrders': false,
35
- 'createDepositAddress': false,
36
- 'createOrder': false,
37
- 'createStopLimitOrder': false,
38
- 'createStopMarketOrder': false,
39
- 'createStopOrder': false,
40
- 'editOrder': false,
41
- 'fetchBalance': false,
42
- 'fetchBorrowInterest': false,
43
- 'fetchBorrowRateHistories': false,
44
- 'fetchBorrowRateHistory': false,
45
- 'fetchClosedOrders': false,
46
- 'fetchCrossBorrowRate': false,
47
- 'fetchCrossBorrowRates': false,
48
- 'fetchCurrencies': false,
49
- 'fetchDepositAddress': false,
50
- 'fetchDeposits': false,
51
- 'fetchFundingHistory': false,
52
- 'fetchFundingRate': false,
53
- 'fetchFundingRateHistory': false,
54
- 'fetchFundingRates': false,
55
- 'fetchIndexOHLCV': false,
56
- 'fetchIsolatedBorrowRate': false,
57
- 'fetchIsolatedBorrowRates': false,
58
- 'fetchL2OrderBook': false,
59
- 'fetchLedger': false,
60
- 'fetchLedgerEntry': false,
61
- 'fetchLeverageTiers': false,
62
- 'fetchMarkets': true,
63
- 'fetchMarkOHLCV': false,
64
- 'fetchMyTrades': false,
65
- 'fetchOHLCV': true,
66
- 'fetchOpenInterestHistory': false,
67
- 'fetchOpenOrders': false,
68
- 'fetchOrder': false,
69
- 'fetchOrderBook': true,
70
- 'fetchOrders': false,
71
- 'fetchOrderTrades': 'emulated',
72
- 'fetchPositions': false,
73
- 'fetchPremiumIndexOHLCV': false,
74
- 'fetchTicker': true,
75
- 'fetchTickers': true,
76
- 'fetchTime': false,
77
- 'fetchTrades': false,
78
- 'fetchTradingFee': false,
79
- 'fetchTradingFees': false,
80
- 'fetchWithdrawals': false,
81
- 'setLeverage': false,
82
- 'setMarginMode': false,
83
- 'transfer': false,
84
- 'withdraw': false,
85
- },
86
- 'comment': 'This comment is optional',
87
- 'urls': {
88
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/ompfinex/64x64.png',
89
- 'api': {
90
- 'public': 'https://api.ompfinex.com',
91
- },
92
- 'www': 'https://www.ompfinex.com/',
93
- 'doc': [
94
- 'https://docs.ompfinex.com/',
95
- ],
96
- },
97
- 'timeframes': {
98
- '1h': '60',
99
- '3h': '180',
100
- '6h': '360',
101
- '12h': '720',
102
- '1d': '1D',
103
- '1W': '1W',
104
- '1M': '3M',
105
- },
106
- 'api': {
107
- 'public': {
108
- 'get': {
109
- 'v1/market': 1,
110
- 'v2/udf/real/history': 1,
111
- 'v1/orderbook': 1,
112
- },
113
- },
114
- },
115
- 'commonCurrencies': {
116
- 'IRR': 'IRT',
117
- },
118
- 'fees': {
119
- 'trading': {
120
- 'tierBased': false,
121
- 'percentage': true,
122
- 'maker': this.parseNumber('0.001'),
123
- 'taker': this.parseNumber('0.001'),
124
- },
125
- },
126
- });
127
- }
128
- async fetchMarkets(params = {}) {
129
- /**
130
- * @method
131
- * @name ompfinex#fetchMarkets
132
- * @description retrieves data on all markets for ompfinex
133
- * @see https://apidocs.ompfinex.ir/#6ae2dae4a2
134
- * @param {object} [params] extra parameters specific to the exchange API endpoint
135
- * @returns {object[]} an array of objects representing market data
136
- */
137
- const response = await this.publicGetV1Market();
138
- const markets = this.safeList(response, 'data');
139
- const result = [];
140
- for (let i = 0; i < markets.length; i++) {
141
- const market = this.parseMarket(markets[i]);
142
- result.push(market);
143
- }
144
- return result;
145
- }
146
- parseMarket(market) {
147
- // {
148
- // 'id': 1,
149
- // 'base_currency': {
150
- // 'id': 'BTC',
151
- // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/btc.png',
152
- // 'name': 'بیت کوین',
153
- // 'decimal_precision': 8,
154
- // },
155
- // 'quote_currency': {
156
- // 'id': 'IRR',
157
- // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/irt.png',
158
- // 'name': 'تومان',
159
- // 'decimal_precision': 0,
160
- // },
161
- // 'name': 'بیت کوین - تومان',
162
- // 'quote_currency_precision': 0,
163
- // 'base_currency_precision': 8,
164
- // 'history': [
165
- // '39904073000',
166
- // '39869830000',
167
- // '39724396000',
168
- // '39701684000',
169
- // '39712038000',
170
- // '39528137000',
171
- // '39639658000',
172
- // '39644885000',
173
- // '39654055000',
174
- // '39574451000',
175
- // '39615152000',
176
- // '39677500800',
177
- // '39606862870',
178
- // '39737426850',
179
- // '39546858000',
180
- // '39593530000',
181
- // '39385856000',
182
- // '39502536080',
183
- // '39527561000',
184
- // '39581729000',
185
- // '39637343000',
186
- // '39806512800',
187
- // '39616055090',
188
- // '39516007000',
189
- // ],
190
- // 'min_price': '39382265000',
191
- // 'max_price': '40128888990',
192
- // 'last_price': '39516007000',
193
- // 'last_volume': '186449950855',
194
- // 'day_change_percent': -0.97,
195
- // 'week_change_percent': 1.64,
196
- // 'tradingview_symbol': 'BINANCE:BTCUSDT',
197
- // 'is_visible': true,
198
- // }
199
- const baseAsset = this.safeDict(market, 'base_currency');
200
- const quoteAsset = this.safeDict(market, 'quote_currency');
201
- let baseId = this.safeStringUpper(baseAsset, 'id');
202
- let quoteId = this.safeStringUpper(quoteAsset, 'id');
203
- const id = this.safeValue(market, 'id');
204
- const base = this.safeCurrencyCode(baseId);
205
- const quote = this.safeCurrencyCode(quoteId);
206
- baseId = baseId.toLowerCase();
207
- quoteId = quoteId.toLowerCase();
208
- return {
209
- 'id': id,
210
- 'symbol': base + '/' + quote,
211
- 'base': base,
212
- 'quote': quote,
213
- 'settle': undefined,
214
- 'baseId': baseId,
215
- 'quoteId': quoteId,
216
- 'settleId': undefined,
217
- 'type': 'spot',
218
- 'spot': true,
219
- 'margin': false,
220
- 'swap': false,
221
- 'future': false,
222
- 'option': false,
223
- 'active': true,
224
- 'contract': false,
225
- 'linear': undefined,
226
- 'inverse': undefined,
227
- 'contractSize': undefined,
228
- 'expiry': undefined,
229
- 'expiryDatetime': undefined,
230
- 'strike': undefined,
231
- 'optionType': undefined,
232
- 'precision': {
233
- 'amount': undefined,
234
- 'price': undefined,
235
- },
236
- 'limits': {
237
- 'leverage': {
238
- 'min': undefined,
239
- 'max': undefined,
240
- },
241
- 'amount': {
242
- 'min': undefined,
243
- 'max': undefined,
244
- },
245
- 'price': {
246
- 'min': undefined,
247
- 'max': undefined,
248
- },
249
- 'cost': {
250
- 'min': undefined,
251
- 'max': undefined,
252
- },
253
- },
254
- 'created': undefined,
255
- 'info': market,
256
- };
257
- }
258
- async fetchTickers(symbols = undefined, params = {}) {
259
- /**
260
- * @method
261
- * @name ompfinex#fetchTickers
262
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
263
- * @see https://docs.ompfinex.com/?shell#5f1cfe9299
264
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
265
- * @param {object} [params] extra parameters specific to the exchange API endpoint
266
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
267
- */
268
- await this.loadMarkets();
269
- if (symbols !== undefined) {
270
- symbols = this.marketSymbols(symbols);
271
- }
272
- const response = await this.publicGetV1Market();
273
- const markets = this.safeList(response, 'data');
274
- const result = {};
275
- for (let i = 0; i < markets.length; i++) {
276
- const ticker = this.parseTicker(markets[i]);
277
- const symbol = ticker['symbol'];
278
- result[symbol] = ticker;
279
- }
280
- return this.filterByArrayTickers(result, 'symbol', symbols);
281
- }
282
- async fetchTicker(symbol, params = {}) {
283
- /**
284
- * @method
285
- * @name ompfinex#fetchTicker
286
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
287
- * @see https://docs.ompfinex.com/?shell#5f1cfe9299
288
- * @param {string} symbol unified symbol of the market to fetch the ticker for
289
- * @param {object} [params] extra parameters specific to the exchange API endpoint
290
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
291
- */
292
- await this.loadMarkets();
293
- const market = this.market(symbol);
294
- const request = {
295
- 'id': market['id'],
296
- };
297
- const response = await this.publicGetV1Market(request);
298
- const markets = this.safeDict(response, 'data');
299
- const ticker = this.parseTicker(markets);
300
- return ticker;
301
- }
302
- parseTicker(ticker, market = undefined) {
303
- // {
304
- // 'id': 1,
305
- // 'base_currency': {
306
- // 'id': 'BTC',
307
- // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/btc.png',
308
- // 'name': 'بیت کوین',
309
- // 'decimal_precision': 8,
310
- // },
311
- // 'quote_currency': {
312
- // 'id': 'IRR',
313
- // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/irt.png',
314
- // 'name': 'تومان',
315
- // 'decimal_precision': 0,
316
- // },
317
- // 'name': 'بیت کوین - تومان',
318
- // 'quote_currency_precision': 0,
319
- // 'base_currency_precision': 8,
320
- // 'history': [
321
- // '39904073000',
322
- // '39869830000',
323
- // '39724396000',
324
- // '39701684000',
325
- // '39712038000',
326
- // '39528137000',
327
- // '39639658000',
328
- // '39644885000',
329
- // '39654055000',
330
- // '39574451000',
331
- // '39615152000',
332
- // '39677500800',
333
- // '39606862870',
334
- // '39737426850',
335
- // '39546858000',
336
- // '39593530000',
337
- // '39385856000',
338
- // '39502536080',
339
- // '39527561000',
340
- // '39581729000',
341
- // '39637343000',
342
- // '39806512800',
343
- // '39616055090',
344
- // '39516007000',
345
- // ],
346
- // 'min_price': '39382265000',
347
- // 'max_price': '40128888990',
348
- // 'last_price': '39516007000',
349
- // 'last_volume': '186449950855',
350
- // 'day_change_percent': -0.97,
351
- // 'week_change_percent': 1.64,
352
- // 'tradingview_symbol': 'BINANCE:BTCUSDT',
353
- // 'is_visible': true,
354
- // }
355
- const marketType = 'spot';
356
- const marketId = this.safeValue(ticker, 'id');
357
- const marketinfo = this.market(marketId);
358
- const symbol = this.safeSymbol(marketId, market, undefined, marketType);
359
- let high = this.safeFloat(ticker, 'max_price');
360
- let low = this.safeFloat(ticker, 'min_price');
361
- const change = this.safeFloat(ticker, 'day_change_percent');
362
- let last = this.safeFloat(ticker, 'last_price');
363
- let quoteVolume = this.safeFloat(ticker, 'last_volume');
364
- if (marketinfo['quote'] === 'IRT') {
365
- high = high ? high * 10 : 0;
366
- low = low ? low / 10 : 0;
367
- last = last ? last / 10 : 0;
368
- quoteVolume = quoteVolume ? quoteVolume / 10 : 0;
369
- }
370
- let baseVolume = 0;
371
- if (last) {
372
- baseVolume = quoteVolume / last;
373
- }
374
- return this.safeTicker({
375
- 'symbol': symbol,
376
- 'timestamp': undefined,
377
- 'datetime': undefined,
378
- 'high': high,
379
- 'low': low,
380
- 'bid': undefined,
381
- 'bidVolume': undefined,
382
- 'ask': undefined,
383
- 'askVolume': undefined,
384
- 'vwap': undefined,
385
- 'open': last,
386
- 'close': last,
387
- 'last': last,
388
- 'previousClose': undefined,
389
- 'change': change,
390
- 'percentage': undefined,
391
- 'average': undefined,
392
- 'baseVolume': baseVolume,
393
- 'quoteVolume': quoteVolume,
394
- 'info': ticker,
395
- }, market);
396
- }
397
- async fetchOHLCV(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
398
- /**
399
- * @method
400
- * @name ompfinex#fetchOHLCV
401
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
402
- * @see https://docs.ompfinex.com/?shell#ohlc
403
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
404
- * @param {string} timeframe the length of time each candle represents
405
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
406
- * @param {int} [limit] the maximum amount of candles to fetch
407
- * @param {object} [params] extra parameters specific to the exchange API endpoint
408
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
409
- */
410
- await this.loadMarkets();
411
- const market = this.market(symbol);
412
- if (market['quote'] === 'IRT') {
413
- symbol = market['base'] + 'IRR';
414
- }
415
- const endTime = Date.now();
416
- const request = {
417
- 'symbol': symbol.replace('/', ''),
418
- 'from': (endTime / 1000) - (24 * 60 * 60),
419
- 'to': endTime / 1000,
420
- 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
421
- // 'limit': 500,
422
- };
423
- if (since !== undefined) {
424
- request['from'] = since / 1000;
425
- }
426
- request['from'] = this.safeInteger(request, 'from');
427
- request['to'] = this.safeInteger(request, 'to');
428
- if (timeframe !== undefined) {
429
- request['resolution'] = this.safeString(this.timeframes, timeframe, timeframe);
430
- }
431
- const response = await this.publicGetV2UdfRealHistory(request);
432
- const openList = this.safeValue(response, 'o', []);
433
- const highList = this.safeList(response, 'h', []);
434
- const lastList = this.safeList(response, 'l', []);
435
- const closeList = this.safeList(response, 'c', []);
436
- const volumeList = this.safeList(response, 'v', []);
437
- const timestampList = this.safeList(response, 't', []);
438
- const ohlcvs = [];
439
- for (let i = 0; i < openList.length; i++) {
440
- if (market['quote'] === 'IRT') {
441
- openList[i] = openList[i] ? openList[i] / 10 : 0;
442
- highList[i] = highList[i] ? highList[i] / 10 : 0;
443
- lastList[i] = lastList[i] ? lastList[i] / 10 : 0;
444
- closeList[i] = closeList[i] ? closeList[i] / 10 : 0;
445
- volumeList[i] = volumeList[i] ? volumeList[i] / 10 : 0;
446
- }
447
- ohlcvs.push([
448
- timestampList[i],
449
- openList[i],
450
- highList[i],
451
- lastList[i],
452
- closeList[i],
453
- volumeList[i],
454
- ]);
455
- }
456
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
457
- }
458
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
459
- /**
460
- * @method
461
- * @name ompfinex#fetchOrderBooks
462
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
463
- * @see https://docs.ompfinex.com/?shell#f2150d7710
464
- * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
465
- * @param {int} [limit] max number of entries per orderbook to return, default is undefined
466
- * @param {object} [params] extra parameters specific to the exchange API endpoint
467
- * @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
468
- */
469
- await this.loadMarkets();
470
- const market = this.market(symbol);
471
- const response = await this.publicGetV1Orderbook();
472
- let orderbook = this.safeDict(response, 'data');
473
- if (market['quote'] === 'IRT') {
474
- orderbook = this.safeDict(orderbook, market['base'] + 'IRR');
475
- const bids = this.safeList(orderbook, 'bids');
476
- const asks = this.safeList(orderbook, 'asks');
477
- for (let i = 0; i < bids.length; i++) {
478
- bids[i][0] = bids[i][0] ? bids[i][0] / 10 : 0;
479
- }
480
- for (let i = 0; i < asks.length; i++) {
481
- asks[i][0] = asks[i][0] ? asks[i][0] / 10 : 0;
482
- }
483
- orderbook['bids'] = asks;
484
- orderbook['asks'] = bids;
485
- }
486
- else {
487
- orderbook = this.safeDict(orderbook, market['base'] + market['quote']);
488
- }
489
- const timestamp = Date.now();
490
- return this.parseOrderBook(orderbook, symbol, timestamp, 'bids', 'asks', 'price', 'amount');
491
- }
492
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
493
- const query = this.omit(params, this.extractParams(path));
494
- let url = this.urls['api']['public'] + '/' + path;
495
- // safer check
496
- const pair_id = this.safeString(params, 'id');
497
- if (pair_id !== undefined) {
498
- url = url + '/' + pair_id;
499
- }
500
- if (path === 'v2/udf/real/history') {
501
- url = this.urls['api']['public'] + '/' + path + '?' + this.urlencode(query);
502
- }
503
- headers = { 'Content-Type': 'application/json' };
504
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
505
- }
8
+ // ---------------------------------------------------------------------------
9
+ /**
10
+ * @class ompfinex
11
+ * @augments Exchange
12
+ * @description Set rateLimit to 1000 if fully verified
13
+ */
14
+ class ompfinex extends ompfinex$1["default"] {
15
+ describe() {
16
+ return this.deepExtend(super.describe(), {
17
+ 'id': 'ompfinex',
18
+ 'name': 'OMPFinex',
19
+ 'countries': ['IR'],
20
+ 'rateLimit': 1000,
21
+ 'version': '1',
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
+ 'addMargin': false,
32
+ 'cancelAllOrders': false,
33
+ 'cancelOrder': false,
34
+ 'cancelOrders': false,
35
+ 'createDepositAddress': false,
36
+ 'createOrder': false,
37
+ 'createStopLimitOrder': false,
38
+ 'createStopMarketOrder': false,
39
+ 'createStopOrder': false,
40
+ 'editOrder': false,
41
+ 'fetchBalance': false,
42
+ 'fetchBorrowInterest': false,
43
+ 'fetchBorrowRateHistories': false,
44
+ 'fetchBorrowRateHistory': false,
45
+ 'fetchClosedOrders': false,
46
+ 'fetchCrossBorrowRate': false,
47
+ 'fetchCrossBorrowRates': false,
48
+ 'fetchCurrencies': false,
49
+ 'fetchDepositAddress': false,
50
+ 'fetchDeposits': false,
51
+ 'fetchFundingHistory': false,
52
+ 'fetchFundingRate': false,
53
+ 'fetchFundingRateHistory': false,
54
+ 'fetchFundingRates': false,
55
+ 'fetchIndexOHLCV': false,
56
+ 'fetchIsolatedBorrowRate': false,
57
+ 'fetchIsolatedBorrowRates': false,
58
+ 'fetchL2OrderBook': false,
59
+ 'fetchLedger': false,
60
+ 'fetchLedgerEntry': false,
61
+ 'fetchLeverageTiers': false,
62
+ 'fetchMarkets': true,
63
+ 'fetchMarkOHLCV': false,
64
+ 'fetchMyTrades': false,
65
+ 'fetchOHLCV': true,
66
+ 'fetchOpenInterestHistory': false,
67
+ 'fetchOpenOrders': false,
68
+ 'fetchOrder': false,
69
+ 'fetchOrderBook': true,
70
+ 'fetchOrders': false,
71
+ 'fetchOrderTrades': 'emulated',
72
+ 'fetchPositions': false,
73
+ 'fetchPremiumIndexOHLCV': false,
74
+ 'fetchTicker': true,
75
+ 'fetchTickers': true,
76
+ 'fetchTime': false,
77
+ 'fetchTrades': false,
78
+ 'fetchTradingFee': false,
79
+ 'fetchTradingFees': false,
80
+ 'fetchWithdrawals': false,
81
+ 'setLeverage': false,
82
+ 'setMarginMode': false,
83
+ 'transfer': false,
84
+ 'withdraw': false,
85
+ },
86
+ 'comment': 'This comment is optional',
87
+ 'urls': {
88
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/ompfinex/64x64.png',
89
+ 'api': {
90
+ 'public': 'https://api.ompfinex.com',
91
+ },
92
+ 'www': 'https://www.ompfinex.com/',
93
+ 'doc': [
94
+ 'https://docs.ompfinex.com/',
95
+ ],
96
+ },
97
+ 'timeframes': {
98
+ '1h': '60',
99
+ '3h': '180',
100
+ '6h': '360',
101
+ '12h': '720',
102
+ '1d': '1D',
103
+ '1W': '1W',
104
+ '1M': '3M',
105
+ },
106
+ 'api': {
107
+ 'public': {
108
+ 'get': {
109
+ 'v1/market': 1,
110
+ 'v2/udf/real/history': 1,
111
+ 'v1/orderbook': 1,
112
+ },
113
+ },
114
+ },
115
+ 'commonCurrencies': {
116
+ 'IRR': 'IRT',
117
+ },
118
+ 'fees': {
119
+ 'trading': {
120
+ 'tierBased': false,
121
+ 'percentage': true,
122
+ 'maker': this.parseNumber('0.001'),
123
+ 'taker': this.parseNumber('0.001'),
124
+ },
125
+ },
126
+ });
127
+ }
128
+ async fetchMarkets(params = {}) {
129
+ /**
130
+ * @method
131
+ * @name ompfinex#fetchMarkets
132
+ * @description retrieves data on all markets for ompfinex
133
+ * @see https://apidocs.ompfinex.ir/#6ae2dae4a2
134
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
135
+ * @returns {object[]} an array of objects representing market data
136
+ */
137
+ const response = await this.publicGetV1Market();
138
+ const markets = this.safeList(response, 'data');
139
+ const result = [];
140
+ for (let i = 0; i < markets.length; i++) {
141
+ const market = this.parseMarket(markets[i]);
142
+ result.push(market);
143
+ }
144
+ return result;
145
+ }
146
+ parseMarket(market) {
147
+ // {
148
+ // 'id': 1,
149
+ // 'base_currency': {
150
+ // 'id': 'BTC',
151
+ // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/btc.png',
152
+ // 'name': 'بیت کوین',
153
+ // 'decimal_precision': 8,
154
+ // },
155
+ // 'quote_currency': {
156
+ // 'id': 'IRR',
157
+ // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/irt.png',
158
+ // 'name': 'تومان',
159
+ // 'decimal_precision': 0,
160
+ // },
161
+ // 'name': 'بیت کوین - تومان',
162
+ // 'quote_currency_precision': 0,
163
+ // 'base_currency_precision': 8,
164
+ // 'history': [
165
+ // '39904073000',
166
+ // '39869830000',
167
+ // '39724396000',
168
+ // '39701684000',
169
+ // '39712038000',
170
+ // '39528137000',
171
+ // '39639658000',
172
+ // '39644885000',
173
+ // '39654055000',
174
+ // '39574451000',
175
+ // '39615152000',
176
+ // '39677500800',
177
+ // '39606862870',
178
+ // '39737426850',
179
+ // '39546858000',
180
+ // '39593530000',
181
+ // '39385856000',
182
+ // '39502536080',
183
+ // '39527561000',
184
+ // '39581729000',
185
+ // '39637343000',
186
+ // '39806512800',
187
+ // '39616055090',
188
+ // '39516007000',
189
+ // ],
190
+ // 'min_price': '39382265000',
191
+ // 'max_price': '40128888990',
192
+ // 'last_price': '39516007000',
193
+ // 'last_volume': '186449950855',
194
+ // 'day_change_percent': -0.97,
195
+ // 'week_change_percent': 1.64,
196
+ // 'tradingview_symbol': 'BINANCE:BTCUSDT',
197
+ // 'is_visible': true,
198
+ // }
199
+ const baseAsset = this.safeDict(market, 'base_currency');
200
+ const quoteAsset = this.safeDict(market, 'quote_currency');
201
+ let baseId = this.safeStringUpper(baseAsset, 'id');
202
+ let quoteId = this.safeStringUpper(quoteAsset, 'id');
203
+ const id = this.safeValue(market, 'id');
204
+ const base = this.safeCurrencyCode(baseId);
205
+ const quote = this.safeCurrencyCode(quoteId);
206
+ baseId = baseId.toLowerCase();
207
+ quoteId = quoteId.toLowerCase();
208
+ return {
209
+ 'id': id,
210
+ 'symbol': base + '/' + quote,
211
+ 'base': base,
212
+ 'quote': quote,
213
+ 'settle': undefined,
214
+ 'baseId': baseId,
215
+ 'quoteId': quoteId,
216
+ 'settleId': undefined,
217
+ 'type': 'spot',
218
+ 'spot': true,
219
+ 'margin': false,
220
+ 'swap': false,
221
+ 'future': false,
222
+ 'option': false,
223
+ 'active': true,
224
+ 'contract': false,
225
+ 'linear': undefined,
226
+ 'inverse': undefined,
227
+ 'contractSize': undefined,
228
+ 'expiry': undefined,
229
+ 'expiryDatetime': undefined,
230
+ 'strike': undefined,
231
+ 'optionType': undefined,
232
+ 'precision': {
233
+ 'amount': undefined,
234
+ 'price': undefined,
235
+ },
236
+ 'limits': {
237
+ 'leverage': {
238
+ 'min': undefined,
239
+ 'max': undefined,
240
+ },
241
+ 'amount': {
242
+ 'min': undefined,
243
+ 'max': undefined,
244
+ },
245
+ 'price': {
246
+ 'min': undefined,
247
+ 'max': undefined,
248
+ },
249
+ 'cost': {
250
+ 'min': undefined,
251
+ 'max': undefined,
252
+ },
253
+ },
254
+ 'created': undefined,
255
+ 'info': market,
256
+ };
257
+ }
258
+ async fetchTickers(symbols = undefined, params = {}) {
259
+ /**
260
+ * @method
261
+ * @name ompfinex#fetchTickers
262
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
263
+ * @see https://docs.ompfinex.com/?shell#5f1cfe9299
264
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
265
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
266
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
267
+ */
268
+ await this.loadMarkets();
269
+ if (symbols !== undefined) {
270
+ symbols = this.marketSymbols(symbols);
271
+ }
272
+ const response = await this.publicGetV1Market();
273
+ const markets = this.safeList(response, 'data');
274
+ const result = {};
275
+ for (let i = 0; i < markets.length; i++) {
276
+ const ticker = this.parseTicker(markets[i]);
277
+ const symbol = ticker['symbol'];
278
+ result[symbol] = ticker;
279
+ }
280
+ return this.filterByArrayTickers(result, 'symbol', symbols);
281
+ }
282
+ async fetchTicker(symbol, params = {}) {
283
+ /**
284
+ * @method
285
+ * @name ompfinex#fetchTicker
286
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
287
+ * @see https://docs.ompfinex.com/?shell#5f1cfe9299
288
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
289
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
290
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
291
+ */
292
+ await this.loadMarkets();
293
+ const market = this.market(symbol);
294
+ const request = {
295
+ 'id': market['id'],
296
+ };
297
+ const response = await this.publicGetV1Market(request);
298
+ const markets = this.safeDict(response, 'data');
299
+ const ticker = this.parseTicker(markets);
300
+ return ticker;
301
+ }
302
+ parseTicker(ticker, market = undefined) {
303
+ // {
304
+ // 'id': 1,
305
+ // 'base_currency': {
306
+ // 'id': 'BTC',
307
+ // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/btc.png',
308
+ // 'name': 'بیت کوین',
309
+ // 'decimal_precision': 8,
310
+ // },
311
+ // 'quote_currency': {
312
+ // 'id': 'IRR',
313
+ // 'icon_path': 'https://s3.ir-thr-at1.arvanstorage.com/ompfinex-static/t/irt.png',
314
+ // 'name': 'تومان',
315
+ // 'decimal_precision': 0,
316
+ // },
317
+ // 'name': 'بیت کوین - تومان',
318
+ // 'quote_currency_precision': 0,
319
+ // 'base_currency_precision': 8,
320
+ // 'history': [
321
+ // '39904073000',
322
+ // '39869830000',
323
+ // '39724396000',
324
+ // '39701684000',
325
+ // '39712038000',
326
+ // '39528137000',
327
+ // '39639658000',
328
+ // '39644885000',
329
+ // '39654055000',
330
+ // '39574451000',
331
+ // '39615152000',
332
+ // '39677500800',
333
+ // '39606862870',
334
+ // '39737426850',
335
+ // '39546858000',
336
+ // '39593530000',
337
+ // '39385856000',
338
+ // '39502536080',
339
+ // '39527561000',
340
+ // '39581729000',
341
+ // '39637343000',
342
+ // '39806512800',
343
+ // '39616055090',
344
+ // '39516007000',
345
+ // ],
346
+ // 'min_price': '39382265000',
347
+ // 'max_price': '40128888990',
348
+ // 'last_price': '39516007000',
349
+ // 'last_volume': '186449950855',
350
+ // 'day_change_percent': -0.97,
351
+ // 'week_change_percent': 1.64,
352
+ // 'tradingview_symbol': 'BINANCE:BTCUSDT',
353
+ // 'is_visible': true,
354
+ // }
355
+ const marketType = 'spot';
356
+ const marketId = this.safeValue(ticker, 'id');
357
+ const marketinfo = this.market(marketId);
358
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
359
+ let high = this.safeFloat(ticker, 'max_price');
360
+ let low = this.safeFloat(ticker, 'min_price');
361
+ const change = this.safeFloat(ticker, 'day_change_percent');
362
+ let last = this.safeFloat(ticker, 'last_price');
363
+ let quoteVolume = this.safeFloat(ticker, 'last_volume');
364
+ if (marketinfo['quote'] === 'IRT') {
365
+ high = high ? high * 10 : 0;
366
+ low = low ? low / 10 : 0;
367
+ last = last ? last / 10 : 0;
368
+ quoteVolume = quoteVolume ? quoteVolume / 10 : 0;
369
+ }
370
+ let baseVolume = 0;
371
+ if (last) {
372
+ baseVolume = quoteVolume / last;
373
+ }
374
+ return this.safeTicker({
375
+ 'symbol': symbol,
376
+ 'timestamp': undefined,
377
+ 'datetime': undefined,
378
+ 'high': high,
379
+ 'low': low,
380
+ 'bid': undefined,
381
+ 'bidVolume': undefined,
382
+ 'ask': undefined,
383
+ 'askVolume': undefined,
384
+ 'vwap': undefined,
385
+ 'open': last,
386
+ 'close': last,
387
+ 'last': last,
388
+ 'previousClose': undefined,
389
+ 'change': change,
390
+ 'percentage': undefined,
391
+ 'average': undefined,
392
+ 'baseVolume': baseVolume,
393
+ 'quoteVolume': quoteVolume,
394
+ 'info': ticker,
395
+ }, market);
396
+ }
397
+ async fetchOHLCV(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
398
+ /**
399
+ * @method
400
+ * @name ompfinex#fetchOHLCV
401
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
402
+ * @see https://docs.ompfinex.com/?shell#ohlc
403
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
404
+ * @param {string} timeframe the length of time each candle represents
405
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
406
+ * @param {int} [limit] the maximum amount of candles to fetch
407
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
408
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
409
+ */
410
+ await this.loadMarkets();
411
+ const market = this.market(symbol);
412
+ if (market['quote'] === 'IRT') {
413
+ symbol = market['base'] + 'IRR';
414
+ }
415
+ const endTime = Date.now();
416
+ const request = {
417
+ 'symbol': symbol.replace('/', ''),
418
+ 'from': (endTime / 1000) - (24 * 60 * 60),
419
+ 'to': endTime / 1000,
420
+ 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
421
+ // 'limit': 500,
422
+ };
423
+ if (since !== undefined) {
424
+ request['from'] = since / 1000;
425
+ }
426
+ request['from'] = this.safeInteger(request, 'from');
427
+ request['to'] = this.safeInteger(request, 'to');
428
+ if (timeframe !== undefined) {
429
+ request['resolution'] = this.safeString(this.timeframes, timeframe, timeframe);
430
+ }
431
+ const response = await this.publicGetV2UdfRealHistory(request);
432
+ const openList = this.safeValue(response, 'o', []);
433
+ const highList = this.safeList(response, 'h', []);
434
+ const lastList = this.safeList(response, 'l', []);
435
+ const closeList = this.safeList(response, 'c', []);
436
+ const volumeList = this.safeList(response, 'v', []);
437
+ const timestampList = this.safeList(response, 't', []);
438
+ const ohlcvs = [];
439
+ for (let i = 0; i < openList.length; i++) {
440
+ if (market['quote'] === 'IRT') {
441
+ openList[i] = openList[i] ? openList[i] / 10 : 0;
442
+ highList[i] = highList[i] ? highList[i] / 10 : 0;
443
+ lastList[i] = lastList[i] ? lastList[i] / 10 : 0;
444
+ closeList[i] = closeList[i] ? closeList[i] / 10 : 0;
445
+ volumeList[i] = volumeList[i] ? volumeList[i] / 10 : 0;
446
+ }
447
+ ohlcvs.push([
448
+ timestampList[i],
449
+ openList[i],
450
+ highList[i],
451
+ lastList[i],
452
+ closeList[i],
453
+ volumeList[i],
454
+ ]);
455
+ }
456
+ return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
457
+ }
458
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
459
+ /**
460
+ * @method
461
+ * @name ompfinex#fetchOrderBooks
462
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
463
+ * @see https://docs.ompfinex.com/?shell#f2150d7710
464
+ * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
465
+ * @param {int} [limit] max number of entries per orderbook to return, default is undefined
466
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
467
+ * @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
468
+ */
469
+ await this.loadMarkets();
470
+ const market = this.market(symbol);
471
+ const response = await this.publicGetV1Orderbook();
472
+ let orderbook = this.safeDict(response, 'data');
473
+ if (market['quote'] === 'IRT') {
474
+ orderbook = this.safeDict(orderbook, market['base'] + 'IRR');
475
+ const bids = this.safeList(orderbook, 'bids');
476
+ const asks = this.safeList(orderbook, 'asks');
477
+ for (let i = 0; i < bids.length; i++) {
478
+ bids[i][0] = bids[i][0] ? bids[i][0] / 10 : 0;
479
+ }
480
+ for (let i = 0; i < asks.length; i++) {
481
+ asks[i][0] = asks[i][0] ? asks[i][0] / 10 : 0;
482
+ }
483
+ orderbook['bids'] = asks;
484
+ orderbook['asks'] = bids;
485
+ }
486
+ else {
487
+ orderbook = this.safeDict(orderbook, market['base'] + market['quote']);
488
+ }
489
+ const timestamp = Date.now();
490
+ return this.parseOrderBook(orderbook, symbol, timestamp, 'bids', 'asks', 'price', 'amount');
491
+ }
492
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
493
+ const query = this.omit(params, this.extractParams(path));
494
+ let url = this.urls['api']['public'] + '/' + path;
495
+ // safer check
496
+ const pair_id = this.safeString(params, 'id');
497
+ if (pair_id !== undefined) {
498
+ url = url + '/' + pair_id;
499
+ }
500
+ if (path === 'v2/udf/real/history') {
501
+ url = this.urls['api']['public'] + '/' + path + '?' + this.urlencode(query);
502
+ }
503
+ headers = {
504
+ 'Content-Type': 'application/json',
505
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
506
+ };
507
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
508
+ }
506
509
  }
507
510
 
508
511
  exports["default"] = ompfinex;