ccxt-ir 4.9.25 → 4.9.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -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/bydfi.js +1 -1
  7. package/dist/cjs/src/abstract/cafearz.js +1 -1
  8. package/dist/cjs/src/abstract/hamtapay.js +1 -1
  9. package/dist/cjs/src/abstract/iranexchange.js +1 -1
  10. package/dist/cjs/src/abstract/kifpoolme.js +1 -1
  11. package/dist/cjs/src/abstract/mazdax.js +1 -1
  12. package/dist/cjs/src/abstract/pingi.js +1 -1
  13. package/dist/cjs/src/abstract/pooleno.js +1 -1
  14. package/dist/cjs/src/abstract/tehran_exchange.js +1 -1
  15. package/dist/cjs/src/afratether.js +347 -347
  16. package/dist/cjs/src/arzplus.js +572 -572
  17. package/dist/cjs/src/bit24.js +380 -379
  18. package/dist/cjs/src/bitbarg.js +303 -303
  19. package/dist/cjs/src/bitpin.js +478 -469
  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 +390 -390
  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/js/ccxt.d.ts +1 -1
  36. package/js/ccxt.js +1 -1
  37. package/js/src/abantether.js +347 -347
  38. package/js/src/abstract/abantether.d.ts +8 -8
  39. package/js/src/abstract/arzplus.d.ts +11 -11
  40. package/js/src/abstract/bitbarg.d.ts +8 -8
  41. package/js/src/abstract/bitbarg.js +5 -5
  42. package/js/src/abstract/bitpin.d.ts +11 -10
  43. package/js/src/abstract/bydfi.d.ts +11 -11
  44. package/js/src/abstract/bydfi.js +5 -5
  45. package/js/src/abstract/cafearz.d.ts +8 -8
  46. package/js/src/abstract/cafearz.js +5 -5
  47. package/js/src/abstract/hamtapay.d.ts +9 -9
  48. package/js/src/abstract/hamtapay.js +5 -5
  49. package/js/src/abstract/iranexchange.d.ts +9 -9
  50. package/js/src/abstract/iranexchange.js +5 -5
  51. package/js/src/abstract/kifpoolme.d.ts +9 -9
  52. package/js/src/abstract/kifpoolme.js +5 -5
  53. package/js/src/abstract/mazdax.d.ts +11 -11
  54. package/js/src/abstract/mazdax.js +5 -5
  55. package/js/src/abstract/pingi.d.ts +9 -9
  56. package/js/src/abstract/pingi.js +5 -5
  57. package/js/src/abstract/pooleno.d.ts +8 -8
  58. package/js/src/abstract/pooleno.js +5 -5
  59. package/js/src/abstract/tehran_exchange.d.ts +9 -9
  60. package/js/src/abstract/tehran_exchange.js +5 -5
  61. package/js/src/abstract/toobit.d.ts +10 -10
  62. package/js/src/afratether.js +350 -350
  63. package/js/src/arzplus.d.ts +26 -26
  64. package/js/src/arzplus.js +575 -575
  65. package/js/src/base/Exchange.d.ts +926 -926
  66. package/js/src/base/types.d.ts +586 -586
  67. package/js/src/bit24.js +383 -382
  68. package/js/src/bitbarg.d.ts +21 -21
  69. package/js/src/bitbarg.js +306 -306
  70. package/js/src/bitpin.js +481 -472
  71. package/js/src/bydfi.d.ts +23 -23
  72. package/js/src/bydfi.js +428 -428
  73. package/js/src/cafearz.d.ts +21 -21
  74. package/js/src/cafearz.js +340 -340
  75. package/js/src/coinbaseexchange.d.ts +334 -334
  76. package/js/src/hamtapay.d.ts +21 -21
  77. package/js/src/hamtapay.js +297 -297
  78. package/js/src/iranexchange.d.ts +21 -21
  79. package/js/src/iranexchange.js +393 -393
  80. package/js/src/kcex.js +329 -329
  81. package/js/src/kifpoolme.d.ts +23 -23
  82. package/js/src/kifpoolme.js +404 -404
  83. package/js/src/mazdax.d.ts +23 -23
  84. package/js/src/mazdax.js +528 -528
  85. package/js/src/ompfinex.js +504 -504
  86. package/js/src/pingi.d.ts +22 -22
  87. package/js/src/pingi.js +440 -440
  88. package/js/src/pooleno.d.ts +21 -21
  89. package/js/src/pooleno.js +341 -341
  90. package/js/src/protobuf/mexc/compiled.d.cts +2 -2
  91. package/js/src/sarmayex.js +370 -370
  92. package/js/src/static_dependencies/fflake/browser.d.ts +222 -222
  93. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -51
  94. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  95. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -204
  96. package/js/src/static_dependencies/qs/formats.d.cts +8 -8
  97. package/js/src/static_dependencies/qs/index.d.cts +4 -4
  98. package/js/src/static_dependencies/qs/parse.d.cts +2 -2
  99. package/js/src/static_dependencies/qs/stringify.d.cts +2 -2
  100. package/js/src/static_dependencies/qs/utils.d.cts +9 -9
  101. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  102. package/js/src/tehran_exchange.d.ts +21 -21
  103. package/js/src/tehran_exchange.js +327 -327
  104. package/js/src/tetherland.js +361 -361
  105. package/js/src/toobit.js +439 -439
  106. package/js/src/twox.js +365 -365
  107. package/package.json +1 -1
