ccxt-ir 4.9.3 → 4.9.10

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 (79) hide show
  1. package/README.md +7 -7
  2. package/dist/ccxt.browser.min.js +4 -4
  3. package/dist/cjs/ccxt.js +25 -1
  4. package/dist/cjs/src/abantether.js +88 -69
  5. package/dist/cjs/src/abstract/bitbarg.js +11 -0
  6. package/dist/cjs/src/abstract/bydfi.js +11 -0
  7. package/dist/cjs/src/abstract/cafearz.js +11 -0
  8. package/dist/cjs/src/abstract/hamtapay.js +11 -0
  9. package/dist/cjs/src/abstract/kifpoolme.js +11 -0
  10. package/dist/cjs/src/abstract/mazdax.js +11 -0
  11. package/dist/cjs/src/abstract/pingi.js +11 -0
  12. package/dist/cjs/src/abstract/pooleno.js +11 -0
  13. package/dist/cjs/src/afratether.js +84 -36
  14. package/dist/cjs/src/arzplus.js +33 -16
  15. package/dist/cjs/src/bitbarg.js +313 -0
  16. package/dist/cjs/src/bydfi.js +435 -0
  17. package/dist/cjs/src/cafearz.js +347 -0
  18. package/dist/cjs/src/hamtapay.js +300 -0
  19. package/dist/cjs/src/kifpoolme.js +411 -0
  20. package/dist/cjs/src/mazdax.js +536 -0
  21. package/dist/cjs/src/pingi.js +448 -0
  22. package/dist/cjs/src/pooleno.js +348 -0
  23. package/dist/cjs/src/tetherland.js +8 -4
  24. package/dist/cjs/src/twox.js +55 -28
  25. package/js/ccxt.d.ts +26 -2
  26. package/js/ccxt.js +18 -2
  27. package/js/src/abantether.js +88 -69
  28. package/js/src/abstract/abantether.d.ts +1 -1
  29. package/js/src/abstract/bitbarg.d.ts +8 -0
  30. package/js/src/abstract/bitbarg.js +11 -0
  31. package/js/src/abstract/bydfi.d.ts +11 -0
  32. package/js/src/abstract/bydfi.js +11 -0
  33. package/js/src/abstract/cafearz.d.ts +8 -0
  34. package/js/src/abstract/cafearz.js +11 -0
  35. package/js/src/abstract/hamtapay.d.ts +9 -0
  36. package/js/src/abstract/hamtapay.js +11 -0
  37. package/js/src/abstract/kifpoolme.d.ts +9 -0
  38. package/js/src/abstract/kifpoolme.js +11 -0
  39. package/js/src/abstract/mazdax.d.ts +11 -0
  40. package/js/src/abstract/mazdax.js +11 -0
  41. package/js/src/abstract/pingi.d.ts +9 -0
  42. package/js/src/abstract/pingi.js +11 -0
  43. package/js/src/abstract/pooleno.d.ts +8 -0
  44. package/js/src/abstract/pooleno.js +11 -0
  45. package/js/src/afratether.js +84 -36
  46. package/js/src/arzplus.d.ts +4 -3
  47. package/js/src/arzplus.js +33 -16
  48. package/js/src/base/Exchange.d.ts +2 -2
  49. package/js/src/base/types.d.ts +1 -1
  50. package/js/src/bitbarg.d.ts +21 -0
  51. package/js/src/bitbarg.js +312 -0
  52. package/js/src/bydfi.d.ts +23 -0
  53. package/js/src/bydfi.js +434 -0
  54. package/js/src/cafearz.d.ts +21 -0
  55. package/js/src/cafearz.js +346 -0
  56. package/js/src/coinbaseexchange.d.ts +1 -1
  57. package/js/src/hamtapay.d.ts +21 -0
  58. package/js/src/hamtapay.js +299 -0
  59. package/js/src/kifpoolme.d.ts +23 -0
  60. package/js/src/kifpoolme.js +410 -0
  61. package/js/src/mazdax.d.ts +23 -0
  62. package/js/src/mazdax.js +535 -0
  63. package/js/src/pingi.d.ts +22 -0
  64. package/js/src/pingi.js +447 -0
  65. package/js/src/pooleno.d.ts +21 -0
  66. package/js/src/pooleno.js +347 -0
  67. package/js/src/protobuf/mexc/compiled.d.cts +0 -6
  68. package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
  69. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +2 -2
  70. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  71. package/js/src/static_dependencies/qs/formats.d.cts +0 -6
  72. package/js/src/static_dependencies/qs/index.d.cts +0 -6
  73. package/js/src/static_dependencies/qs/parse.d.cts +0 -6
  74. package/js/src/static_dependencies/qs/stringify.d.cts +0 -6
  75. package/js/src/static_dependencies/qs/utils.d.cts +0 -6
  76. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  77. package/js/src/tetherland.js +5 -4
  78. package/js/src/twox.js +55 -28
  79. package/package.json +1 -1
