ccxt-ir 4.9.13 → 4.9.15

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 (99) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +232 -229
  4. package/dist/cjs/package.json +1 -1
  5. package/dist/cjs/src/abantether.js +344 -344
  6. package/dist/cjs/src/abstract/bitbarg.js +1 -1
  7. package/dist/cjs/src/abstract/bitunix.js +1 -1
  8. package/dist/cjs/src/abstract/bydfi.js +1 -1
  9. package/dist/cjs/src/abstract/cafearz.js +1 -1
  10. package/dist/cjs/src/abstract/hamtapay.js +1 -1
  11. package/dist/cjs/src/abstract/kifpoolme.js +1 -1
  12. package/dist/cjs/src/abstract/mazdax.js +1 -1
  13. package/dist/cjs/src/abstract/pingi.js +1 -1
  14. package/dist/cjs/src/abstract/pooleno.js +1 -1
  15. package/dist/cjs/src/abstract/tehran_exchange.js +11 -0
  16. package/dist/cjs/src/afratether.js +347 -347
  17. package/dist/cjs/src/arzplus.js +572 -572
  18. package/dist/cjs/src/bitbarg.js +303 -303
  19. package/dist/cjs/src/bitunix.js +317 -317
  20. package/dist/cjs/src/bydfi.js +425 -425
  21. package/dist/cjs/src/cafearz.js +337 -337
  22. package/dist/cjs/src/hamtapay.js +291 -291
  23. package/dist/cjs/src/kcex.js +326 -326
  24. package/dist/cjs/src/kifpoolme.js +401 -401
  25. package/dist/cjs/src/mazdax.js +525 -526
  26. package/dist/cjs/src/pingi.js +437 -438
  27. package/dist/cjs/src/pooleno.js +338 -338
  28. package/dist/cjs/src/tehran_exchange.js +334 -0
  29. package/dist/cjs/src/tetherland.js +358 -358
  30. package/dist/cjs/src/twox.js +362 -362
  31. package/dist/cjs/src/xt.js +5171 -5171
  32. package/js/ccxt.d.ts +676 -673
  33. package/js/ccxt.js +493 -491
  34. package/js/src/abantether.js +347 -347
  35. package/js/src/abstract/abantether.d.ts +8 -8
  36. package/js/src/abstract/arzplus.d.ts +11 -11
  37. package/js/src/abstract/bitbarg.d.ts +8 -8
  38. package/js/src/abstract/bitbarg.js +5 -5
  39. package/js/src/abstract/bitunix.d.ts +9 -9
  40. package/js/src/abstract/bitunix.js +5 -5
  41. package/js/src/abstract/bydfi.d.ts +11 -11
  42. package/js/src/abstract/bydfi.js +5 -5
  43. package/js/src/abstract/cafearz.d.ts +8 -8
  44. package/js/src/abstract/cafearz.js +5 -5
  45. package/js/src/abstract/hamtapay.d.ts +9 -9
  46. package/js/src/abstract/hamtapay.js +5 -5
  47. package/js/src/abstract/kcex.d.ts +10 -10
  48. package/js/src/abstract/kifpoolme.d.ts +9 -9
  49. package/js/src/abstract/kifpoolme.js +5 -5
  50. package/js/src/abstract/mazdax.d.ts +11 -11
  51. package/js/src/abstract/mazdax.js +5 -5
  52. package/js/src/abstract/pingi.d.ts +9 -9
  53. package/js/src/abstract/pingi.js +5 -5
  54. package/js/src/abstract/pooleno.d.ts +8 -8
  55. package/js/src/abstract/pooleno.js +5 -5
  56. package/js/src/abstract/tehran_exchange.d.ts +9 -0
  57. package/js/src/abstract/tehran_exchange.js +11 -0
  58. package/js/src/afratether.js +350 -350
  59. package/js/src/arzplus.d.ts +26 -26
  60. package/js/src/arzplus.js +575 -575
  61. package/js/src/base/Exchange.d.ts +926 -926
  62. package/js/src/base/types.d.ts +586 -586
  63. package/js/src/bitbarg.d.ts +21 -21
  64. package/js/src/bitbarg.js +306 -306
  65. package/js/src/bitunix.d.ts +21 -21
  66. package/js/src/bitunix.js +320 -320
  67. package/js/src/bydfi.d.ts +23 -23
  68. package/js/src/bydfi.js +428 -428
  69. package/js/src/cafearz.d.ts +21 -21
  70. package/js/src/cafearz.js +340 -340
  71. package/js/src/coinbaseexchange.d.ts +334 -334
  72. package/js/src/hamtapay.d.ts +21 -21
  73. package/js/src/hamtapay.js +294 -294
  74. package/js/src/kcex.d.ts +21 -21
  75. package/js/src/kcex.js +329 -329
  76. package/js/src/kifpoolme.d.ts +23 -23
  77. package/js/src/kifpoolme.js +404 -404
  78. package/js/src/mazdax.d.ts +23 -23
  79. package/js/src/mazdax.js +528 -529
  80. package/js/src/pingi.d.ts +22 -22
  81. package/js/src/pingi.js +440 -441
  82. package/js/src/pooleno.d.ts +21 -21
  83. package/js/src/pooleno.js +341 -341
  84. package/js/src/protobuf/mexc/compiled.d.cts +2 -2
  85. package/js/src/static_dependencies/fflake/browser.d.ts +222 -222
  86. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -51
  87. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -101
  88. package/js/src/static_dependencies/qs/formats.d.cts +8 -8
  89. package/js/src/static_dependencies/qs/index.d.cts +4 -4
  90. package/js/src/static_dependencies/qs/parse.d.cts +2 -2
  91. package/js/src/static_dependencies/qs/stringify.d.cts +2 -2
  92. package/js/src/static_dependencies/qs/utils.d.cts +9 -9
  93. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -5
  94. package/js/src/tehran_exchange.d.ts +21 -0
  95. package/js/src/tehran_exchange.js +333 -0
  96. package/js/src/tetherland.js +361 -361
  97. package/js/src/twox.js +365 -365
  98. package/js/src/xt.js +5178 -5178
  99. package/package.json +1 -1