package/js/src/pingi.js CHANGED
@@ -4,443 +4,443 @@
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/pingi.js';
9
- // ---------------------------------------------------------------------------
10
- /**
11
- * @class pingi
12
- * @augments Exchange
13
- * @description Pingi SPOT exchange implementation
14
- */
15
- export default class pingi extends Exchange {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'pingi',
19
- 'name': 'Pingi',
20
- 'countries': ['IR'],
21
- 'rateLimit': 1000,
22
- 'version': '1',
23
- 'certified': false,
24
- 'pro': false,
25
- 'has': {
26
- 'CORS': undefined,
27
- 'spot': false,
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
- 'fetchL3OrderBook': false,
61
- 'fetchLedger': false,
62
- 'fetchLedgerEntry': false,
63
- 'fetchLeverageTiers': false,
64
- 'fetchMarkets': true,
65
- 'fetchMarkOHLCV': false,
66
- 'fetchMyTrades': false,
67
- 'fetchOHLCV': true,
68
- 'fetchOpenInterestHistory': false,
69
- 'fetchOpenOrders': false,
70
- 'fetchOrder': false,
71
- 'fetchOrderBook': false,
72
- 'fetchOrders': false,
73
- 'fetchOrderTrades': 'emulated',
74
- 'fetchPositions': false,
75
- 'fetchPremiumIndexOHLCV': false,
76
- 'fetchTicker': true,
77
- 'fetchTickers': true,
78
- 'fetchTime': false,
79
- 'fetchTrades': false,
80
- 'fetchTradingFee': false,
81
- 'fetchTradingFees': false,
82
- 'fetchWithdrawals': false,
83
- 'setLeverage': false,
84
- 'setMarginMode': false,
85
- 'transfer': false,
86
- 'withdraw': false,
87
- },
88
- 'comment': 'Pingi SPOT Exchange',
89
- 'urls': {
90
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/pingi/64x64.png',
91
- 'api': {
92
- 'public': 'https://api5.pingi.co/trading',
93
- },
94
- 'www': 'https://pingi.co',
95
- 'doc': [
96
- 'https://pingi.co',
97
- ],
98
- },
99
- 'timeframes': {
100
- '1m': '1',
101
- '5m': '5',
102
- '15m': '15',
103
- '30m': '30',
104
- '1h': '60',
105
- '4h': '240',
106
- '1d': '1D',
107
- '1w': '1W',
108
- },
109
- 'api': {
110
- 'public': {
111
- 'get': {
112
- 'market/prices': 1,
113
- 'udf/history': 1,
114
- },
115
- },
116
- },
117
- 'fees': {
118
- 'trading': {
119
- 'tierBased': false,
120
- 'percentage': true,
121
- 'maker': this.parseNumber('0.001'),
122
- 'taker': this.parseNumber('0.001'),
123
- },
124
- },
125
- });
126
- }
127
- async fetchMarkets(params = {}) {
128
- /**
129
- * @method
130
- * @name pingi#fetchMarkets
131
- * @description retrieves data on all markets for pingi
132
- * @see https://api5.pingi.co/trading/market/prices/
133
- * @param {object} [params] extra parameters specific to the exchange API endpoint
134
- * @returns {object[]} an array of objects representing market data
135
- */
136
- const response = await this.publicGetMarketPrices(params);
137
- // Response structure:
138
- // {
139
- // "statusCode": 200,
140
- // "ok": true,
141
- // "data": {
142
- // "ETH_USDT": {
143
- // "market": "ETH_USDT",
144
- // "marketId": 6,
145
- // "marketVolume": "128889.02937760774364521500000000",
146
- // "currentPrice": "4083.7744580000000",
147
- // "maxPrice": "4218.0241700000000",
148
- // "minPrice": "3786.9124050000000",
149
- // "startPrice": "3830.5800220000000",
150
- // "marketPlatform": 0
151
- // },
152
- // "BTC_IRT": {
153
- // "market": "BTC_IRT",
154
- // "marketId": 8,
155
- // "marketVolume": "27140908320.17800246693400000000000000",
156
- // "currentPrice": "12909088630.0000000000000",
157
- // "maxPrice": "13213902170.0000000000000",
158
- // "minPrice": "12000000000.0000000000000",
159
- // "startPrice": "12752332240.0000000000000",
160
- // "marketPlatform": 0
161
- // },
162
- // ...
163
- // }
164
- // }
165
- const data = this.safeDict(response, 'data', {});
166
- const marketKeys = Object.keys(data);
167
- const result = [];
168
- for (let i = 0; i < marketKeys.length; i++) {
169
- const marketId = marketKeys[i];
170
- const marketData = data[marketId];
171
- const market = this.parseMarket(marketData);
172
- result.push(market);
173
- }
174
- return result;
175
- }
176
- parseMarket(market) {
177
- // {
178
- // "market": "BTC_IRT",
179
- // "marketId": 8,
180
- // "marketVolume": "27140908320.17800246693400000000000000",
181
- // "currentPrice": "12909088630.0000000000000",
182
- // "maxPrice": "13213902170.0000000000000",
183
- // "minPrice": "12000000000.0000000000000",
184
- // "startPrice": "12752332240.0000000000000",
185
- // "marketPlatform": 0
186
- // }
187
- const id = this.safeString(market, 'market');
188
- const parts = id.split('_');
189
- let baseId = this.safeString(parts, 0);
190
- let quoteId = this.safeString(parts, 1);
191
- const base = this.safeCurrencyCode(baseId);
192
- const quote = this.safeCurrencyCode(quoteId);
193
- baseId = baseId.toLowerCase();
194
- quoteId = quoteId.toLowerCase();
195
- return {
196
- 'id': id,
197
- 'symbol': base + '/' + quote,
198
- 'base': base,
199
- 'quote': quote,
200
- 'settle': undefined,
201
- 'baseId': baseId,
202
- 'quoteId': quoteId,
203
- 'settleId': undefined,
204
- 'type': 'spot',
205
- 'spot': false,
206
- 'margin': false,
207
- 'swap': false,
208
- 'future': false,
209
- 'option': false,
210
- 'active': true,
211
- 'contract': false,
212
- 'linear': undefined,
213
- 'inverse': undefined,
214
- 'contractSize': undefined,
215
- 'expiry': undefined,
216
- 'expiryDatetime': undefined,
217
- 'strike': undefined,
218
- 'optionType': undefined,
219
- 'precision': {
220
- 'amount': undefined,
221
- 'price': undefined,
222
- },
223
- 'limits': {
224
- 'leverage': {
225
- 'min': undefined,
226
- 'max': undefined,
227
- },
228
- 'amount': {
229
- 'min': undefined,
230
- 'max': undefined,
231
- },
232
- 'price': {
233
- 'min': undefined,
234
- 'max': undefined,
235
- },
236
- 'cost': {
237
- 'min': undefined,
238
- 'max': undefined,
239
- },
240
- },
241
- 'created': undefined,
242
- 'info': market,
243
- };
244
- }
245
- async fetchTickers(symbols = undefined, params = {}) {
246
- /**
247
- * @method
248
- * @name pingi#fetchTickers
249
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
250
- * @see https://api5.pingi.co/trading/market/prices/
251
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
252
- * @param {object} [params] extra parameters specific to the exchange API endpoint
253
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
254
- */
255
- await this.loadMarkets();
256
- if (symbols !== undefined) {
257
- symbols = this.marketSymbols(symbols);
258
- }
259
- const response = await this.publicGetMarketPrices(params);
260
- // Response structure:
261
- // {
262
- // "statusCode": 200,
263
- // "ok": true,
264
- // "data": {
265
- // "ETH_USDT": {
266
- // "market": "ETH_USDT",
267
- // "marketId": 6,
268
- // "marketVolume": "128889.02937760774364521500000000",
269
- // "currentPrice": "4083.7744580000000",
270
- // "maxPrice": "4218.0241700000000",
271
- // "minPrice": "3786.9124050000000",
272
- // "startPrice": "3830.5800220000000",
273
- // "marketPlatform": 0
274
- // },
275
- // ...
276
- // }
277
- // }
278
- const data = this.safeDict(response, 'data', {});
279
- const marketKeys = Object.keys(data);
280
- const result = {};
281
- for (let i = 0; i < marketKeys.length; i++) {
282
- const marketId = marketKeys[i];
283
- const marketData = data[marketId];
284
- const ticker = this.parseTicker(marketData);
285
- const symbol = ticker['symbol'];
286
- result[symbol] = ticker;
287
- }
288
- return this.filterByArrayTickers(result, 'symbol', symbols);
289
- }
290
- async fetchTicker(symbol, params = {}) {
291
- /**
292
- * @method
293
- * @name pingi#fetchTicker
294
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
295
- * @see https://api5.pingi.co/trading/market/prices/
296
- * @param {string} symbol unified symbol of the market to fetch the ticker for
297
- * @param {object} [params] extra parameters specific to the exchange API endpoint
298
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
299
- */
300
- await this.loadMarkets();
301
- const market = this.market(symbol);
302
- const response = await this.publicGetMarketPrices(params);
303
- // Response structure:
304
- // {
305
- // "statusCode": 200,
306
- // "ok": true,
307
- // "data": {
308
- // "BTC_IRT": {
309
- // "market": "BTC_IRT",
310
- // "marketId": 8,
311
- // "marketVolume": "27140908320.17800246693400000000000000",
312
- // "currentPrice": "12909088630.0000000000000",
313
- // "maxPrice": "13213902170.0000000000000",
314
- // "minPrice": "12000000000.0000000000000",
315
- // "startPrice": "12752332240.0000000000000",
316
- // "marketPlatform": 0
317
- // },
318
- // ...
319
- // }
320
- // }
321
- const data = this.safeDict(response, 'data', {});
322
- const tickerData = this.safeDict(data, market['id']);
323
- return this.parseTicker(tickerData, market);
324
- }
325
- parseTicker(ticker, market = undefined) {
326
- // {
327
- // "market": "BTC_IRT",
328
- // "marketId": 8,
329
- // "marketVolume": "27140908320.17800246693400000000000000",
330
- // "currentPrice": "12909088630.0000000000000",
331
- // "maxPrice": "13213902170.0000000000000",
332
- // "minPrice": "12000000000.0000000000000",
333
- // "startPrice": "12752332240.0000000000000",
334
- // "marketPlatform": 0
335
- // }
336
- const marketType = 'spot';
337
- const marketId = this.safeString(ticker, 'market');
338
- const symbol = this.safeSymbol(marketId, market, '_', marketType);
339
- const last = this.safeString(ticker, 'currentPrice');
340
- const high = this.safeString(ticker, 'maxPrice');
341
- const low = this.safeString(ticker, 'minPrice');
342
- const open = this.safeString(ticker, 'startPrice');
343
- const baseVolume = this.safeString(ticker, 'marketVolume');
344
- // Calculate change and percentage
345
- let change = undefined;
346
- let percentage = undefined;
347
- if (open !== undefined && last !== undefined) {
348
- const openNum = this.parseNumber(open);
349
- const lastNum = this.parseNumber(last);
350
- if (openNum !== undefined && lastNum !== undefined && openNum > 0) {
351
- change = this.parseNumber(this.numberToString(lastNum - openNum));
352
- percentage = this.parseNumber(this.numberToString((lastNum - openNum) / openNum * 100));
353
- }
354
- }
355
- return this.safeTicker({
356
- 'symbol': symbol,
357
- 'timestamp': undefined,
358
- 'datetime': undefined,
359
- 'high': high,
360
- 'low': low,
361
- 'bid': undefined,
362
- 'bidVolume': undefined,
363
- 'ask': undefined,
364
- 'askVolume': undefined,
365
- 'vwap': undefined,
366
- 'open': open,
367
- 'close': last,
368
- 'last': last,
369
- 'previousClose': undefined,
370
- 'change': change,
371
- 'percentage': percentage,
372
- 'average': undefined,
373
- 'baseVolume': baseVolume,
374
- 'quoteVolume': undefined,
375
- 'info': ticker,
376
- }, market);
377
- }
378
- async fetchOHLCV(symbol, timeframe = '1d', since = undefined, limit = undefined, params = {}) {
379
- /**
380
- * @method
381
- * @name pingi#fetchOHLCV
382
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
383
- * @see https://api5.pingi.co/trading/udf/history/
384
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
385
- * @param {string} timeframe the length of time each candle represents
386
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
387
- * @param {int} [limit] the maximum amount of candles to fetch
388
- * @param {object} [params] extra parameters specific to the exchange API endpoint
389
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
390
- */
391
- await this.loadMarkets();
392
- const market = this.market(symbol);
393
- const endTime = Date.now();
394
- const request = {
395
- 'symbol': market['base'] + '/' + market['quote'],
396
- 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
397
- 'from': (endTime / 1000) - (30 * 24 * 60 * 60),
398
- 'to': endTime / 1000,
399
- };
400
- if (since !== undefined) {
401
- request['from'] = since / 1000;
402
- }
403
- request['from'] = this.safeInteger(request, 'from');
404
- request['to'] = this.safeInteger(request, 'to');
405
- const response = await this.publicGetUdfHistory(request);
406
- // Response structure:
407
- // {
408
- // "c": [12710726290.0, 12732737270.0, ...], // close prices
409
- // "v": [0.015461630724, 0.024055443184, ...], // volumes
410
- // "l": [12702815580.0, 12689256670.0, ...], // low prices
411
- // "h": [12723701120.0, 12752332240.0, ...], // high prices
412
- // "o": [12752332240.0, 12710726290.0, ...], // open prices
413
- // "t": [1760271600, 1760272500, ...] // timestamps
414
- // }
415
- const closeList = this.safeList(response, 'c', []);
416
- const volumeList = this.safeList(response, 'v', []);
417
- const lowList = this.safeList(response, 'l', []);
418
- const highList = this.safeList(response, 'h', []);
419
- const openList = this.safeList(response, 'o', []);
420
- const timestampList = this.safeList(response, 't', []);
421
- const ohlcvs = [];
422
- for (let i = 0; i < openList.length; i++) {
423
- ohlcvs.push([
424
- this.safeTimestamp(timestampList, i),
425
- this.safeNumber(openList, i),
426
- this.safeNumber(highList, i),
427
- this.safeNumber(lowList, i),
428
- this.safeNumber(closeList, i),
429
- this.safeNumber(volumeList, i),
430
- ]);
431
- }
432
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
433
- }
434
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
435
- const query = this.omit(params, this.extractParams(path));
436
- let url = this.urls['api']['public'] + '/' + path;
437
- if (path === 'market/prices') {
438
- url = url + '/';
439
- }
440
- if (path === 'udf/history') {
441
- url = url + '/?' + this.urlencode(query);
442
- }
443
- headers = { 'Content-Type': 'application/json' };
444
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
445
- }
446
- }
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/pingi.js';
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class pingi
12
+ * @augments Exchange
13
+ * @description Pingi SPOT exchange implementation
14
+ */
15
+ export default class pingi extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'pingi',
19
+ 'name': 'Pingi',
20
+ 'countries': ['IR'],
21
+ 'rateLimit': 1000,
22
+ 'version': '1',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'has': {
26
+ 'CORS': undefined,
27
+ 'spot': false,
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
+ 'fetchL3OrderBook': false,
61
+ 'fetchLedger': false,
62
+ 'fetchLedgerEntry': false,
63
+ 'fetchLeverageTiers': false,
64
+ 'fetchMarkets': true,
65
+ 'fetchMarkOHLCV': false,
66
+ 'fetchMyTrades': false,
67
+ 'fetchOHLCV': true,
68
+ 'fetchOpenInterestHistory': false,
69
+ 'fetchOpenOrders': false,
70
+ 'fetchOrder': false,
71
+ 'fetchOrderBook': false,
72
+ 'fetchOrders': false,
73
+ 'fetchOrderTrades': 'emulated',
74
+ 'fetchPositions': false,
75
+ 'fetchPremiumIndexOHLCV': false,
76
+ 'fetchTicker': true,
77
+ 'fetchTickers': true,
78
+ 'fetchTime': false,
79
+ 'fetchTrades': false,
80
+ 'fetchTradingFee': false,
81
+ 'fetchTradingFees': false,
82
+ 'fetchWithdrawals': false,
83
+ 'setLeverage': false,
84
+ 'setMarginMode': false,
85
+ 'transfer': false,
86
+ 'withdraw': false,
87
+ },
88
+ 'comment': 'Pingi SPOT Exchange',
89
+ 'urls': {
90
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/pingi/64x64.png',
91
+ 'api': {
92
+ 'public': 'https://api5.pingi.co/trading',
93
+ },
94
+ 'www': 'https://pingi.co',
95
+ 'doc': [
96
+ 'https://pingi.co',
97
+ ],
98
+ },
99
+ 'timeframes': {
100
+ '1m': '1',
101
+ '5m': '5',
102
+ '15m': '15',
103
+ '30m': '30',
104
+ '1h': '60',
105
+ '4h': '240',
106
+ '1d': '1D',
107
+ '1w': '1W',
108
+ },
109
+ 'api': {
110
+ 'public': {
111
+ 'get': {
112
+ 'market/prices': 1,
113
+ 'udf/history': 1,
114
+ },
115
+ },
116
+ },
117
+ 'fees': {
118
+ 'trading': {
119
+ 'tierBased': false,
120
+ 'percentage': true,
121
+ 'maker': this.parseNumber('0.001'),
122
+ 'taker': this.parseNumber('0.001'),
123
+ },
124
+ },
125
+ });
126
+ }
127
+ async fetchMarkets(params = {}) {
128
+ /**
129
+ * @method
130
+ * @name pingi#fetchMarkets
131
+ * @description retrieves data on all markets for pingi
132
+ * @see https://api5.pingi.co/trading/market/prices/
133
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
134
+ * @returns {object[]} an array of objects representing market data
135
+ */
136
+ const response = await this.publicGetMarketPrices(params);
137
+ // Response structure:
138
+ // {
139
+ // "statusCode": 200,
140
+ // "ok": true,
141
+ // "data": {
142
+ // "ETH_USDT": {
143
+ // "market": "ETH_USDT",
144
+ // "marketId": 6,
145
+ // "marketVolume": "128889.02937760774364521500000000",
146
+ // "currentPrice": "4083.7744580000000",
147
+ // "maxPrice": "4218.0241700000000",
148
+ // "minPrice": "3786.9124050000000",
149
+ // "startPrice": "3830.5800220000000",
150
+ // "marketPlatform": 0
151
+ // },
152
+ // "BTC_IRT": {
153
+ // "market": "BTC_IRT",
154
+ // "marketId": 8,
155
+ // "marketVolume": "27140908320.17800246693400000000000000",
156
+ // "currentPrice": "12909088630.0000000000000",
157
+ // "maxPrice": "13213902170.0000000000000",
158
+ // "minPrice": "12000000000.0000000000000",
159
+ // "startPrice": "12752332240.0000000000000",
160
+ // "marketPlatform": 0
161
+ // },
162
+ // ...
163
+ // }
164
+ // }
165
+ const data = this.safeDict(response, 'data', {});
166
+ const marketKeys = Object.keys(data);
167
+ const result = [];
168
+ for (let i = 0; i < marketKeys.length; i++) {
169
+ const marketId = marketKeys[i];
170
+ const marketData = data[marketId];
171
+ const market = this.parseMarket(marketData);
172
+ result.push(market);
173
+ }
174
+ return result;
175
+ }
176
+ parseMarket(market) {
177
+ // {
178
+ // "market": "BTC_IRT",
179
+ // "marketId": 8,
180
+ // "marketVolume": "27140908320.17800246693400000000000000",
181
+ // "currentPrice": "12909088630.0000000000000",
182
+ // "maxPrice": "13213902170.0000000000000",
183
+ // "minPrice": "12000000000.0000000000000",
184
+ // "startPrice": "12752332240.0000000000000",
185
+ // "marketPlatform": 0
186
+ // }
187
+ const id = this.safeString(market, 'market');
188
+ const parts = id.split('_');
189
+ let baseId = this.safeString(parts, 0);
190
+ let quoteId = this.safeString(parts, 1);
191
+ const base = this.safeCurrencyCode(baseId);
192
+ const quote = this.safeCurrencyCode(quoteId);
193
+ baseId = baseId.toLowerCase();
194
+ quoteId = quoteId.toLowerCase();
195
+ return {
196
+ 'id': id,
197
+ 'symbol': base + '/' + quote,
198
+ 'base': base,
199
+ 'quote': quote,
200
+ 'settle': undefined,
201
+ 'baseId': baseId,
202
+ 'quoteId': quoteId,
203
+ 'settleId': undefined,
204
+ 'type': 'spot',
205
+ 'spot': false,
206
+ 'margin': false,
207
+ 'swap': false,
208
+ 'future': false,
209
+ 'option': false,
210
+ 'active': true,
211
+ 'contract': false,
212
+ 'linear': undefined,
213
+ 'inverse': undefined,
214
+ 'contractSize': undefined,
215
+ 'expiry': undefined,
216
+ 'expiryDatetime': undefined,
217
+ 'strike': undefined,
218
+ 'optionType': undefined,
219
+ 'precision': {
220
+ 'amount': undefined,
221
+ 'price': undefined,
222
+ },
223
+ 'limits': {
224
+ 'leverage': {
225
+ 'min': undefined,
226
+ 'max': undefined,
227
+ },
228
+ 'amount': {
229
+ 'min': undefined,
230
+ 'max': undefined,
231
+ },
232
+ 'price': {
233
+ 'min': undefined,
234
+ 'max': undefined,
235
+ },
236
+ 'cost': {
237
+ 'min': undefined,
238
+ 'max': undefined,
239
+ },
240
+ },
241
+ 'created': undefined,
242
+ 'info': market,
243
+ };
244
+ }
245
+ async fetchTickers(symbols = undefined, params = {}) {
246
+ /**
247
+ * @method
248
+ * @name pingi#fetchTickers
249
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
250
+ * @see https://api5.pingi.co/trading/market/prices/
251
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
252
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
253
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
254
+ */
255
+ await this.loadMarkets();
256
+ if (symbols !== undefined) {
257
+ symbols = this.marketSymbols(symbols);
258
+ }
259
+ const response = await this.publicGetMarketPrices(params);
260
+ // Response structure:
261
+ // {
262
+ // "statusCode": 200,
263
+ // "ok": true,
264
+ // "data": {
265
+ // "ETH_USDT": {
266
+ // "market": "ETH_USDT",
267
+ // "marketId": 6,
268
+ // "marketVolume": "128889.02937760774364521500000000",
269
+ // "currentPrice": "4083.7744580000000",
270
+ // "maxPrice": "4218.0241700000000",
271
+ // "minPrice": "3786.9124050000000",
272
+ // "startPrice": "3830.5800220000000",
273
+ // "marketPlatform": 0
274
+ // },
275
+ // ...
276
+ // }
277
+ // }
278
+ const data = this.safeDict(response, 'data', {});
279
+ const marketKeys = Object.keys(data);
280
+ const result = {};
281
+ for (let i = 0; i < marketKeys.length; i++) {
282
+ const marketId = marketKeys[i];
283
+ const marketData = data[marketId];
284
+ const ticker = this.parseTicker(marketData);
285
+ const symbol = ticker['symbol'];
286
+ result[symbol] = ticker;
287
+ }
288
+ return this.filterByArrayTickers(result, 'symbol', symbols);
289
+ }
290
+ async fetchTicker(symbol, params = {}) {
291
+ /**
292
+ * @method
293
+ * @name pingi#fetchTicker
294
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
295
+ * @see https://api5.pingi.co/trading/market/prices/
296
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
297
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
298
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
299
+ */
300
+ await this.loadMarkets();
301
+ const market = this.market(symbol);
302
+ const response = await this.publicGetMarketPrices(params);
303
+ // Response structure:
304
+ // {
305
+ // "statusCode": 200,
306
+ // "ok": true,
307
+ // "data": {
308
+ // "BTC_IRT": {
309
+ // "market": "BTC_IRT",
310
+ // "marketId": 8,
311
+ // "marketVolume": "27140908320.17800246693400000000000000",
312
+ // "currentPrice": "12909088630.0000000000000",
313
+ // "maxPrice": "13213902170.0000000000000",
314
+ // "minPrice": "12000000000.0000000000000",
315
+ // "startPrice": "12752332240.0000000000000",
316
+ // "marketPlatform": 0
317
+ // },
318
+ // ...
319
+ // }
320
+ // }
321
+ const data = this.safeDict(response, 'data', {});
322
+ const tickerData = this.safeDict(data, market['id']);
323
+ return this.parseTicker(tickerData, market);
324
+ }
325
+ parseTicker(ticker, market = undefined) {
326
+ // {
327
+ // "market": "BTC_IRT",
328
+ // "marketId": 8,
329
+ // "marketVolume": "27140908320.17800246693400000000000000",
330
+ // "currentPrice": "12909088630.0000000000000",
331
+ // "maxPrice": "13213902170.0000000000000",
332
+ // "minPrice": "12000000000.0000000000000",
333
+ // "startPrice": "12752332240.0000000000000",
334
+ // "marketPlatform": 0
335
+ // }
336
+ const marketType = 'spot';
337
+ const marketId = this.safeString(ticker, 'market');
338
+ const symbol = this.safeSymbol(marketId, market, '_', marketType);
339
+ const last = this.safeString(ticker, 'currentPrice');
340
+ const high = this.safeString(ticker, 'maxPrice');
341
+ const low = this.safeString(ticker, 'minPrice');
342
+ const open = this.safeString(ticker, 'startPrice');
343
+ const baseVolume = this.safeString(ticker, 'marketVolume');
344
+ // Calculate change and percentage
345
+ let change = undefined;
346
+ let percentage = undefined;
347
+ if (open !== undefined && last !== undefined) {
348
+ const openNum = this.parseNumber(open);
349
+ const lastNum = this.parseNumber(last);
350
+ if (openNum !== undefined && lastNum !== undefined && openNum > 0) {
351
+ change = this.parseNumber(this.numberToString(lastNum - openNum));
352
+ percentage = this.parseNumber(this.numberToString((lastNum - openNum) / openNum * 100));
353
+ }
354
+ }
355
+ return this.safeTicker({
356
+ 'symbol': symbol,
357
+ 'timestamp': undefined,
358
+ 'datetime': undefined,
359
+ 'high': high,
360
+ 'low': low,
361
+ 'bid': undefined,
362
+ 'bidVolume': undefined,
363
+ 'ask': undefined,
364
+ 'askVolume': undefined,
365
+ 'vwap': undefined,
366
+ 'open': open,
367
+ 'close': last,
368
+ 'last': last,
369
+ 'previousClose': undefined,
370
+ 'change': change,
371
+ 'percentage': percentage,
372
+ 'average': undefined,
373
+ 'baseVolume': baseVolume,
374
+ 'quoteVolume': undefined,
375
+ 'info': ticker,
376
+ }, market);
377
+ }
378
+ async fetchOHLCV(symbol, timeframe = '1d', since = undefined, limit = undefined, params = {}) {
379
+ /**
380
+ * @method
381
+ * @name pingi#fetchOHLCV
382
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
383
+ * @see https://api5.pingi.co/trading/udf/history/
384
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
385
+ * @param {string} timeframe the length of time each candle represents
386
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
387
+ * @param {int} [limit] the maximum amount of candles to fetch
388
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
389
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
390
+ */
391
+ await this.loadMarkets();
392
+ const market = this.market(symbol);
393
+ const endTime = Date.now();
394
+ const request = {
395
+ 'symbol': market['base'] + '/' + market['quote'],
396
+ 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
397
+ 'from': (endTime / 1000) - (30 * 24 * 60 * 60),
398
+ 'to': endTime / 1000,
399
+ };
400
+ if (since !== undefined) {
401
+ request['from'] = since / 1000;
402
+ }
403
+ request['from'] = this.safeInteger(request, 'from');
404
+ request['to'] = this.safeInteger(request, 'to');
405
+ const response = await this.publicGetUdfHistory(request);
406
+ // Response structure:
407
+ // {
408
+ // "c": [12710726290.0, 12732737270.0, ...], // close prices
409
+ // "v": [0.015461630724, 0.024055443184, ...], // volumes
410
+ // "l": [12702815580.0, 12689256670.0, ...], // low prices
411
+ // "h": [12723701120.0, 12752332240.0, ...], // high prices
412
+ // "o": [12752332240.0, 12710726290.0, ...], // open prices
413
+ // "t": [1760271600, 1760272500, ...] // timestamps
414
+ // }
415
+ const closeList = this.safeList(response, 'c', []);
416
+ const volumeList = this.safeList(response, 'v', []);
417
+ const lowList = this.safeList(response, 'l', []);
418
+ const highList = this.safeList(response, 'h', []);
419
+ const openList = this.safeList(response, 'o', []);
420
+ const timestampList = this.safeList(response, 't', []);
421
+ const ohlcvs = [];
422
+ for (let i = 0; i < openList.length; i++) {
423
+ ohlcvs.push([
424
+ this.safeTimestamp(timestampList, i),
425
+ this.safeNumber(openList, i),
426
+ this.safeNumber(highList, i),
427
+ this.safeNumber(lowList, i),
428
+ this.safeNumber(closeList, i),
429
+ this.safeNumber(volumeList, i),
430
+ ]);
431
+ }
432
+ return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
433
+ }
434
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
435
+ const query = this.omit(params, this.extractParams(path));
436
+ let url = this.urls['api']['public'] + '/' + path;
437
+ if (path === 'market/prices') {
438
+ url = url + '/';
439
+ }
440
+ if (path === 'udf/history') {
441
+ url = url + '/?' + this.urlencode(query);
442
+ }
443
+ headers = { 'Content-Type': 'application/json' };
444
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
445
+ }
446
+ }