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