@@ -5,431 +5,431 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var bydfi$1 = require('./abstract/bydfi.js');
6
6
 
7
7
  // ----------------------------------------------------------------------------
8
- // ---------------------------------------------------------------------------
9
- /**
10
- * @class bydfi
11
- * @augments Exchange
12
- * @description Set rateLimit to 1000 if fully verified
13
- */
14
- class bydfi extends bydfi$1["default"] {
15
- describe() {
16
- return this.deepExtend(super.describe(), {
17
- 'id': 'bydfi',
18
- 'name': 'Bydfi',
19
- 'countries': ['SC'],
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': true,
67
- 'fetchOpenInterestHistory': false,
68
- 'fetchOpenOrders': false,
69
- 'fetchOrder': false,
70
- 'fetchOrderBook': true,
71
- 'fetchOrders': false,
72
- 'fetchOrderTrades': 'emulated',
73
- 'fetchPositions': false,
74
- 'fetchPremiumIndexOHLCV': false,
75
- 'fetchTicker': true,
76
- 'fetchTickers': true,
77
- 'fetchTime': false,
78
- 'fetchTrades': false,
79
- 'fetchTradingFee': false,
80
- 'fetchTradingFees': false,
81
- 'fetchWithdrawals': false,
82
- 'setLeverage': false,
83
- 'setMarginMode': false,
84
- 'transfer': false,
85
- 'withdraw': false,
86
- },
87
- 'comment': 'This comment is optional',
88
- 'urls': {
89
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bydfi/64x64.png',
90
- 'api': {
91
- 'public': 'https://www.bydfi.com',
92
- 'quote': 'https://quote.bydfi.pro',
93
- },
94
- 'www': 'https://www.bydfi.com/',
95
- 'doc': [
96
- 'https://www.bydfi.com/',
97
- ],
98
- },
99
- 'timeframes': {
100
- '1m': '1',
101
- '5m': '5',
102
- '15m': '15',
103
- '30m': '30',
104
- '1h': '60',
105
- '4h': '240',
106
- '1d': 'D',
107
- '1w': 'W',
108
- '1M': 'M',
109
- },
110
- 'api': {
111
- 'public': {
112
- 'get': {
113
- 'api/spot/product/list': 1,
114
- 'api/tv/tradingView/history': 1,
115
- },
116
- },
117
- 'quote': {
118
- 'get': {
119
- 'tickers': 1,
120
- 'mkpai/depth-v2': 1,
121
- },
122
- },
123
- },
124
- 'fees': {
125
- 'trading': {
126
- 'tierBased': false,
127
- 'percentage': true,
128
- 'maker': this.parseNumber('0.001'),
129
- 'taker': this.parseNumber('0.001'),
130
- },
131
- },
132
- });
133
- }
134
- async fetchMarkets(params = {}) {
135
- /**
136
- * @method
137
- * @name bydfi#fetchMarkets
138
- * @description retrieves data on all markets for bydfi
139
- * @see https://www.bydfi.com/api/spot/product/list
140
- * @param {object} [params] extra parameters specific to the exchange API endpoint
141
- * @returns {object[]} an array of objects representing market data
142
- */
143
- const response = await this.publicGetApiSpotProductList(params);
144
- const data = this.safeList(response, 'data', []);
145
- const result = [];
146
- for (let i = 0; i < data.length; i++) {
147
- const market = this.parseMarket(data[i]);
148
- result.push(market);
149
- }
150
- return result;
151
- }
152
- parseMarket(market) {
153
- // {
154
- // "symbol": "BTC_USDT",
155
- // "alias": "BTC/USDT",
156
- // "baseCoin": "BTC",
157
- // "quoteCoin": "USDT",
158
- // "icon": "https://...",
159
- // "type": 1,
160
- // "tags": "hot",
161
- // "visible": true,
162
- // "anonymous": false,
163
- // "canBuy": true,
164
- // "canSell": true,
165
- // "canGrid": true,
166
- // "depth": "0.01,0.1,1",
167
- // "matchMode": 1,
168
- // "priceScale": 2,
169
- // "volumeScale": 6,
170
- // "amountScale": 2,
171
- // "makerRate": 0.001,
172
- // "takerRate": 0.001,
173
- // "feeCoin": "USDT",
174
- // "volumeMin": 0.000001,
175
- // "amountMin": 5
176
- // }
177
- const id = this.safeString(market, 'symbol');
178
- const baseId = this.safeString(market, 'baseCoin');
179
- const quoteId = this.safeString(market, 'quoteCoin');
180
- const base = this.safeCurrencyCode(baseId);
181
- const quote = this.safeCurrencyCode(quoteId);
182
- const visible = this.safeBool(market, 'visible', true);
183
- const canBuy = this.safeBool(market, 'canBuy', true);
184
- const canSell = this.safeBool(market, 'canSell', true);
185
- const active = visible && canBuy && canSell;
186
- return {
187
- 'id': id,
188
- 'symbol': base + '/' + quote,
189
- 'base': base,
190
- 'quote': quote,
191
- 'settle': undefined,
192
- 'baseId': baseId,
193
- 'quoteId': quoteId,
194
- 'settleId': undefined,
195
- 'type': 'spot',
196
- 'spot': true,
197
- 'margin': false,
198
- 'swap': false,
199
- 'future': false,
200
- 'option': false,
201
- 'active': active,
202
- 'contract': false,
203
- 'linear': undefined,
204
- 'inverse': undefined,
205
- 'contractSize': undefined,
206
- 'expiry': undefined,
207
- 'expiryDatetime': undefined,
208
- 'strike': undefined,
209
- 'optionType': undefined,
210
- 'precision': {
211
- 'amount': this.safeInteger(market, 'volumeScale'),
212
- 'price': this.safeInteger(market, 'priceScale'),
213
- },
214
- 'limits': {
215
- 'leverage': {
216
- 'min': undefined,
217
- 'max': undefined,
218
- },
219
- 'amount': {
220
- 'min': this.safeNumber(market, 'volumeMin'),
221
- 'max': undefined,
222
- },
223
- 'price': {
224
- 'min': undefined,
225
- 'max': undefined,
226
- },
227
- 'cost': {
228
- 'min': this.safeNumber(market, 'amountMin'),
229
- 'max': undefined,
230
- },
231
- },
232
- 'created': undefined,
233
- 'info': market,
234
- };
235
- }
236
- async fetchTickers(symbols = undefined, params = {}) {
237
- /**
238
- * @method
239
- * @name bydfi#fetchTickers
240
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
241
- * @see https://quote.bydfi.pro/tickers?preHour=24
242
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
243
- * @param {object} [params] extra parameters specific to the exchange API endpoint
244
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
245
- */
246
- await this.loadMarkets();
247
- if (symbols !== undefined) {
248
- symbols = this.marketSymbols(symbols);
249
- }
250
- const request = {
251
- 'preHour': 24,
252
- };
253
- const response = await this.quoteGetTickers(this.extend(request, params));
254
- const data = this.safeString(response, 'data', '');
255
- // Parse the CSV-like response (cast to string for safety)
256
- const tickers = String(data).split(';');
257
- const result = {};
258
- for (let i = 0; i < tickers.length; i++) {
259
- const tickerStr = tickers[i].trim();
260
- if (tickerStr.length === 0) {
261
- continue;
262
- }
263
- const ticker = this.parseTicker(tickerStr);
264
- const symbol = ticker['symbol'];
265
- result[symbol] = ticker;
266
- }
267
- return this.filterByArrayTickers(result, 'symbol', symbols);
268
- }
269
- async fetchTicker(symbol, params = {}) {
270
- /**
271
- * @method
272
- * @name bydfi#fetchTicker
273
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
274
- * @see https://quote.bydfi.pro/tickers?preHour=24
275
- * @param {string} symbol unified symbol of the market to fetch the ticker for
276
- * @param {object} [params] extra parameters specific to the exchange API endpoint
277
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
278
- */
279
- await this.loadMarkets();
280
- const tickers = await this.fetchTickers([symbol], params);
281
- return tickers[symbol];
282
- }
283
- parseTicker(ticker, market = undefined) {
284
- // BTC_USDT, -1, 112148.56000, 121452.59000, 0.00000, 0.00000, 0.00000, 0.0000, 122518.22000, 102403.50000, 2935.7203
285
- // Fields:
286
- // 0: symbol (BTC_USDT)
287
- // 1: trend indicator (-1 = down, 0 = neutral, 1 = up)
288
- // 2: last price
289
- // 3: 24h high
290
- // 4: 24h low
291
- // 5: price change
292
- // 6: base volume (BTC)
293
- // 7: price change percentage
294
- // 8: bid price
295
- // 9: ask price
296
- // 10: 24h quote volume (USDT)
297
- let parts = [];
298
- if (typeof ticker === 'string') {
299
- parts = ticker.split(',');
300
- }
301
- else {
302
- return this.safeTicker({}, market);
303
- }
304
- if (parts.length < 11) {
305
- return this.safeTicker({}, market);
306
- }
307
- const marketType = 'spot';
308
- const marketId = parts[0].trim();
309
- const symbol = this.safeSymbol(marketId, market, '_', marketType);
310
- const last = this.safeFloat(parts, 2);
311
- const high = this.safeFloat(parts, 3);
312
- const low = this.safeFloat(parts, 4);
313
- const change = this.safeFloat(parts, 5);
314
- const baseVolume = this.safeFloat(parts, 6);
315
- const percentage = this.safeFloat(parts, 7);
316
- const bid = this.safeFloat(parts, 8);
317
- const ask = this.safeFloat(parts, 9);
318
- const quoteVolume = this.safeFloat(parts, 10);
319
- return this.safeTicker({
320
- 'symbol': symbol,
321
- 'timestamp': undefined,
322
- 'datetime': undefined,
323
- 'high': high,
324
- 'low': low,
325
- 'bid': bid,
326
- 'bidVolume': undefined,
327
- 'ask': ask,
328
- 'askVolume': undefined,
329
- 'vwap': undefined,
330
- 'open': undefined,
331
- 'close': last,
332
- 'last': last,
333
- 'previousClose': undefined,
334
- 'change': change,
335
- 'percentage': percentage,
336
- 'average': undefined,
337
- 'baseVolume': baseVolume,
338
- 'quoteVolume': quoteVolume,
339
- 'info': ticker,
340
- }, market);
341
- }
342
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
343
- /**
344
- * @method
345
- * @name bydfi#fetchOHLCV
346
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
347
- * @see https://www.bydfi.com/api/tv/tradingView/history
348
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
349
- * @param {string} timeframe the length of time each candle represents
350
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
351
- * @param {int} [limit] the maximum amount of candles to fetch
352
- * @param {object} [params] extra parameters specific to the exchange API endpoint
353
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
354
- */
355
- await this.loadMarkets();
356
- const market = this.market(symbol);
357
- const endTime = Date.now();
358
- const request = {
359
- 'symbol': market['id'],
360
- 'from': (endTime / 1000) - (24 * 60 * 60),
361
- 'to': endTime / 1000,
362
- 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
363
- };
364
- if (since !== undefined) {
365
- request['from'] = since / 1000;
366
- }
367
- request['from'] = this.safeInteger(request, 'from');
368
- request['to'] = this.safeInteger(request, 'to');
369
- if (timeframe !== undefined) {
370
- request['resolution'] = this.safeString(this.timeframes, timeframe, timeframe);
371
- }
372
- const response = await this.publicGetApiTvTradingViewHistory(request);
373
- const openList = this.safeList(response, 'o', []);
374
- const highList = this.safeList(response, 'h', []);
375
- const lowList = this.safeList(response, 'l', []);
376
- const closeList = this.safeList(response, 'c', []);
377
- const volumeList = this.safeList(response, 'v', []);
378
- const timestampList = this.safeList(response, 't', []);
379
- const ohlcvs = [];
380
- for (let i = 0; i < openList.length; i++) {
381
- ohlcvs.push([
382
- this.safeInteger(timestampList, i),
383
- this.safeFloat(openList, i),
384
- this.safeFloat(highList, i),
385
- this.safeFloat(lowList, i),
386
- this.safeFloat(closeList, i),
387
- this.safeFloat(volumeList, i),
388
- ]);
389
- }
390
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
391
- }
392
- async fetchOrderBook(symbol, limit = 1, params = {}) {
393
- /**
394
- * @method
395
- * @name bydfi#fetchOrderBook
396
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
397
- * @see https://quote.bydfi.pro/mkpai/depth-v2
398
- * @param {string} symbol unified symbol of the market to fetch the order book for
399
- * @param {int} [limit] the maximum amount of order book entries to return
400
- * @param {object} [params] extra parameters specific to the exchange API endpoint
401
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
402
- */
403
- await this.loadMarkets();
404
- const market = this.market(symbol);
405
- const request = {
406
- 'businessType': market['id'],
407
- 'dType': 0,
408
- };
409
- if (limit !== undefined) {
410
- request['size'] = limit;
411
- }
412
- const response = await this.quoteGetMkpaiDepthV2(request);
413
- const data = this.safeDict(response, 'data', {});
414
- const timestamp = Date.now();
415
- const orderbook = this.parseOrderBook(data, symbol, timestamp, 'bids', 'asks', 'price', 'amount');
416
- return orderbook;
417
- }
418
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
419
- const query = this.omit(params, this.extractParams(path));
420
- let url = '';
421
- if (api === 'quote') {
422
- url = this.urls['api']['quote'] + '/' + path;
423
- }
424
- else {
425
- url = this.urls['api']['public'] + '/' + path;
426
- }
427
- if (Object.keys(query).length) {
428
- url += '?' + this.urlencode(query);
429
- }
430
- headers = { 'Content-Type': 'application/json' };
431
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
432
- }
8
+ // ---------------------------------------------------------------------------
9
+ /**
10
+ * @class bydfi
11
+ * @augments Exchange
12
+ * @description Set rateLimit to 1000 if fully verified
13
+ */
14
+ class bydfi extends bydfi$1["default"] {
15
+ describe() {
16
+ return this.deepExtend(super.describe(), {
17
+ 'id': 'bydfi',
18
+ 'name': 'Bydfi',
19
+ 'countries': ['SC'],
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': true,
67
+ 'fetchOpenInterestHistory': false,
68
+ 'fetchOpenOrders': false,
69
+ 'fetchOrder': false,
70
+ 'fetchOrderBook': true,
71
+ 'fetchOrders': false,
72
+ 'fetchOrderTrades': 'emulated',
73
+ 'fetchPositions': false,
74
+ 'fetchPremiumIndexOHLCV': false,
75
+ 'fetchTicker': true,
76
+ 'fetchTickers': true,
77
+ 'fetchTime': false,
78
+ 'fetchTrades': false,
79
+ 'fetchTradingFee': false,
80
+ 'fetchTradingFees': false,
81
+ 'fetchWithdrawals': false,
82
+ 'setLeverage': false,
83
+ 'setMarginMode': false,
84
+ 'transfer': false,
85
+ 'withdraw': false,
86
+ },
87
+ 'comment': 'This comment is optional',
88
+ 'urls': {
89
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bydfi/64x64.png',
90
+ 'api': {
91
+ 'public': 'https://www.bydfi.com',
92
+ 'quote': 'https://quote.bydfi.pro',
93
+ },
94
+ 'www': 'https://www.bydfi.com/',
95
+ 'doc': [
96
+ 'https://www.bydfi.com/',
97
+ ],
98
+ },
99
+ 'timeframes': {
100
+ '1m': '1',
101
+ '5m': '5',
102
+ '15m': '15',
103
+ '30m': '30',
104
+ '1h': '60',
105
+ '4h': '240',
106
+ '1d': 'D',
107
+ '1w': 'W',
108
+ '1M': 'M',
109
+ },
110
+ 'api': {
111
+ 'public': {
112
+ 'get': {
113
+ 'api/spot/product/list': 1,
114
+ 'api/tv/tradingView/history': 1,
115
+ },
116
+ },
117
+ 'quote': {
118
+ 'get': {
119
+ 'tickers': 1,
120
+ 'mkpai/depth-v2': 1,
121
+ },
122
+ },
123
+ },
124
+ 'fees': {
125
+ 'trading': {
126
+ 'tierBased': false,
127
+ 'percentage': true,
128
+ 'maker': this.parseNumber('0.001'),
129
+ 'taker': this.parseNumber('0.001'),
130
+ },
131
+ },
132
+ });
133
+ }
134
+ async fetchMarkets(params = {}) {
135
+ /**
136
+ * @method
137
+ * @name bydfi#fetchMarkets
138
+ * @description retrieves data on all markets for bydfi
139
+ * @see https://www.bydfi.com/api/spot/product/list
140
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
141
+ * @returns {object[]} an array of objects representing market data
142
+ */
143
+ const response = await this.publicGetApiSpotProductList(params);
144
+ const data = this.safeList(response, 'data', []);
145
+ const result = [];
146
+ for (let i = 0; i < data.length; i++) {
147
+ const market = this.parseMarket(data[i]);
148
+ result.push(market);
149
+ }
150
+ return result;
151
+ }
152
+ parseMarket(market) {
153
+ // {
154
+ // "symbol": "BTC_USDT",
155
+ // "alias": "BTC/USDT",
156
+ // "baseCoin": "BTC",
157
+ // "quoteCoin": "USDT",
158
+ // "icon": "https://...",
159
+ // "type": 1,
160
+ // "tags": "hot",
161
+ // "visible": true,
162
+ // "anonymous": false,
163
+ // "canBuy": true,
164
+ // "canSell": true,
165
+ // "canGrid": true,
166
+ // "depth": "0.01,0.1,1",
167
+ // "matchMode": 1,
168
+ // "priceScale": 2,
169
+ // "volumeScale": 6,
170
+ // "amountScale": 2,
171
+ // "makerRate": 0.001,
172
+ // "takerRate": 0.001,
173
+ // "feeCoin": "USDT",
174
+ // "volumeMin": 0.000001,
175
+ // "amountMin": 5
176
+ // }
177
+ const id = this.safeString(market, 'symbol');
178
+ const baseId = this.safeString(market, 'baseCoin');
179
+ const quoteId = this.safeString(market, 'quoteCoin');
180
+ const base = this.safeCurrencyCode(baseId);
181
+ const quote = this.safeCurrencyCode(quoteId);
182
+ const visible = this.safeBool(market, 'visible', true);
183
+ const canBuy = this.safeBool(market, 'canBuy', true);
184
+ const canSell = this.safeBool(market, 'canSell', true);
185
+ const active = visible && canBuy && canSell;
186
+ return {
187
+ 'id': id,
188
+ 'symbol': base + '/' + quote,
189
+ 'base': base,
190
+ 'quote': quote,
191
+ 'settle': undefined,
192
+ 'baseId': baseId,
193
+ 'quoteId': quoteId,
194
+ 'settleId': undefined,
195
+ 'type': 'spot',
196
+ 'spot': true,
197
+ 'margin': false,
198
+ 'swap': false,
199
+ 'future': false,
200
+ 'option': false,
201
+ 'active': active,
202
+ 'contract': false,
203
+ 'linear': undefined,
204
+ 'inverse': undefined,
205
+ 'contractSize': undefined,
206
+ 'expiry': undefined,
207
+ 'expiryDatetime': undefined,
208
+ 'strike': undefined,
209
+ 'optionType': undefined,
210
+ 'precision': {
211
+ 'amount': this.safeInteger(market, 'volumeScale'),
212
+ 'price': this.safeInteger(market, 'priceScale'),
213
+ },
214
+ 'limits': {
215
+ 'leverage': {
216
+ 'min': undefined,
217
+ 'max': undefined,
218
+ },
219
+ 'amount': {
220
+ 'min': this.safeNumber(market, 'volumeMin'),
221
+ 'max': undefined,
222
+ },
223
+ 'price': {
224
+ 'min': undefined,
225
+ 'max': undefined,
226
+ },
227
+ 'cost': {
228
+ 'min': this.safeNumber(market, 'amountMin'),
229
+ 'max': undefined,
230
+ },
231
+ },
232
+ 'created': undefined,
233
+ 'info': market,
234
+ };
235
+ }
236
+ async fetchTickers(symbols = undefined, params = {}) {
237
+ /**
238
+ * @method
239
+ * @name bydfi#fetchTickers
240
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
241
+ * @see https://quote.bydfi.pro/tickers?preHour=24
242
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
243
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
244
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
245
+ */
246
+ await this.loadMarkets();
247
+ if (symbols !== undefined) {
248
+ symbols = this.marketSymbols(symbols);
249
+ }
250
+ const request = {
251
+ 'preHour': 24,
252
+ };
253
+ const response = await this.quoteGetTickers(this.extend(request, params));
254
+ const data = this.safeString(response, 'data', '');
255
+ // Parse the CSV-like response (cast to string for safety)
256
+ const tickers = String(data).split(';');
257
+ const result = {};
258
+ for (let i = 0; i < tickers.length; i++) {
259
+ const tickerStr = tickers[i].trim();
260
+ if (tickerStr.length === 0) {
261
+ continue;
262
+ }
263
+ const ticker = this.parseTicker(tickerStr);
264
+ const symbol = ticker['symbol'];
265
+ result[symbol] = ticker;
266
+ }
267
+ return this.filterByArrayTickers(result, 'symbol', symbols);
268
+ }
269
+ async fetchTicker(symbol, params = {}) {
270
+ /**
271
+ * @method
272
+ * @name bydfi#fetchTicker
273
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
274
+ * @see https://quote.bydfi.pro/tickers?preHour=24
275
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
276
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
277
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
278
+ */
279
+ await this.loadMarkets();
280
+ const tickers = await this.fetchTickers([symbol], params);
281
+ return tickers[symbol];
282
+ }
283
+ parseTicker(ticker, market = undefined) {
284
+ // BTC_USDT, -1, 112148.56000, 121452.59000, 0.00000, 0.00000, 0.00000, 0.0000, 122518.22000, 102403.50000, 2935.7203
285
+ // Fields:
286
+ // 0: symbol (BTC_USDT)
287
+ // 1: trend indicator (-1 = down, 0 = neutral, 1 = up)
288
+ // 2: last price
289
+ // 3: 24h high
290
+ // 4: 24h low
291
+ // 5: price change
292
+ // 6: base volume (BTC)
293
+ // 7: price change percentage
294
+ // 8: bid price
295
+ // 9: ask price
296
+ // 10: 24h quote volume (USDT)
297
+ let parts = [];
298
+ if (typeof ticker === 'string') {
299
+ parts = ticker.split(',');
300
+ }
301
+ else {
302
+ return this.safeTicker({}, market);
303
+ }
304
+ if (parts.length < 11) {
305
+ return this.safeTicker({}, market);
306
+ }
307
+ const marketType = 'spot';
308
+ const marketId = parts[0].trim();
309
+ const symbol = this.safeSymbol(marketId, market, '_', marketType);
310
+ const last = this.safeFloat(parts, 2);
311
+ const high = this.safeFloat(parts, 3);
312
+ const low = this.safeFloat(parts, 4);
313
+ const change = this.safeFloat(parts, 5);
314
+ const baseVolume = this.safeFloat(parts, 6);
315
+ const percentage = this.safeFloat(parts, 7);
316
+ const bid = this.safeFloat(parts, 8);
317
+ const ask = this.safeFloat(parts, 9);
318
+ const quoteVolume = this.safeFloat(parts, 10);
319
+ return this.safeTicker({
320
+ 'symbol': symbol,
321
+ 'timestamp': undefined,
322
+ 'datetime': undefined,
323
+ 'high': high,
324
+ 'low': low,
325
+ 'bid': bid,
326
+ 'bidVolume': undefined,
327
+ 'ask': ask,
328
+ 'askVolume': undefined,
329
+ 'vwap': undefined,
330
+ 'open': undefined,
331
+ 'close': last,
332
+ 'last': last,
333
+ 'previousClose': undefined,
334
+ 'change': change,
335
+ 'percentage': percentage,
336
+ 'average': undefined,
337
+ 'baseVolume': baseVolume,
338
+ 'quoteVolume': quoteVolume,
339
+ 'info': ticker,
340
+ }, market);
341
+ }
342
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
343
+ /**
344
+ * @method
345
+ * @name bydfi#fetchOHLCV
346
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
347
+ * @see https://www.bydfi.com/api/tv/tradingView/history
348
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
349
+ * @param {string} timeframe the length of time each candle represents
350
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
351
+ * @param {int} [limit] the maximum amount of candles to fetch
352
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
353
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
354
+ */
355
+ await this.loadMarkets();
356
+ const market = this.market(symbol);
357
+ const endTime = Date.now();
358
+ const request = {
359
+ 'symbol': market['id'],
360
+ 'from': (endTime / 1000) - (24 * 60 * 60),
361
+ 'to': endTime / 1000,
362
+ 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
363
+ };
364
+ if (since !== undefined) {
365
+ request['from'] = since / 1000;
366
+ }
367
+ request['from'] = this.safeInteger(request, 'from');
368
+ request['to'] = this.safeInteger(request, 'to');
369
+ if (timeframe !== undefined) {
370
+ request['resolution'] = this.safeString(this.timeframes, timeframe, timeframe);
371
+ }
372
+ const response = await this.publicGetApiTvTradingViewHistory(request);
373
+ const openList = this.safeList(response, 'o', []);
374
+ const highList = this.safeList(response, 'h', []);
375
+ const lowList = this.safeList(response, 'l', []);
376
+ const closeList = this.safeList(response, 'c', []);
377
+ const volumeList = this.safeList(response, 'v', []);
378
+ const timestampList = this.safeList(response, 't', []);
379
+ const ohlcvs = [];
380
+ for (let i = 0; i < openList.length; i++) {
381
+ ohlcvs.push([
382
+ this.safeInteger(timestampList, i),
383
+ this.safeFloat(openList, i),
384
+ this.safeFloat(highList, i),
385
+ this.safeFloat(lowList, i),
386
+ this.safeFloat(closeList, i),
387
+ this.safeFloat(volumeList, i),
388
+ ]);
389
+ }
390
+ return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
391
+ }
392
+ async fetchOrderBook(symbol, limit = 1, params = {}) {
393
+ /**
394
+ * @method
395
+ * @name bydfi#fetchOrderBook
396
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
397
+ * @see https://quote.bydfi.pro/mkpai/depth-v2
398
+ * @param {string} symbol unified symbol of the market to fetch the order book for
399
+ * @param {int} [limit] the maximum amount of order book entries to return
400
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
401
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
402
+ */
403
+ await this.loadMarkets();
404
+ const market = this.market(symbol);
405
+ const request = {
406
+ 'businessType': market['id'],
407
+ 'dType': 0,
408
+ };
409
+ if (limit !== undefined) {
410
+ request['size'] = limit;
411
+ }
412
+ const response = await this.quoteGetMkpaiDepthV2(request);
413
+ const data = this.safeDict(response, 'data', {});
414
+ const timestamp = Date.now();
415
+ const orderbook = this.parseOrderBook(data, symbol, timestamp, 'bids', 'asks', 'price', 'amount');
416
+ return orderbook;
417
+ }
418
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
419
+ const query = this.omit(params, this.extractParams(path));
420
+ let url = '';
421
+ if (api === 'quote') {
422
+ url = this.urls['api']['quote'] + '/' + path;
423
+ }
424
+ else {
425
+ url = this.urls['api']['public'] + '/' + path;
426
+ }
427
+ if (Object.keys(query).length) {
428
+ url += '?' + this.urlencode(query);
429
+ }
430
+ headers = { 'Content-Type': 'application/json' };
431
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
432
+ }
433
433
  }
434
434
 
435
435
  exports["default"] = bydfi;