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