ccxt-ir 4.9.19 → 4.9.23

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.
Files changed (111) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +4 -1
  4. package/dist/cjs/src/abantether.js +344 -344
  5. package/dist/cjs/src/abstract/bitbarg.js +1 -1
  6. package/dist/cjs/src/abstract/bitunix.js +1 -1
  7. package/dist/cjs/src/abstract/bydfi.js +1 -1
  8. package/dist/cjs/src/abstract/cafearz.js +1 -1
  9. package/dist/cjs/src/abstract/hamtapay.js +1 -1
  10. package/dist/cjs/src/abstract/iranexchange.js +11 -0
  11. package/dist/cjs/src/abstract/kifpoolme.js +1 -1
  12. package/dist/cjs/src/abstract/mazdax.js +1 -1
  13. package/dist/cjs/src/abstract/pingi.js +1 -1
  14. package/dist/cjs/src/abstract/pooleno.js +1 -1
  15. package/dist/cjs/src/abstract/tehran_exchange.js +1 -1
  16. package/dist/cjs/src/afratether.js +347 -347
  17. package/dist/cjs/src/arzplus.js +572 -572
  18. package/dist/cjs/src/bitbarg.js +303 -303
  19. package/dist/cjs/src/bitunix.js +317 -317
  20. package/dist/cjs/src/bydfi.js +425 -425
  21. package/dist/cjs/src/cafearz.js +337 -337
  22. package/dist/cjs/src/hamtapay.js +294 -294
  23. package/dist/cjs/src/iranexchange.js +398 -0
  24. package/dist/cjs/src/kcex.js +326 -326
  25. package/dist/cjs/src/kifpoolme.js +401 -401
  26. package/dist/cjs/src/mazdax.js +525 -525
  27. package/dist/cjs/src/ompfinex.js +501 -501
  28. package/dist/cjs/src/pingi.js +437 -437
  29. package/dist/cjs/src/pooleno.js +338 -338
  30. package/dist/cjs/src/sarmayex.js +367 -367
  31. package/dist/cjs/src/tehran_exchange.js +324 -324
  32. package/dist/cjs/src/tetherland.js +358 -358
  33. package/dist/cjs/src/toobit.js +436 -436
  34. package/dist/cjs/src/twox.js +362 -362
  35. package/dist/cjs/src/xt.js +5171 -5171
  36. package/js/ccxt.d.ts +5 -2
  37. package/js/ccxt.js +4 -2
  38. package/js/src/abantether.js +347 -347
  39. package/js/src/abstract/abantether.d.ts +8 -8
  40. package/js/src/abstract/arzplus.d.ts +11 -11
  41. package/js/src/abstract/bitbarg.d.ts +8 -8
  42. package/js/src/abstract/bitbarg.js +5 -5
  43. package/js/src/abstract/bitunix.d.ts +9 -9
  44. package/js/src/abstract/bitunix.js +5 -5
  45. package/js/src/abstract/bydfi.d.ts +11 -11
  46. package/js/src/abstract/bydfi.js +5 -5
  47. package/js/src/abstract/cafearz.d.ts +8 -8
  48. package/js/src/abstract/cafearz.js +5 -5
  49. package/js/src/abstract/hamtapay.d.ts +9 -9
  50. package/js/src/abstract/hamtapay.js +5 -5
  51. package/js/src/abstract/iranexchange.d.ts +9 -0
  52. package/js/src/abstract/iranexchange.js +11 -0
  53. package/js/src/abstract/kcex.d.ts +10 -10
  54. package/js/src/abstract/kifpoolme.d.ts +9 -9
  55. package/js/src/abstract/kifpoolme.js +5 -5
  56. package/js/src/abstract/mazdax.d.ts +11 -11
  57. package/js/src/abstract/mazdax.js +5 -5
  58. package/js/src/abstract/pingi.d.ts +9 -9
  59. package/js/src/abstract/pingi.js +5 -5
  60. package/js/src/abstract/pooleno.d.ts +8 -8
  61. package/js/src/abstract/pooleno.js +5 -5
  62. package/js/src/abstract/tehran_exchange.d.ts +9 -9
  63. package/js/src/abstract/tehran_exchange.js +5 -5
  64. package/js/src/abstract/toobit.d.ts +10 -10
  65. package/js/src/afratether.js +350 -350
  66. package/js/src/arzplus.d.ts +26 -26
  67. package/js/src/arzplus.js +575 -575
  68. package/js/src/base/Exchange.d.ts +2 -2
  69. package/js/src/base/types.d.ts +586 -586
  70. package/js/src/bitbarg.d.ts +21 -21
  71. package/js/src/bitbarg.js +306 -306
  72. package/js/src/bitunix.d.ts +21 -21
  73. package/js/src/bitunix.js +320 -320
  74. package/js/src/bydfi.d.ts +23 -23
  75. package/js/src/bydfi.js +428 -428
  76. package/js/src/cafearz.d.ts +21 -21
  77. package/js/src/cafearz.js +340 -340
  78. package/js/src/coinbaseexchange.d.ts +1 -1
  79. package/js/src/hamtapay.d.ts +21 -21
  80. package/js/src/hamtapay.js +297 -297
  81. package/js/src/iranexchange.d.ts +21 -0
  82. package/js/src/iranexchange.js +397 -0
  83. package/js/src/kcex.d.ts +21 -21
  84. package/js/src/kcex.js +329 -329
  85. package/js/src/kifpoolme.d.ts +23 -23
  86. package/js/src/kifpoolme.js +404 -404
  87. package/js/src/mazdax.d.ts +23 -23
  88. package/js/src/mazdax.js +528 -528
  89. package/js/src/ompfinex.js +504 -504
  90. package/js/src/pingi.d.ts +22 -22
  91. package/js/src/pingi.js +440 -440
  92. package/js/src/pooleno.d.ts +21 -21
  93. package/js/src/pooleno.js +341 -341
  94. package/js/src/protobuf/mexc/compiled.d.cts +0 -6
  95. package/js/src/sarmayex.js +370 -370
  96. package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
  97. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -51
  98. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -101
  99. package/js/src/static_dependencies/qs/formats.d.cts +0 -6
  100. package/js/src/static_dependencies/qs/index.d.cts +0 -6
  101. package/js/src/static_dependencies/qs/parse.d.cts +0 -6
  102. package/js/src/static_dependencies/qs/stringify.d.cts +0 -6
  103. package/js/src/static_dependencies/qs/utils.d.cts +0 -6
  104. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -5
  105. package/js/src/tehran_exchange.d.ts +21 -21
  106. package/js/src/tehran_exchange.js +327 -327
  107. package/js/src/tetherland.js +361 -361
  108. package/js/src/toobit.js +439 -439
  109. package/js/src/twox.js +365 -365
  110. package/js/src/xt.js +5178 -5178
  111. package/package.json +1 -1
@@ -5,507 +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 = {
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
- }
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
+ }
509
509
  }
510
510
 
511
511
  exports["default"] = ompfinex;