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/bitpin.js CHANGED
@@ -4,475 +4,484 @@
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/bitpin.js';
9
- // ---------------------------------------------------------------------------
10
- /**
11
- * @class bitpin
12
- * @augments Exchange
13
- * @description Set rateLimit to 1000 if fully verified
14
- */
15
- export default class bitpin extends Exchange {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'bitpin',
19
- 'name': 'bitpin',
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
- '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': true,
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': 'This comment is optional',
89
- 'urls': {
90
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bitpin/64x64.png',
91
- 'api': {
92
- 'public': 'https://api.bitpin.ir',
93
- 'OHLCV': 'https://api.bitpin.org',
94
- },
95
- 'www': 'https://bitpin.ir',
96
- 'doc': [
97
- 'https://docs.bitpin.ir',
98
- ],
99
- },
100
- 'timeframes': {
101
- '1m': '1',
102
- '5m': '5',
103
- '15m': '15',
104
- '30m': '30',
105
- '1h': '60',
106
- '3h': '180',
107
- '4h': '240',
108
- '12h': '720',
109
- '1d': '1D',
110
- '1w': '1W',
111
- },
112
- 'api': {
113
- 'public': {
114
- 'get': {
115
- 'v1/mkt/markets/': 1,
116
- 'v2/mth/actives/': 1,
117
- 'v1/mkt/tv/get_bars/': 1,
118
- },
119
- },
120
- },
121
- 'fees': {
122
- 'trading': {
123
- 'tierBased': false,
124
- 'percentage': true,
125
- 'maker': this.parseNumber('0.001'),
126
- 'taker': this.parseNumber('0.001'),
127
- },
128
- },
129
- });
130
- }
131
- async fetchMarkets(params = {}) {
132
- /**
133
- * @method
134
- * @name bitpin#fetchMarkets
135
- * @description retrieves data on all markets for bitpin
136
- * @see https://api-docs.bitpin.ir/#be8d9c51a2
137
- * @param {object} [params] extra parameters specific to the exchange API endpoint
138
- * @returns {object[]} an array of objects representing market data
139
- */
140
- const response = await this.publicGetV1MktMarkets(params);
141
- const markets = this.safeList(response, 'results');
142
- const result = [];
143
- for (let i = 0; i < markets.length; i++) {
144
- const market = this.parseMarket(markets[i]);
145
- result.push(market);
146
- }
147
- return result;
148
- }
149
- parseMarket(market) {
150
- const id = this.safeString(market, 'id');
151
- const baseCurrency = this.safeDict(market, 'currency1');
152
- const quoteCurrency = this.safeDict(market, 'currency2');
153
- let baseId = this.safeString(baseCurrency, 'code');
154
- let quoteId = this.safeString(quoteCurrency, 'code');
155
- const base = this.safeCurrencyCode(baseId);
156
- const quote = this.safeCurrencyCode(quoteId);
157
- baseId = baseId.toLowerCase();
158
- quoteId = quoteId.toLowerCase();
159
- return {
160
- 'id': id,
161
- 'symbol': base + '/' + quote,
162
- 'base': base,
163
- 'quote': quote,
164
- 'settle': undefined,
165
- 'baseId': baseId,
166
- 'quoteId': quoteId,
167
- 'settleId': undefined,
168
- 'type': 'spot',
169
- 'spot': true,
170
- 'margin': false,
171
- 'swap': false,
172
- 'future': false,
173
- 'option': false,
174
- 'active': true,
175
- 'contract': false,
176
- 'linear': undefined,
177
- 'inverse': undefined,
178
- 'contractSize': undefined,
179
- 'expiry': undefined,
180
- 'expiryDatetime': undefined,
181
- 'strike': undefined,
182
- 'optionType': undefined,
183
- 'precision': {
184
- 'amount': undefined,
185
- 'price': undefined,
186
- },
187
- 'limits': {
188
- 'leverage': {
189
- 'min': undefined,
190
- 'max': undefined,
191
- },
192
- 'amount': {
193
- 'min': undefined,
194
- 'max': undefined,
195
- },
196
- 'price': {
197
- 'min': undefined,
198
- 'max': undefined,
199
- },
200
- 'cost': {
201
- 'min': undefined,
202
- 'max': undefined,
203
- },
204
- },
205
- 'created': undefined,
206
- 'info': market,
207
- };
208
- }
209
- async fetchTickers(symbols = undefined, params = {}) {
210
- /**
211
- * @method
212
- * @name bitpin#fetchTickers
213
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
214
- * @see https://api-docs.bitpin.ir/#be8d9c51a2
215
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
216
- * @param {object} [params] extra parameters specific to the exchange API endpoint
217
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
218
- */
219
- await this.loadMarkets();
220
- if (symbols !== undefined) {
221
- symbols = this.marketSymbols(symbols);
222
- }
223
- const response = await this.publicGetV1MktMarkets(params);
224
- const markets = this.safeList(response, 'results');
225
- const result = {};
226
- for (let i = 0; i < markets.length; i++) {
227
- const is_active = this.safeBool(markets[i], 'tradable');
228
- if (is_active === true) {
229
- const ticker = this.parseTicker(markets[i]);
230
- const symbol = ticker['symbol'];
231
- result[symbol] = ticker;
232
- }
233
- }
234
- return this.filterByArrayTickers(result, 'symbol', symbols);
235
- }
236
- async fetchTicker(symbol, params = {}) {
237
- /**
238
- * @method
239
- * @name bitpin#fetchTicker
240
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
241
- * @see https://api-docs.bitpin.ir/#be8d9c51a2
242
- * @param {string} symbol unified symbol of the market to fetch the ticker for
243
- * @param {object} [params] extra parameters specific to the exchange API endpoint
244
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
245
- */
246
- const ticker = await this.fetchTickers([symbol]);
247
- return ticker[symbol];
248
- }
249
- parseTicker(ticker, market = undefined) {
250
- // {
251
- // 'id': 1,
252
- // 'currency1': {
253
- // 'id': 1,
254
- // 'title': 'Bitcoin',
255
- // 'title_fa': 'بیت کوین',
256
- // 'code': 'BTC',
257
- // 'tradable': true,
258
- // 'for_test': false,
259
- // 'image': 'https://cdn.bitpin.ir/media/market/currency/1697370601.svg',
260
- // 'decimal': 2,
261
- // 'decimal_amount': 8,
262
- // 'decimal_irt': 0,
263
- // 'color': 'f7931a',
264
- // 'high_risk': false,
265
- // 'show_high_risk': false,
266
- // 'withdraw_commission': '0.003000000000000000',
267
- // 'tags': [
268
- // {
269
- // 'id': 44,
270
- // 'name': 'لایه ۱',
271
- // 'name_en': 'layer-1',
272
- // 'has_chart': true,
273
- // },
274
- // {
275
- // 'id': 52,
276
- // 'name': 'اثبات کار',
277
- // 'name_en': 'pow',
278
- // 'has_chart': true,
279
- // },
280
- // ],
281
- // 'etf': false,
282
- // 'for_binvest': false,
283
- // 'for_loan': true,
284
- // 'for_stake': false,
285
- // 'recommend_for_deposit_weight': 1,
286
- // },
287
- // 'currency2': {
288
- // 'id': 2,
289
- // 'title': 'Toman',
290
- // 'title_fa': 'تومان',
291
- // 'code': 'IRT',
292
- // 'tradable': true,
293
- // 'for_test': false,
294
- // 'image': 'https://cdn.bitpin.ir/media/market/currency/1684671406.svg',
295
- // 'decimal': 0,
296
- // 'decimal_amount': 0,
297
- // 'decimal_irt': 1,
298
- // 'color': '00fd22',
299
- // 'high_risk': false,
300
- // 'show_high_risk': false,
301
- // 'withdraw_commission': '0.000200000000000000',
302
- // 'tags': [ ],
303
- // 'etf': false,
304
- // 'for_binvest': false,
305
- // 'for_loan': false,
306
- // 'for_stake': false,
307
- // 'recommend_for_deposit_weight': 0,
308
- // },
309
- // 'tradable': true,
310
- // 'for_test': false,
311
- // 'otc_sell_percent': '0.01000',
312
- // 'otc_buy_percent': '0.01000',
313
- // 'otc_max_buy_amount': '0.017000000000000000',
314
- // 'otc_max_sell_amount': '0.017000000000000000',
315
- // 'order_book_info': {
316
- // 'created_at': null,
317
- // 'price': '3894924262',
318
- // 'change': 0.0179,
319
- // 'min': '3777777800',
320
- // 'max': '3925000000',
321
- // 'time': '2024-05-19T13:45:00.000Z',
322
- // 'mean': '3833950912',
323
- // 'value': '6215833783',
324
- // 'amount': '1.62286922',
325
- // },
326
- // 'internal_price_info': {
327
- // 'created_at': 1716126301.298626,
328
- // 'price': '3894924262',
329
- // 'change': 1.8,
330
- // 'min': '3777777800',
331
- // 'max': '3925000000',
332
- // 'time': null,
333
- // 'mean': null,
334
- // 'value': null,
335
- // 'amount': null,
336
- // },
337
- // 'price_info': {
338
- // 'created_at': 1716126370.677,
339
- // 'price': '3906940950',
340
- // 'change': 2.04,
341
- // 'min': '3785113135',
342
- // 'max': '3921003333',
343
- // 'time': null,
344
- // 'mean': null,
345
- // 'value': null,
346
- // 'amount': null,
347
- // },
348
- // 'price': '3906940950',
349
- // 'title': 'Bitcoin/Toman',
350
- // 'code': 'BTC_IRT',
351
- // 'title_fa': 'بیت کوین/تومان',
352
- // 'trading_view_source': 'BINANCE',
353
- // 'trading_view_symbol': 'BTCUSDT',
354
- // 'otc_market': false,
355
- // 'text': '',
356
- // 'volume_24h': '2318294704054686.000000000000000000',
357
- // 'market_cap': '43370130583253964.000000000000000000',
358
- // 'circulating_supply': '19588837.000000000000000000',
359
- // 'all_time_high': '3577014315.000000000000000000',
360
- // 'popularity_weight': 0,
361
- // 'freshness_weight': 0,
362
- // }
363
- const marketType = 'spot';
364
- const priceInfo = this.safeValue(ticker, 'order_book_info');
365
- const marketId = this.safeString(ticker, 'id');
366
- const symbol = this.safeSymbol(marketId, market, undefined, marketType);
367
- const high = this.safeFloat(priceInfo, 'max', 0);
368
- const low = this.safeFloat(priceInfo, 'min', 0);
369
- const last = this.safeFloat(priceInfo, 'price', 0);
370
- const change = this.safeFloat(priceInfo, 'change', 0);
371
- const baseVolume = this.safeFloat(priceInfo, 'amount', 0);
372
- const quoteVolume = this.safeFloat(priceInfo, 'value', 0);
373
- return this.safeTicker({
374
- 'symbol': symbol,
375
- 'timestamp': undefined,
376
- 'datetime': undefined,
377
- 'high': high,
378
- 'low': low,
379
- 'bid': undefined,
380
- 'bidVolume': undefined,
381
- 'ask': undefined,
382
- 'askVolume': undefined,
383
- 'vwap': undefined,
384
- 'open': undefined,
385
- 'close': last,
386
- 'last': last,
387
- 'previousClose': undefined,
388
- 'change': change,
389
- 'percentage': undefined,
390
- 'average': undefined,
391
- 'baseVolume': baseVolume,
392
- 'quoteVolume': quoteVolume,
393
- 'info': ticker,
394
- }, market);
395
- }
396
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
397
- /**
398
- * @method
399
- * @name bitpin#fetchOHLCV
400
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
401
- * @see https://api-docs.bitpin.ir/#be8d9c51a2
402
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
403
- * @param {string} timeframe the length of time each candle represents
404
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
405
- * @param {int} [limit] the maximum amount of candles to fetch
406
- * @param {object} [params] extra parameters specific to the exchange API endpoint
407
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
408
- */
409
- await this.loadMarkets();
410
- const market = this.market(symbol);
411
- const endTime = Date.now();
412
- const request = {
413
- 'symbol': market['symbol'].replace('/', '_'),
414
- 'from': (endTime / 1000) - (24 * 60 * 60),
415
- 'to': endTime / 1000,
416
- 'res': this.safeString(this.timeframes, timeframe, timeframe),
417
- };
418
- if (since !== undefined) {
419
- request['from'] = since / 1000;
420
- }
421
- request['from'] = this.safeInteger(request, 'from');
422
- request['to'] = this.safeInteger(request, 'to');
423
- if (timeframe !== undefined) {
424
- request['res'] = this.safeString(this.timeframes, timeframe, timeframe);
425
- }
426
- const response = await this.publicGetV1MktTvGetBars(request);
427
- const ohlcvs = [];
428
- for (let i = 0; i < response.length; i++) {
429
- ohlcvs.push([
430
- this.safeValue(response[i], 'ts'),
431
- this.safeFloat(response[i], 'open'),
432
- this.safeFloat(response[i], 'high'),
433
- this.safeFloat(response[i], 'low'),
434
- this.safeFloat(response[i], 'close'),
435
- this.safeFloat(response[i], 'volume'),
436
- ]);
437
- }
438
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
439
- }
440
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
441
- /**
442
- * @method
443
- * @name bitpin#fetchOrderBooks
444
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
445
- * @see https://api-docs.bitpin.ir/#be8d9c51a2
446
- * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
447
- * @param {int} [limit] max number of entries per orderbook to return, default is undefined
448
- * @param {object} [params] extra parameters specific to the exchange API endpoint
449
- * @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
450
- */
451
- await this.loadMarkets();
452
- const market = this.market(symbol);
453
- const request = {
454
- 'symbol': market['id'],
455
- 'type': 'buy',
456
- };
457
- const Buyresponse = await this.publicGetV2MthActives(request);
458
- request['type'] = 'sell';
459
- const Sellresponse = await this.publicGetV2MthActives(request);
460
- const BuyorderBook = this.safeDict(Buyresponse, 'orders', {});
461
- const SellorderBook = this.safeDict(Sellresponse, 'orders', {});
462
- const orderBook = { 'bid': BuyorderBook, 'ask': SellorderBook };
463
- const timestamp = Date.now();
464
- return this.parseOrderBook(orderBook, symbol, timestamp, 'bid', 'ask', 'price', 'amount');
465
- }
466
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
467
- const query = this.omit(params, this.extractParams(path));
468
- let url = this.urls['api'][api] + '/' + path;
469
- if (path === 'v1/mkt/tv/get_bars/') {
470
- url = this.urls['api']['OHLCV'] + '/' + path + '?' + this.urlencode(query);
471
- }
472
- if (path === 'v2/mth/actives/') {
473
- url = url + params['symbol'] + '/?type=' + params['type'];
474
- }
475
- headers = { 'Content-Type': 'application/json' };
476
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
477
- }
478
- }
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/bitpin.js';
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class bitpin
12
+ * @augments Exchange
13
+ * @description Set rateLimit to 1000 if fully verified
14
+ */
15
+ export default class bitpin extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'bitpin',
19
+ 'name': 'bitpin',
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
+ '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': true,
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': 'This comment is optional',
89
+ 'urls': {
90
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bitpin/64x64.png',
91
+ 'api': {
92
+ 'public': 'https://api.bitpin.ir',
93
+ 'OHLCV': 'https://api.bitpin.org',
94
+ },
95
+ 'www': 'https://bitpin.ir',
96
+ 'doc': [
97
+ 'https://docs.bitpin.ir',
98
+ ],
99
+ },
100
+ 'timeframes': {
101
+ '1m': '1',
102
+ '5m': '5',
103
+ '15m': '15',
104
+ '30m': '30',
105
+ '1h': '60',
106
+ '3h': '180',
107
+ '4h': '240',
108
+ '12h': '720',
109
+ '1d': '1D',
110
+ '1w': '1W',
111
+ },
112
+ 'api': {
113
+ 'public': {
114
+ 'get': {
115
+ 'v1/mkt/markets/': 1,
116
+ 'v2/mth/actives/': 1,
117
+ 'v1/mkt/tv/get_bars/': 1,
118
+ 'v4/mth/orderbook/': 1,
119
+ },
120
+ },
121
+ },
122
+ 'fees': {
123
+ 'trading': {
124
+ 'tierBased': false,
125
+ 'percentage': true,
126
+ 'maker': this.parseNumber('0.001'),
127
+ 'taker': this.parseNumber('0.001'),
128
+ },
129
+ },
130
+ });
131
+ }
132
+ async fetchMarkets(params = {}) {
133
+ /**
134
+ * @method
135
+ * @name bitpin#fetchMarkets
136
+ * @description retrieves data on all markets for bitpin
137
+ * @see https://api-docs.bitpin.ir/#be8d9c51a2
138
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
139
+ * @returns {object[]} an array of objects representing market data
140
+ */
141
+ const response = await this.publicGetV1MktMarkets(params);
142
+ const markets = this.safeList(response, 'results');
143
+ const result = [];
144
+ for (let i = 0; i < markets.length; i++) {
145
+ const market = this.parseMarket(markets[i]);
146
+ result.push(market);
147
+ }
148
+ return result;
149
+ }
150
+ parseMarket(market) {
151
+ const id = this.safeString(market, 'id');
152
+ const baseCurrency = this.safeDict(market, 'currency1');
153
+ const quoteCurrency = this.safeDict(market, 'currency2');
154
+ let baseId = this.safeString(baseCurrency, 'code');
155
+ let quoteId = this.safeString(quoteCurrency, 'code');
156
+ const base = this.safeCurrencyCode(baseId);
157
+ const quote = this.safeCurrencyCode(quoteId);
158
+ baseId = baseId.toLowerCase();
159
+ quoteId = quoteId.toLowerCase();
160
+ return {
161
+ 'id': id,
162
+ 'symbol': base + '/' + quote,
163
+ 'base': base,
164
+ 'quote': quote,
165
+ 'settle': undefined,
166
+ 'baseId': baseId,
167
+ 'quoteId': quoteId,
168
+ 'settleId': undefined,
169
+ 'type': 'spot',
170
+ 'spot': true,
171
+ 'margin': false,
172
+ 'swap': false,
173
+ 'future': false,
174
+ 'option': false,
175
+ 'active': true,
176
+ 'contract': false,
177
+ 'linear': undefined,
178
+ 'inverse': undefined,
179
+ 'contractSize': undefined,
180
+ 'expiry': undefined,
181
+ 'expiryDatetime': undefined,
182
+ 'strike': undefined,
183
+ 'optionType': undefined,
184
+ 'precision': {
185
+ 'amount': undefined,
186
+ 'price': undefined,
187
+ },
188
+ 'limits': {
189
+ 'leverage': {
190
+ 'min': undefined,
191
+ 'max': undefined,
192
+ },
193
+ 'amount': {
194
+ 'min': undefined,
195
+ 'max': undefined,
196
+ },
197
+ 'price': {
198
+ 'min': undefined,
199
+ 'max': undefined,
200
+ },
201
+ 'cost': {
202
+ 'min': undefined,
203
+ 'max': undefined,
204
+ },
205
+ },
206
+ 'created': undefined,
207
+ 'info': market,
208
+ };
209
+ }
210
+ async fetchTickers(symbols = undefined, params = {}) {
211
+ /**
212
+ * @method
213
+ * @name bitpin#fetchTickers
214
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
215
+ * @see https://api-docs.bitpin.ir/#be8d9c51a2
216
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
217
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
218
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
219
+ */
220
+ await this.loadMarkets();
221
+ if (symbols !== undefined) {
222
+ symbols = this.marketSymbols(symbols);
223
+ }
224
+ const response = await this.publicGetV1MktMarkets(params);
225
+ const markets = this.safeList(response, 'results');
226
+ const result = {};
227
+ for (let i = 0; i < markets.length; i++) {
228
+ const is_active = this.safeBool(markets[i], 'tradable');
229
+ if (is_active === true) {
230
+ const ticker = this.parseTicker(markets[i]);
231
+ const symbol = ticker['symbol'];
232
+ result[symbol] = ticker;
233
+ }
234
+ }
235
+ return this.filterByArrayTickers(result, 'symbol', symbols);
236
+ }
237
+ async fetchTicker(symbol, params = {}) {
238
+ /**
239
+ * @method
240
+ * @name bitpin#fetchTicker
241
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
242
+ * @see https://api-docs.bitpin.ir/#be8d9c51a2
243
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
244
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
245
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
246
+ */
247
+ const ticker = await this.fetchTickers([symbol]);
248
+ return ticker[symbol];
249
+ }
250
+ parseTicker(ticker, market = undefined) {
251
+ // {
252
+ // 'id': 1,
253
+ // 'currency1': {
254
+ // 'id': 1,
255
+ // 'title': 'Bitcoin',
256
+ // 'title_fa': 'بیت کوین',
257
+ // 'code': 'BTC',
258
+ // 'tradable': true,
259
+ // 'for_test': false,
260
+ // 'image': 'https://cdn.bitpin.ir/media/market/currency/1697370601.svg',
261
+ // 'decimal': 2,
262
+ // 'decimal_amount': 8,
263
+ // 'decimal_irt': 0,
264
+ // 'color': 'f7931a',
265
+ // 'high_risk': false,
266
+ // 'show_high_risk': false,
267
+ // 'withdraw_commission': '0.003000000000000000',
268
+ // 'tags': [
269
+ // {
270
+ // 'id': 44,
271
+ // 'name': 'لایه ۱',
272
+ // 'name_en': 'layer-1',
273
+ // 'has_chart': true,
274
+ // },
275
+ // {
276
+ // 'id': 52,
277
+ // 'name': 'اثبات کار',
278
+ // 'name_en': 'pow',
279
+ // 'has_chart': true,
280
+ // },
281
+ // ],
282
+ // 'etf': false,
283
+ // 'for_binvest': false,
284
+ // 'for_loan': true,
285
+ // 'for_stake': false,
286
+ // 'recommend_for_deposit_weight': 1,
287
+ // },
288
+ // 'currency2': {
289
+ // 'id': 2,
290
+ // 'title': 'Toman',
291
+ // 'title_fa': 'تومان',
292
+ // 'code': 'IRT',
293
+ // 'tradable': true,
294
+ // 'for_test': false,
295
+ // 'image': 'https://cdn.bitpin.ir/media/market/currency/1684671406.svg',
296
+ // 'decimal': 0,
297
+ // 'decimal_amount': 0,
298
+ // 'decimal_irt': 1,
299
+ // 'color': '00fd22',
300
+ // 'high_risk': false,
301
+ // 'show_high_risk': false,
302
+ // 'withdraw_commission': '0.000200000000000000',
303
+ // 'tags': [ ],
304
+ // 'etf': false,
305
+ // 'for_binvest': false,
306
+ // 'for_loan': false,
307
+ // 'for_stake': false,
308
+ // 'recommend_for_deposit_weight': 0,
309
+ // },
310
+ // 'tradable': true,
311
+ // 'for_test': false,
312
+ // 'otc_sell_percent': '0.01000',
313
+ // 'otc_buy_percent': '0.01000',
314
+ // 'otc_max_buy_amount': '0.017000000000000000',
315
+ // 'otc_max_sell_amount': '0.017000000000000000',
316
+ // 'order_book_info': {
317
+ // 'created_at': null,
318
+ // 'price': '3894924262',
319
+ // 'change': 0.0179,
320
+ // 'min': '3777777800',
321
+ // 'max': '3925000000',
322
+ // 'time': '2024-05-19T13:45:00.000Z',
323
+ // 'mean': '3833950912',
324
+ // 'value': '6215833783',
325
+ // 'amount': '1.62286922',
326
+ // },
327
+ // 'internal_price_info': {
328
+ // 'created_at': 1716126301.298626,
329
+ // 'price': '3894924262',
330
+ // 'change': 1.8,
331
+ // 'min': '3777777800',
332
+ // 'max': '3925000000',
333
+ // 'time': null,
334
+ // 'mean': null,
335
+ // 'value': null,
336
+ // 'amount': null,
337
+ // },
338
+ // 'price_info': {
339
+ // 'created_at': 1716126370.677,
340
+ // 'price': '3906940950',
341
+ // 'change': 2.04,
342
+ // 'min': '3785113135',
343
+ // 'max': '3921003333',
344
+ // 'time': null,
345
+ // 'mean': null,
346
+ // 'value': null,
347
+ // 'amount': null,
348
+ // },
349
+ // 'price': '3906940950',
350
+ // 'title': 'Bitcoin/Toman',
351
+ // 'code': 'BTC_IRT',
352
+ // 'title_fa': 'بیت کوین/تومان',
353
+ // 'trading_view_source': 'BINANCE',
354
+ // 'trading_view_symbol': 'BTCUSDT',
355
+ // 'otc_market': false,
356
+ // 'text': '',
357
+ // 'volume_24h': '2318294704054686.000000000000000000',
358
+ // 'market_cap': '43370130583253964.000000000000000000',
359
+ // 'circulating_supply': '19588837.000000000000000000',
360
+ // 'all_time_high': '3577014315.000000000000000000',
361
+ // 'popularity_weight': 0,
362
+ // 'freshness_weight': 0,
363
+ // }
364
+ const marketType = 'spot';
365
+ const priceInfo = this.safeValue(ticker, 'order_book_info');
366
+ const marketId = this.safeString(ticker, 'id');
367
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
368
+ const high = this.safeFloat(priceInfo, 'max', 0);
369
+ const low = this.safeFloat(priceInfo, 'min', 0);
370
+ const last = this.safeFloat(priceInfo, 'price', 0);
371
+ const change = this.safeFloat(priceInfo, 'change', 0);
372
+ const baseVolume = this.safeFloat(priceInfo, 'amount', 0);
373
+ const quoteVolume = this.safeFloat(priceInfo, 'value', 0);
374
+ return this.safeTicker({
375
+ 'symbol': symbol,
376
+ 'timestamp': undefined,
377
+ 'datetime': undefined,
378
+ 'high': high,
379
+ 'low': low,
380
+ 'bid': undefined,
381
+ 'bidVolume': undefined,
382
+ 'ask': undefined,
383
+ 'askVolume': undefined,
384
+ 'vwap': undefined,
385
+ 'open': undefined,
386
+ 'close': last,
387
+ 'last': last,
388
+ 'previousClose': undefined,
389
+ 'change': change,
390
+ 'percentage': undefined,
391
+ 'average': undefined,
392
+ 'baseVolume': baseVolume,
393
+ 'quoteVolume': quoteVolume,
394
+ 'info': ticker,
395
+ }, market);
396
+ }
397
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
398
+ /**
399
+ * @method
400
+ * @name bitpin#fetchOHLCV
401
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
402
+ * @see https://api-docs.bitpin.ir/#be8d9c51a2
403
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
404
+ * @param {string} timeframe the length of time each candle represents
405
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
406
+ * @param {int} [limit] the maximum amount of candles to fetch
407
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
408
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
409
+ */
410
+ await this.loadMarkets();
411
+ const market = this.market(symbol);
412
+ const endTime = Date.now();
413
+ const request = {
414
+ 'symbol': market['symbol'].replace('/', '_'),
415
+ 'from': (endTime / 1000) - (24 * 60 * 60),
416
+ 'to': endTime / 1000,
417
+ 'res': this.safeString(this.timeframes, timeframe, timeframe),
418
+ };
419
+ if (since !== undefined) {
420
+ request['from'] = since / 1000;
421
+ }
422
+ request['from'] = this.safeInteger(request, 'from');
423
+ request['to'] = this.safeInteger(request, 'to');
424
+ if (timeframe !== undefined) {
425
+ request['res'] = this.safeString(this.timeframes, timeframe, timeframe);
426
+ }
427
+ const response = await this.publicGetV1MktTvGetBars(request);
428
+ const ohlcvs = [];
429
+ for (let i = 0; i < response.length; i++) {
430
+ ohlcvs.push([
431
+ this.safeValue(response[i], 'ts'),
432
+ this.safeFloat(response[i], 'open'),
433
+ this.safeFloat(response[i], 'high'),
434
+ this.safeFloat(response[i], 'low'),
435
+ this.safeFloat(response[i], 'close'),
436
+ this.safeFloat(response[i], 'volume'),
437
+ ]);
438
+ }
439
+ return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
440
+ }
441
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
442
+ /**
443
+ * @method
444
+ * @name bitpin#fetchOrderBooks
445
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
446
+ * @see https://api-docs.bitpin.ir/#be8d9c51a2
447
+ * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
448
+ * @param {int} [limit] max number of entries per orderbook to return, default is undefined
449
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
450
+ * @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
451
+ */
452
+ await this.loadMarkets();
453
+ const market = this.market(symbol);
454
+ const request = {
455
+ 'symbol': market['id'],
456
+ 'limit': limit || 100,
457
+ };
458
+ const orderBookRequest = await this.publicGetV4MthOrderbook(this.extend(request, params));
459
+ const bids = this.safeList(orderBookRequest, 'bids', []);
460
+ const asks = this.safeList(orderBookRequest, 'asks', []);
461
+ const bidlist = [];
462
+ const askslist = [];
463
+ for (let i = 0; i < bids.length; i++) {
464
+ const bid = bids[i];
465
+ bidlist.push({ 'price': this.safeFloat(bid, 0), 'amount': this.safeFloat(bid, 1) });
466
+ }
467
+ for (let j = 0; j < asks.length; j++) {
468
+ const ask = asks[j];
469
+ askslist.push({ 'price': this.safeFloat(ask, 0), 'amount': this.safeFloat(ask, 1) });
470
+ }
471
+ const orderBook = { 'bid': bidlist, 'ask': askslist };
472
+ const timestamp = Date.now();
473
+ return this.parseOrderBook(orderBook, symbol, timestamp, 'bid', 'ask', 'price', 'amount');
474
+ }
475
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
476
+ const query = this.omit(params, this.extractParams(path));
477
+ let url = this.urls['api'][api] + '/' + path;
478
+ if (path === 'v1/mkt/tv/get_bars/') {
479
+ url = this.urls['api']['OHLCV'] + '/' + path + '?' + this.urlencode(query);
480
+ }
481
+ if (path === 'v4/mth/orderbook/') {
482
+ url = url + params['symbol'] + '/?limit=' + params['limit'];
483
+ }
484
+ headers = { 'Content-Type': 'application/json' };
485
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
486
+ }
487
+ }