@@ -23,7 +23,7 @@ class afratether extends afratether$1["default"] {
23
23
  'pro': false,
24
24
  'has': {
25
25
  'CORS': undefined,
26
- 'spot': true,
26
+ 'spot': false,
27
27
  'margin': false,
28
28
  'swap': false,
29
29
  'future': false,
@@ -79,6 +79,7 @@ class afratether extends afratether$1["default"] {
79
79
  'fetchTradingFee': false,
80
80
  'fetchTradingFees': false,
81
81
  'fetchWithdrawals': false,
82
+ 'otc': true,
82
83
  'setLeverage': false,
83
84
  'setMarginMode': false,
84
85
  'transfer': false,
@@ -138,21 +139,43 @@ class afratether extends afratether$1["default"] {
138
139
  }
139
140
  parseMarket(market) {
140
141
  // {
141
- // "currencyAbb": "BTC",
142
- // "nameEn": "Bitcoin",
143
- // "nameFa": "بیت کوین",
144
- // "icon": "/assets/crypto/BTC.png",
145
- // "currency": "BTC",
146
- // "prices": [
147
- // {
148
- // "currency": "USDT",
149
- // "price": "67797.1"
142
+ // "currencyAbb": "USDT",
143
+ // "nameEn": "Tether",
144
+ // "nameFa": "تتر",
145
+ // "icon": "/assets/crypto/usdt.png",
146
+ // "round": 1000000,
147
+ // "currency": "USDT",
148
+ // "changeRate24h": "-0.0065",
149
+ // "Klines": [
150
+ // [
151
+ // "1760227200000",
152
+ // "1147500",
153
+ // "1140000",
154
+ // "1145500",
155
+ // "1125000",
156
+ // "0",
157
+ // "0"
158
+ // ],
159
+ // ],
160
+ // "info": {
161
+ // "birth_date": 1412553600000,
162
+ // "open_24h": 1,
163
+ // "open_1w": 1,
164
+ // "open_3M": 1,
165
+ // "open_1y": 1
166
+ // },
167
+ // "prices": {
168
+ // "USDT": {
169
+ // "price": "1"
170
+ // },
171
+ // "IRR": {
172
+ // "price_sell": 1135000,
173
+ // "price_buy": 1123000
150
174
  // }
151
- // ]
152
- // },
153
- const details = this.safeList(market, 'prices');
175
+ // }
176
+ // }
154
177
  let baseId = this.safeString(market, 'currency');
155
- let quoteId = this.safeString(details[0], 'currency');
178
+ let quoteId = 'IRR';
156
179
  const base = this.safeCurrencyCode(baseId);
157
180
  const quote = this.safeCurrencyCode(quoteId);
158
181
  const id = base + quote;
@@ -167,8 +190,8 @@ class afratether extends afratether$1["default"] {
167
190
  'baseId': baseId,
168
191
  'quoteId': quoteId,
169
192
  'settleId': undefined,
170
- 'type': 'spot',
171
- 'spot': true,
193
+ 'type': 'otc',
194
+ 'spot': false,
172
195
  'margin': false,
173
196
  'swap': false,
174
197
  'future': false,
@@ -251,41 +274,66 @@ class afratether extends afratether$1["default"] {
251
274
  }
252
275
  parseTicker(ticker, market = undefined) {
253
276
  // {
254
- // "currencyAbb": "BTC",
255
- // "nameEn": "Bitcoin",
256
- // "nameFa": "بیت کوین",
257
- // "icon": "/assets/crypto/BTC.png",
258
- // "currency": "BTC",
259
- // "prices": [
260
- // {
261
- // "currency": "USDT",
262
- // "price": "67797.1"
277
+ // "currencyAbb": "USDT",
278
+ // "nameEn": "Tether",
279
+ // "nameFa": "تتر",
280
+ // "icon": "/assets/crypto/usdt.png",
281
+ // "round": 1000000,
282
+ // "currency": "USDT",
283
+ // "changeRate24h": "-0.0065",
284
+ // "Klines": [
285
+ // [
286
+ // "1760227200000",
287
+ // "1147500",
288
+ // "1140000",
289
+ // "1145500",
290
+ // "1125000",
291
+ // "0",
292
+ // "0"
293
+ // ],
294
+ // ],
295
+ // "info": {
296
+ // "birth_date": 1412553600000,
297
+ // "open_24h": 1,
298
+ // "open_1w": 1,
299
+ // "open_3M": 1,
300
+ // "open_1y": 1
301
+ // },
302
+ // "prices": {
303
+ // "USDT": {
304
+ // "price": "1"
305
+ // },
306
+ // "IRR": {
307
+ // "price_sell": 1135000,
308
+ // "price_buy": 1123000
263
309
  // }
264
- // ]
265
- // },
310
+ // }
311
+ // }
266
312
  const marketType = 'otc';
267
- const details = this.safeList(ticker, 'prices');
268
313
  const base = this.safeString(ticker, 'currency');
269
- const quote = this.safeString(details[0], 'currency');
270
- const marketId = base + quote;
314
+ const quote = 'IRR';
315
+ const marketId = base + '/' + quote;
271
316
  const symbol = this.safeSymbol(marketId, market, undefined, marketType);
272
- const last = this.safeFloat(details[0], 'price', 0);
317
+ const prices = this.safeDict(ticker, 'prices', {});
318
+ const irrPrices = this.safeDict(prices, 'IRR', {});
319
+ const sell = this.safeFloat(irrPrices, 'price_sell', 0);
320
+ const buy = this.safeFloat(irrPrices, 'price_buy', 0);
273
321
  return this.safeTicker({
274
322
  'symbol': symbol,
275
323
  'timestamp': undefined,
276
324
  'datetime': undefined,
277
325
  'high': undefined,
278
326
  'low': undefined,
279
- 'bid': undefined,
327
+ 'bid': sell,
280
328
  'bidVolume': undefined,
281
- 'ask': undefined,
329
+ 'ask': buy,
282
330
  'askVolume': undefined,
283
331
  'vwap': undefined,
284
332
  'open': undefined,
285
- 'close': last,
286
- 'last': last,
333
+ 'close': buy,
334
+ 'last': buy,
287
335
  'previousClose': undefined,
288
- 'change': undefined,
336
+ 'change': this.safeFloat(ticker, 'changeRate24h', undefined),
289
337
  'percentage': undefined,
290
338
  'average': undefined,
291
339
  'baseVolume': undefined,
@@ -131,8 +131,15 @@ class arzplus extends arzplus$1["default"] {
131
131
  'stats': '1',
132
132
  'enable': 'true',
133
133
  };
134
- const response = await this.publicGetApiV1MarketSymbols(request);
135
- const otcMarkets = await this.publicGetApiV1MarketIrtInfo(request);
134
+ const typedRequest = this.safeString(params, 'type', 'spot');
135
+ let response = [];
136
+ let otcMarkets = [];
137
+ if (typedRequest === 'otc') {
138
+ otcMarkets = await this.publicGetApiV1MarketIrtInfo(request);
139
+ }
140
+ else {
141
+ response = await this.publicGetApiV1MarketSymbols(request);
142
+ }
136
143
  const result = [];
137
144
  for (let i = 0; i < response.length; i++) {
138
145
  const market = this.parseMarket(response[i]);
@@ -145,12 +152,15 @@ class arzplus extends arzplus$1["default"] {
145
152
  const parsedMarket = this.parseOTCMarkets(marketdata);
146
153
  result.push(parsedMarket);
147
154
  }
148
- if (params['type']) {
149
- return this.filterByArray(result, 'type', params['type'], false);
150
- }
151
155
  return result;
152
156
  }
153
- parseMarket(market) {
157
+ parseMarket(market, type = 'spot') {
158
+ if (type === 'otc') {
159
+ return this.parseOTCMarkets(market);
160
+ }
161
+ return this.parseSpotMarket(market);
162
+ }
163
+ parseSpotMarket(market) {
154
164
  // {
155
165
  // 'name': 'USDTIRT',
156
166
  // 'asset': {
@@ -248,10 +258,12 @@ class arzplus extends arzplus$1["default"] {
248
258
  }
249
259
  parseOTCMarkets(market) {
250
260
  // {
251
- // symbol: "BTC",
252
- // ask: "13877900000",
253
- // bid: "13860999995",
254
- // name: "bitcoin"
261
+ // symbol: "BTC",
262
+ // ask: "13877900000",
263
+ // bid: "13860999995",
264
+ // name: "bitcoin"
265
+ // qoute: "IRT",
266
+ // id: "OTC_BTCIRT"
255
267
  // },
256
268
  const baseAsset = this.safeString(market, 'symbol');
257
269
  const quoteAsset = this.safeString(market, 'quote');
@@ -270,7 +282,7 @@ class arzplus extends arzplus$1["default"] {
270
282
  'quoteId': quoteId,
271
283
  'settleId': undefined,
272
284
  'type': 'otc',
273
- 'spot': true,
285
+ 'spot': false,
274
286
  'margin': false,
275
287
  'swap': false,
276
288
  'future': false,
@@ -320,12 +332,13 @@ class arzplus extends arzplus$1["default"] {
320
332
  * @param {object} [params] extra parameters specific to the exchange API endpoint
321
333
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
322
334
  */
323
- await this.loadMarkets();
335
+ const marketType = this.safeString(params, 'type', 'spot');
336
+ await this.loadMarkets(false, { 'type': marketType });
324
337
  if (symbols !== undefined) {
325
338
  symbols = this.marketSymbols(symbols);
326
339
  }
327
340
  const result = {};
328
- if (params['type'] === 'otc') {
341
+ if (marketType === 'otc') {
329
342
  const otcMarkets = await this.publicGetApiV1MarketIrtInfo(params);
330
343
  for (let i = 0; i < otcMarkets.length; i++) {
331
344
  const marketdata = otcMarkets[i];
@@ -359,7 +372,11 @@ class arzplus extends arzplus$1["default"] {
359
372
  * @param {object} [params] extra parameters specific to the exchange API endpoint
360
373
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
361
374
  */
362
- await this.loadMarkets();
375
+ const marketType = this.safeString(params, 'type', 'spot');
376
+ if (marketType === 'otc') {
377
+ throw new Error('OTC markets are not supported');
378
+ }
379
+ await this.loadMarkets(false, { 'type': marketType });
363
380
  const market = this.market(symbol);
364
381
  const request = {
365
382
  'symbol': market['id'],
@@ -488,7 +505,7 @@ class arzplus extends arzplus$1["default"] {
488
505
  * @param {object} [params] extra parameters specific to the exchange API endpoint
489
506
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
490
507
  */
491
- await this.loadMarkets();
508
+ await this.loadMarkets(false, { 'type': 'otc' });
492
509
  const market = this.market(symbol);
493
510
  const endTime = Date.now();
494
511
  const request = {
@@ -534,7 +551,7 @@ class arzplus extends arzplus$1["default"] {
534
551
  * @param {object} [params] extra parameters specific to the exchange API endpoint
535
552
  * @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
536
553
  */
537
- await this.loadMarkets();
554
+ await this.loadMarkets(false, { 'type': 'otc' });
538
555
  const market = this.market(symbol);
539
556
  const request = {
540
557
  'symbol': market['id'],
@@ -0,0 +1,313 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var bitbarg$1 = require('./abstract/bitbarg.js');
6
+
7
+ // ----------------------------------------------------------------------------
8
+ // ---------------------------------------------------------------------------
9
+ /**
10
+ * @class bitbarg
11
+ * @augments Exchange
12
+ * @description Set rateLimit to 1000 if fully verified
13
+ */
14
+ class bitbarg extends bitbarg$1["default"] {
15
+ describe() {
16
+ return this.deepExtend(super.describe(), {
17
+ 'id': 'bitbarg',
18
+ 'name': 'Bitbarg',
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
+ 'fetchL3OrderBook': false,
60
+ 'fetchLedger': false,
61
+ 'fetchLedgerEntry': false,
62
+ 'fetchLeverageTiers': false,
63
+ 'fetchMarkets': true,
64
+ 'fetchMarkOHLCV': false,
65
+ 'fetchMyTrades': false,
66
+ 'fetchOHLCV': false,
67
+ 'fetchOpenInterestHistory': false,
68
+ 'fetchOpenOrders': false,
69
+ 'fetchOrder': false,
70
+ 'fetchOrderBook': false,
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/bitbarg/64x64.png',
90
+ 'api': {
91
+ 'public': 'https://api.bitbarg.com',
92
+ },
93
+ 'www': 'https://bitbarg.com/',
94
+ 'doc': [
95
+ 'https://bitbarg.com/',
96
+ ],
97
+ },
98
+ 'api': {
99
+ 'public': {
100
+ 'get': {
101
+ '/api/v1/currencies': 1,
102
+ },
103
+ },
104
+ },
105
+ 'fees': {
106
+ 'trading': {
107
+ 'tierBased': false,
108
+ 'percentage': true,
109
+ 'maker': this.parseNumber('0.001'),
110
+ 'taker': this.parseNumber('0.001'),
111
+ },
112
+ },
113
+ });
114
+ }
115
+ parseMarket(market) {
116
+ // "id": 53,
117
+ // "icon": "https://s3.bitbarg.com/currencies/btc.webp",
118
+ // "tradeActive": true,
119
+ // "faName": "بیت کوین",
120
+ // "enName": "Bitcoin",
121
+ // "coin": "BTC",
122
+ // "path": "bitcoin",
123
+ // "price": 112192,
124
+ // "quote": "813430226.5004",
125
+ // "percent": -5.735,
126
+ // "decimal": 8,
127
+ // "isFavorite": false,
128
+ const baseId = this.safeString(market, 'coin');
129
+ const quoteId = 'USDT';
130
+ const base = this.safeCurrencyCode(baseId);
131
+ const quote = this.safeCurrencyCode(quoteId);
132
+ const id = baseId + '/' + quoteId;
133
+ return {
134
+ 'id': id,
135
+ 'symbol': id,
136
+ 'base': base,
137
+ 'quote': quote,
138
+ 'settle': undefined,
139
+ 'baseId': baseId,
140
+ 'quoteId': quoteId,
141
+ 'settleId': undefined,
142
+ 'type': 'otc',
143
+ 'spot': false,
144
+ 'margin': false,
145
+ 'swap': false,
146
+ 'future': false,
147
+ 'option': false,
148
+ 'active': true,
149
+ 'contract': false,
150
+ 'linear': undefined,
151
+ 'inverse': undefined,
152
+ 'contractSize': undefined,
153
+ 'expiry': undefined,
154
+ 'expiryDatetime': undefined,
155
+ 'strike': undefined,
156
+ 'optionType': undefined,
157
+ 'precision': {
158
+ 'amount': undefined,
159
+ 'price': undefined,
160
+ },
161
+ 'limits': {
162
+ 'leverage': {
163
+ 'min': undefined,
164
+ 'max': undefined,
165
+ },
166
+ 'amount': {
167
+ 'min': undefined,
168
+ 'max': undefined,
169
+ },
170
+ 'price': {
171
+ 'min': undefined,
172
+ 'max': undefined,
173
+ },
174
+ 'cost': {
175
+ 'min': undefined,
176
+ 'max': undefined,
177
+ },
178
+ },
179
+ 'created': undefined,
180
+ 'info': market,
181
+ };
182
+ }
183
+ async fetchMarkets(params = {}) {
184
+ /**
185
+ * @method
186
+ * @name bitbarg#fetchMarkets
187
+ * @description retrieves data on all markets for bitbarg
188
+ * @see https://api.bitbarg.com/api/v1/currencies?pageSize=-1
189
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
190
+ * @returns {object[]} an array of objects representing market data
191
+ */
192
+ const request = {
193
+ 'pageSize': -1,
194
+ };
195
+ const response = await this.publicGetApiV1Currencies(this.extend(request, params));
196
+ const result = [];
197
+ const data = this.safeDict(response, 'result', {});
198
+ const items = this.safeList(data, 'items', []);
199
+ // Create markets for each currency with IRT quote
200
+ for (let i = 0; i < items.length; i++) {
201
+ const market = this.parseMarket(items[i]);
202
+ result.push(market);
203
+ }
204
+ return result;
205
+ }
206
+ async fetchTickers(symbols = undefined, params = {}) {
207
+ /**
208
+ * @method
209
+ * @name bitbarg#fetchTickers
210
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
211
+ * @see https://api.bitbarg.com/api/v1/currencies?pageSize=-1
212
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
213
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
214
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
215
+ */
216
+ await this.loadMarkets();
217
+ if (symbols !== undefined) {
218
+ symbols = this.marketSymbols(symbols);
219
+ }
220
+ const request = {
221
+ 'pageSize': -1,
222
+ };
223
+ const response = await this.publicGetApiV1Currencies(this.extend(request, params));
224
+ const data = this.safeDict(response, 'result', {});
225
+ const items = this.safeList(data, 'items', []);
226
+ const result = {};
227
+ for (let i = 0; i < items.length; i++) {
228
+ const coinData = items[i];
229
+ const baseId = this.safeString(coinData, 'coin');
230
+ // Create ticker for USDT quote
231
+ const quoteId = 'USDT';
232
+ const base = this.safeCurrencyCode(baseId);
233
+ const quote = this.safeCurrencyCode(quoteId);
234
+ const symbol = base + '/' + quote;
235
+ const ticker = this.extend({
236
+ 'symbol': symbol,
237
+ 'baseId': baseId,
238
+ 'quoteId': quoteId,
239
+ 'id': baseId + '/' + quoteId,
240
+ }, coinData);
241
+ result[symbol] = this.parseTicker(ticker);
242
+ }
243
+ return this.filterByArrayTickers(result, 'symbol', symbols);
244
+ }
245
+ async fetchTicker(symbol, params = {}) {
246
+ /**
247
+ * @method
248
+ * @name bitbarg#fetchTicker
249
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
250
+ * @see https://api.bitbarg.com/api/v1/currencies?pageSize=-1
251
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
252
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
253
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
254
+ */
255
+ const ticker = await this.fetchTickers([symbol]);
256
+ return ticker[symbol];
257
+ }
258
+ parseTicker(ticker, market = undefined) {
259
+ // {
260
+ // "id": 1,
261
+ // "icon": "https://...",
262
+ // "tradeActive": true,
263
+ // "faName": "بیت کوین",
264
+ // "enName": "Bitcoin",
265
+ // "coin": "BTC",
266
+ // "path": "bitcoin",
267
+ // "price": 110387.56,
268
+ // "quote": "57479298399.76",
269
+ // "percent": -3.01,
270
+ // "decimal": 5,
271
+ // "isFavorite": false,
272
+ // "chart": [...]
273
+ // }
274
+ const marketType = 'otc';
275
+ const marketId = this.safeString(ticker, 'coin') + '/' + 'USDT';
276
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
277
+ const last = this.safeFloat(ticker, 'price', 0);
278
+ const percentage = this.safeFloat(ticker, 'percent', 0);
279
+ const baseVolume = this.safeFloat(ticker, 'quote');
280
+ return this.safeTicker({
281
+ 'symbol': symbol,
282
+ 'timestamp': undefined,
283
+ 'datetime': undefined,
284
+ 'high': undefined,
285
+ 'low': undefined,
286
+ 'bid': last,
287
+ 'bidVolume': undefined,
288
+ 'ask': last,
289
+ 'askVolume': undefined,
290
+ 'vwap': undefined,
291
+ 'open': undefined,
292
+ 'close': last,
293
+ 'last': last,
294
+ 'previousClose': undefined,
295
+ 'change': undefined,
296
+ 'percentage': percentage,
297
+ 'average': undefined,
298
+ 'baseVolume': baseVolume,
299
+ 'quoteVolume': undefined,
300
+ 'info': ticker,
301
+ }, market);
302
+ }
303
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
304
+ let url = this.urls['api']['public'] + path;
305
+ if (Object.keys(params).length) {
306
+ url += '?' + this.urlencode(params);
307
+ }
308
+ headers = { 'Content-Type': 'application/json' };
309
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
310
+ }
311
+ }
312
+
313
+ exports["default"] = bitbarg;