ccxt-ir 4.9.19 → 4.9.23

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 (111) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +4 -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/bitunix.js +1 -1
  7. package/dist/cjs/src/abstract/bydfi.js +1 -1
  8. package/dist/cjs/src/abstract/cafearz.js +1 -1
  9. package/dist/cjs/src/abstract/hamtapay.js +1 -1
  10. package/dist/cjs/src/abstract/iranexchange.js +11 -0
  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 +1 -1
  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 +294 -294
  23. package/dist/cjs/src/iranexchange.js +398 -0
  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/dist/cjs/src/xt.js +5171 -5171
  36. package/js/ccxt.d.ts +5 -2
  37. package/js/ccxt.js +4 -2
  38. package/js/src/abantether.js +347 -347
  39. package/js/src/abstract/abantether.d.ts +8 -8
  40. package/js/src/abstract/arzplus.d.ts +11 -11
  41. package/js/src/abstract/bitbarg.d.ts +8 -8
  42. package/js/src/abstract/bitbarg.js +5 -5
  43. package/js/src/abstract/bitunix.d.ts +9 -9
  44. package/js/src/abstract/bitunix.js +5 -5
  45. package/js/src/abstract/bydfi.d.ts +11 -11
  46. package/js/src/abstract/bydfi.js +5 -5
  47. package/js/src/abstract/cafearz.d.ts +8 -8
  48. package/js/src/abstract/cafearz.js +5 -5
  49. package/js/src/abstract/hamtapay.d.ts +9 -9
  50. package/js/src/abstract/hamtapay.js +5 -5
  51. package/js/src/abstract/iranexchange.d.ts +9 -0
  52. package/js/src/abstract/iranexchange.js +11 -0
  53. package/js/src/abstract/kcex.d.ts +10 -10
  54. package/js/src/abstract/kifpoolme.d.ts +9 -9
  55. package/js/src/abstract/kifpoolme.js +5 -5
  56. package/js/src/abstract/mazdax.d.ts +11 -11
  57. package/js/src/abstract/mazdax.js +5 -5
  58. package/js/src/abstract/pingi.d.ts +9 -9
  59. package/js/src/abstract/pingi.js +5 -5
  60. package/js/src/abstract/pooleno.d.ts +8 -8
  61. package/js/src/abstract/pooleno.js +5 -5
  62. package/js/src/abstract/tehran_exchange.d.ts +9 -9
  63. package/js/src/abstract/tehran_exchange.js +5 -5
  64. package/js/src/abstract/toobit.d.ts +10 -10
  65. package/js/src/afratether.js +350 -350
  66. package/js/src/arzplus.d.ts +26 -26
  67. package/js/src/arzplus.js +575 -575
  68. package/js/src/base/Exchange.d.ts +2 -2
  69. package/js/src/base/types.d.ts +586 -586
  70. package/js/src/bitbarg.d.ts +21 -21
  71. package/js/src/bitbarg.js +306 -306
  72. package/js/src/bitunix.d.ts +21 -21
  73. package/js/src/bitunix.js +320 -320
  74. package/js/src/bydfi.d.ts +23 -23
  75. package/js/src/bydfi.js +428 -428
  76. package/js/src/cafearz.d.ts +21 -21
  77. package/js/src/cafearz.js +340 -340
  78. package/js/src/coinbaseexchange.d.ts +1 -1
  79. package/js/src/hamtapay.d.ts +21 -21
  80. package/js/src/hamtapay.js +297 -297
  81. package/js/src/iranexchange.d.ts +21 -0
  82. package/js/src/iranexchange.js +397 -0
  83. package/js/src/kcex.d.ts +21 -21
  84. package/js/src/kcex.js +329 -329
  85. package/js/src/kifpoolme.d.ts +23 -23
  86. package/js/src/kifpoolme.js +404 -404
  87. package/js/src/mazdax.d.ts +23 -23
  88. package/js/src/mazdax.js +528 -528
  89. package/js/src/ompfinex.js +504 -504
  90. package/js/src/pingi.d.ts +22 -22
  91. package/js/src/pingi.js +440 -440
  92. package/js/src/pooleno.d.ts +21 -21
  93. package/js/src/pooleno.js +341 -341
  94. package/js/src/protobuf/mexc/compiled.d.cts +0 -6
  95. package/js/src/sarmayex.js +370 -370
  96. package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
  97. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -51
  98. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -101
  99. package/js/src/static_dependencies/qs/formats.d.cts +0 -6
  100. package/js/src/static_dependencies/qs/index.d.cts +0 -6
  101. package/js/src/static_dependencies/qs/parse.d.cts +0 -6
  102. package/js/src/static_dependencies/qs/stringify.d.cts +0 -6
  103. package/js/src/static_dependencies/qs/utils.d.cts +0 -6
  104. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -5
  105. package/js/src/tehran_exchange.d.ts +21 -21
  106. package/js/src/tehran_exchange.js +327 -327
  107. package/js/src/tetherland.js +361 -361
  108. package/js/src/toobit.js +439 -439
  109. package/js/src/twox.js +365 -365
  110. package/js/src/xt.js +5178 -5178
  111. package/package.json +1 -1
@@ -5,442 +5,442 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var toobit$1 = require('./abstract/toobit.js');
6
6
 
7
7
  // ----------------------------------------------------------------------------
8
- // ---------------------------------------------------------------------------
9
- /**
10
- * @class toobit
11
- * @augments Exchange
12
- * @description Set rateLimit to 1000 if fully verified
13
- */
14
- class toobit extends toobit$1["default"] {
15
- describe() {
16
- return this.deepExtend(super.describe(), {
17
- 'id': 'toobit',
18
- 'name': 'Toobit',
19
- 'countries': ['KY'],
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': true,
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
- 'fetchLedger': false,
60
- 'fetchLedgerEntry': false,
61
- 'fetchLeverageTiers': false,
62
- 'fetchMarkets': true,
63
- 'fetchMarkOHLCV': false,
64
- 'fetchMyTrades': false,
65
- 'fetchOHLCV': true,
66
- 'fetchOpenInterestHistory': false,
67
- 'fetchOpenOrders': false,
68
- 'fetchOrder': false,
69
- 'fetchOrderBook': true,
70
- 'fetchOrders': false,
71
- 'fetchOrderTrades': 'emulated',
72
- 'fetchPositions': false,
73
- 'fetchPremiumIndexOHLCV': false,
74
- 'fetchTicker': true,
75
- 'fetchTickers': true,
76
- 'fetchTime': false,
77
- 'fetchTrades': false,
78
- 'fetchTradingFee': false,
79
- 'fetchTradingFees': false,
80
- 'fetchWithdrawals': false,
81
- 'setLeverage': false,
82
- 'setMarginMode': false,
83
- 'transfer': false,
84
- 'withdraw': false,
85
- },
86
- 'comment': 'This comment is optional',
87
- 'urls': {
88
- 'logo': 'https://toobit-docs.github.io/apidocs/spot/v1/en/images/logo.svg',
89
- 'api': {
90
- 'public': 'https://api.toobit.com',
91
- },
92
- 'www': 'https://www.toobit.com/',
93
- 'doc': [
94
- 'https://toobit-docs.github.io/apidocs/spot/v1/en/#change-log',
95
- ],
96
- },
97
- 'timeframes': {
98
- '1m': '1m',
99
- '3m': '3m',
100
- '5m': '5m',
101
- '15m': '15m',
102
- '30m': '30m',
103
- '1h': '1h',
104
- '2h': '2h',
105
- '4h': '4h',
106
- '6h': '6h',
107
- '12h': '12h',
108
- '1d': '1d',
109
- '1w': '1w',
110
- '1M': '1M',
111
- },
112
- 'api': {
113
- 'public': {
114
- 'get': {
115
- 'quote/v1/ticker/24hr': 1,
116
- 'quote/v1/klines': 1,
117
- '/api/v1/exchangeInfo': 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 toobit#fetchMarkets
135
- * @description retrieves data on all markets for toobit
136
- * @see https://api.toobit.com/api/v1/exchangeInfo
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.publicGetApiV1ExchangeInfo();
141
- const symbols = this.safeValue(response, 'symbols', []);
142
- const result = [];
143
- for (let i = 0; i < symbols.length; i++) {
144
- const symbolData = symbols[i];
145
- const status = this.safeValue(symbolData, 'status');
146
- const symbol = this.safeValue(symbolData, 'symbol');
147
- if (status !== 'TRADING' || symbol === 'TESTA1S3TESTX8Z9') {
148
- continue;
149
- }
150
- const market = this.parseMarket(symbolData);
151
- result.push(market);
152
- }
153
- return result;
154
- }
155
- parseMarket(market) {
156
- // {
157
- // "filters": [
158
- // {
159
- // "minPrice": "0.01",
160
- // "maxPrice": "10000000.00000000",
161
- // "tickSize": "0.01",
162
- // "filterType": "PRICE_FILTER"
163
- // },
164
- // {
165
- // "minQty": "0.0001",
166
- // "maxQty": "4000",
167
- // "stepSize": "0.0001",
168
- // "filterType": "LOT_SIZE"
169
- // },
170
- // {
171
- // "minNotional": "5",
172
- // "filterType": "MIN_NOTIONAL"
173
- // }
174
- // ],
175
- // "exchangeId": "301",
176
- // "symbol": "ETHUSDT",
177
- // "symbolName": "ETHUSDT",
178
- // "status": "TRADING",
179
- // "baseAsset": "ETH",
180
- // "baseAssetName": "ETH",
181
- // "baseAssetPrecision": "0.0001",
182
- // "quoteAsset": "USDT",
183
- // "quoteAssetName": "USDT",
184
- // "quotePrecision": "0.01",
185
- // "icebergAllowed": false,
186
- // "isAggregate": false,
187
- // "allowMargin": true
188
- // }
189
- const symbol = this.safeValue(market, 'symbol');
190
- const baseAsset = this.safeValue(market, 'baseAsset');
191
- const quoteAsset = this.safeValue(market, 'quoteAsset');
192
- const baseAssetPrecision = this.safeValue(market, 'baseAssetPrecision');
193
- const quotePrecision = this.safeValue(market, 'quotePrecision');
194
- const allowMargin = this.safeValue(market, 'allowMargin', false);
195
- const filters = this.safeValue(market, 'filters', []);
196
- // Parse filters to extract limits and precision
197
- let minPrice = undefined;
198
- let maxPrice = undefined;
199
- let tickSize = undefined;
200
- let minQty = undefined;
201
- let maxQty = undefined;
202
- let stepSize = undefined;
203
- let minNotional = undefined;
204
- let minAmount = undefined;
205
- let maxAmount = undefined;
206
- for (let i = 0; i < filters.length; i++) {
207
- const filter = filters[i];
208
- const filterType = this.safeValue(filter, 'filterType');
209
- if (filterType === 'PRICE_FILTER') {
210
- minPrice = this.safeNumber(filter, 'minPrice');
211
- maxPrice = this.safeNumber(filter, 'maxPrice');
212
- tickSize = this.safeString(filter, 'tickSize');
213
- }
214
- else if (filterType === 'LOT_SIZE') {
215
- minQty = this.safeNumber(filter, 'minQty');
216
- maxQty = this.safeNumber(filter, 'maxQty');
217
- stepSize = this.safeString(filter, 'stepSize');
218
- }
219
- else if (filterType === 'MIN_NOTIONAL') {
220
- minNotional = this.safeNumber(filter, 'minNotional');
221
- }
222
- else if (filterType === 'TRADE_AMOUNT') {
223
- minAmount = this.safeNumber(filter, 'minAmount');
224
- maxAmount = this.safeNumber(filter, 'maxAmount');
225
- }
226
- }
227
- const id = symbol;
228
- const base = this.safeCurrencyCode(baseAsset);
229
- const quote = this.safeCurrencyCode(quoteAsset);
230
- const baseId = baseAsset.toLowerCase();
231
- const quoteId = quoteAsset.toLowerCase();
232
- // Calculate precision from step sizes and precision strings
233
- const amountPrecision = stepSize ? this.precisionFromString(stepSize.toString()) : this.precisionFromString(baseAssetPrecision);
234
- const pricePrecision = tickSize ? this.precisionFromString(tickSize.toString()) : this.precisionFromString(quotePrecision);
235
- return {
236
- 'id': id,
237
- 'symbol': base + '/' + quote,
238
- 'base': base,
239
- 'quote': quote,
240
- 'settle': undefined,
241
- 'baseId': baseId,
242
- 'quoteId': quoteId,
243
- 'settleId': undefined,
244
- 'type': 'spot',
245
- 'spot': true,
246
- 'margin': allowMargin,
247
- 'swap': false,
248
- 'future': false,
249
- 'option': false,
250
- 'active': true,
251
- 'contract': false,
252
- 'linear': undefined,
253
- 'inverse': undefined,
254
- 'contractSize': undefined,
255
- 'expiry': undefined,
256
- 'expiryDatetime': undefined,
257
- 'strike': undefined,
258
- 'optionType': undefined,
259
- 'precision': {
260
- 'amount': amountPrecision,
261
- 'price': pricePrecision,
262
- },
263
- 'limits': {
264
- 'leverage': {
265
- 'min': undefined,
266
- 'max': undefined,
267
- },
268
- 'amount': {
269
- 'min': minQty,
270
- 'max': maxQty,
271
- },
272
- 'price': {
273
- 'min': minPrice,
274
- 'max': maxPrice,
275
- },
276
- 'cost': {
277
- 'min': minNotional || minAmount,
278
- 'max': maxAmount,
279
- },
280
- },
281
- 'created': undefined,
282
- 'info': market,
283
- };
284
- }
285
- async fetchTickers(symbols = undefined, params = {}) {
286
- /**
287
- * @method
288
- * @name toobit#fetchTickers
289
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
290
- * @see https://toobit-docs.github.io/apidocs/spot/v1/en/#tickers
291
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
292
- * @param {object} [params] extra parameters specific to the exchange API endpoint
293
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
294
- */
295
- await this.loadMarkets();
296
- if (symbols !== undefined) {
297
- symbols = this.marketSymbols(symbols);
298
- }
299
- const response = await this.publicGetQuoteV1Ticker24hr();
300
- const result = {};
301
- for (let i = 0; i < response.length; i++) {
302
- const volume = this.safeFloat(response[i], 'v');
303
- if (volume === 0) {
304
- continue;
305
- }
306
- const ticker = this.parseTicker(response[i]);
307
- const symbol = ticker['symbol'];
308
- result[symbol] = ticker;
309
- }
310
- return this.filterByArrayTickers(result, 'symbol', symbols);
311
- }
312
- async fetchTicker(symbol, params = {}) {
313
- /**
314
- * @method
315
- * @name toobit#fetchTicker
316
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
317
- * @see https://toobit-docs.github.io/apidocs/spot/v1/en/#ticker
318
- * @param {string} symbol unified symbol of the market to fetch the ticker for
319
- * @param {object} [params] extra parameters specific to the exchange API endpoint
320
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
321
- */
322
- await this.loadMarkets();
323
- const market = this.market(symbol);
324
- const request = {
325
- 'symbol': market['id'],
326
- };
327
- const response = await this.publicGetQuoteV1Ticker24hr(request);
328
- const ticker = this.parseTicker(response[0]);
329
- return ticker;
330
- }
331
- parseTicker(ticker, market = undefined) {
332
- // {
333
- // t: 1757164008834,
334
- // s: "BTCUSDT",
335
- // c: "110895.06",
336
- // h: "113310.01",
337
- // l: "110219.01",
338
- // o: "112951.99",
339
- // v: "3893.406649",
340
- // qv: "433374169.27969515",
341
- // pc: "-2056.93",
342
- // pcp: "-0.0182"
343
- // }
344
- const marketType = 'spot';
345
- let symbol = this.safeValue(ticker, 's');
346
- const marketId = symbol;
347
- symbol = this.safeSymbol(marketId, market, undefined, marketType);
348
- const high = this.safeFloat(ticker, 'h');
349
- const low = this.safeFloat(ticker, 'l');
350
- const open = this.safeFloat(ticker, 'o');
351
- const close = this.safeFloat(ticker, 'c');
352
- const last = this.safeFloat(ticker, 'c');
353
- const change = this.safeFloat(ticker, 'pcp');
354
- const priceChange = this.safeFloat(ticker, 'pc');
355
- const baseVolume = this.safeFloat(ticker, 'v');
356
- const quoteVolume = this.safeFloat(ticker, 'qv');
357
- const datetime = this.safeString(ticker, 't');
358
- const bid = this.safeFloat(ticker, 'b', 0);
359
- const ask = this.safeFloat(ticker, 'a', 0);
360
- return this.safeTicker({
361
- 'symbol': symbol,
362
- 'timestamp': datetime,
363
- 'datetime': this.parse8601(datetime),
364
- 'high': high,
365
- 'low': low,
366
- 'bid': bid,
367
- 'bidVolume': undefined,
368
- 'ask': ask,
369
- 'askVolume': undefined,
370
- 'vwap': undefined,
371
- 'open': open,
372
- 'close': close,
373
- 'last': last,
374
- 'previousClose': undefined,
375
- 'change': priceChange,
376
- 'percentage': change,
377
- 'average': undefined,
378
- 'baseVolume': baseVolume,
379
- 'quoteVolume': quoteVolume,
380
- 'info': ticker,
381
- }, market);
382
- }
383
- async fetchOHLCV(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
384
- /**
385
- * @method
386
- * @name toobit#fetchOHLCV
387
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
388
- * @see https://toobit-docs.github.io/apidocs/spot/v1/en/#chart
389
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
390
- * @param {string} timeframe the length of time each candle represents
391
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
392
- * @param {int} [limit] the maximum amount of candles to fetch
393
- * @param {object} [params] extra parameters specific to the exchange API endpoint
394
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
395
- */
396
- await this.loadMarkets();
397
- const market = this.market(symbol);
398
- const endTime = Date.now();
399
- const request = {
400
- 'symbol': market['id'],
401
- 'from': (endTime - (24 * 60 * 60 * 1000)),
402
- 'to': endTime,
403
- 'interval': this.safeString(this.timeframes, timeframe, timeframe),
404
- };
405
- if (since !== undefined) {
406
- request['from'] = since;
407
- }
408
- if (timeframe !== undefined) {
409
- request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
410
- }
411
- const response = await this.publicGetQuoteV1Klines(request);
412
- const ohlcvs = [];
413
- for (let i = 0; i < response.length; i++) {
414
- const candle = response[i];
415
- const ts = this.safeTimestamp(candle, 0);
416
- const open = this.safeFloat(candle, 1);
417
- const high = this.safeFloat(candle, 2);
418
- const low = this.safeFloat(candle, 3);
419
- const close = this.safeFloat(candle, 4);
420
- const volume = this.safeFloat(candle, 5);
421
- ohlcvs.push([
422
- ts,
423
- open,
424
- high,
425
- low,
426
- close,
427
- volume,
428
- ]);
429
- }
430
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
431
- }
432
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
433
- const query = this.omit(params, this.extractParams(path));
434
- let url = this.urls['api']['public'] + '/' + path;
435
- if (path === 'quote/v1/ticker/24hr') {
436
- url = url + '?' + this.urlencode(query);
437
- }
438
- if (path === 'quote/v1/klines') {
439
- url = url + '?' + this.urlencode(query);
440
- }
441
- headers = { 'Content-Type': 'application/json' };
442
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
443
- }
8
+ // ---------------------------------------------------------------------------
9
+ /**
10
+ * @class toobit
11
+ * @augments Exchange
12
+ * @description Set rateLimit to 1000 if fully verified
13
+ */
14
+ class toobit extends toobit$1["default"] {
15
+ describe() {
16
+ return this.deepExtend(super.describe(), {
17
+ 'id': 'toobit',
18
+ 'name': 'Toobit',
19
+ 'countries': ['KY'],
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': true,
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
+ 'fetchLedger': false,
60
+ 'fetchLedgerEntry': false,
61
+ 'fetchLeverageTiers': false,
62
+ 'fetchMarkets': true,
63
+ 'fetchMarkOHLCV': false,
64
+ 'fetchMyTrades': false,
65
+ 'fetchOHLCV': true,
66
+ 'fetchOpenInterestHistory': false,
67
+ 'fetchOpenOrders': false,
68
+ 'fetchOrder': false,
69
+ 'fetchOrderBook': true,
70
+ 'fetchOrders': false,
71
+ 'fetchOrderTrades': 'emulated',
72
+ 'fetchPositions': false,
73
+ 'fetchPremiumIndexOHLCV': false,
74
+ 'fetchTicker': true,
75
+ 'fetchTickers': true,
76
+ 'fetchTime': false,
77
+ 'fetchTrades': false,
78
+ 'fetchTradingFee': false,
79
+ 'fetchTradingFees': false,
80
+ 'fetchWithdrawals': false,
81
+ 'setLeverage': false,
82
+ 'setMarginMode': false,
83
+ 'transfer': false,
84
+ 'withdraw': false,
85
+ },
86
+ 'comment': 'This comment is optional',
87
+ 'urls': {
88
+ 'logo': 'https://toobit-docs.github.io/apidocs/spot/v1/en/images/logo.svg',
89
+ 'api': {
90
+ 'public': 'https://api.toobit.com',
91
+ },
92
+ 'www': 'https://www.toobit.com/',
93
+ 'doc': [
94
+ 'https://toobit-docs.github.io/apidocs/spot/v1/en/#change-log',
95
+ ],
96
+ },
97
+ 'timeframes': {
98
+ '1m': '1m',
99
+ '3m': '3m',
100
+ '5m': '5m',
101
+ '15m': '15m',
102
+ '30m': '30m',
103
+ '1h': '1h',
104
+ '2h': '2h',
105
+ '4h': '4h',
106
+ '6h': '6h',
107
+ '12h': '12h',
108
+ '1d': '1d',
109
+ '1w': '1w',
110
+ '1M': '1M',
111
+ },
112
+ 'api': {
113
+ 'public': {
114
+ 'get': {
115
+ 'quote/v1/ticker/24hr': 1,
116
+ 'quote/v1/klines': 1,
117
+ '/api/v1/exchangeInfo': 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 toobit#fetchMarkets
135
+ * @description retrieves data on all markets for toobit
136
+ * @see https://api.toobit.com/api/v1/exchangeInfo
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.publicGetApiV1ExchangeInfo();
141
+ const symbols = this.safeValue(response, 'symbols', []);
142
+ const result = [];
143
+ for (let i = 0; i < symbols.length; i++) {
144
+ const symbolData = symbols[i];
145
+ const status = this.safeValue(symbolData, 'status');
146
+ const symbol = this.safeValue(symbolData, 'symbol');
147
+ if (status !== 'TRADING' || symbol === 'TESTA1S3TESTX8Z9') {
148
+ continue;
149
+ }
150
+ const market = this.parseMarket(symbolData);
151
+ result.push(market);
152
+ }
153
+ return result;
154
+ }
155
+ parseMarket(market) {
156
+ // {
157
+ // "filters": [
158
+ // {
159
+ // "minPrice": "0.01",
160
+ // "maxPrice": "10000000.00000000",
161
+ // "tickSize": "0.01",
162
+ // "filterType": "PRICE_FILTER"
163
+ // },
164
+ // {
165
+ // "minQty": "0.0001",
166
+ // "maxQty": "4000",
167
+ // "stepSize": "0.0001",
168
+ // "filterType": "LOT_SIZE"
169
+ // },
170
+ // {
171
+ // "minNotional": "5",
172
+ // "filterType": "MIN_NOTIONAL"
173
+ // }
174
+ // ],
175
+ // "exchangeId": "301",
176
+ // "symbol": "ETHUSDT",
177
+ // "symbolName": "ETHUSDT",
178
+ // "status": "TRADING",
179
+ // "baseAsset": "ETH",
180
+ // "baseAssetName": "ETH",
181
+ // "baseAssetPrecision": "0.0001",
182
+ // "quoteAsset": "USDT",
183
+ // "quoteAssetName": "USDT",
184
+ // "quotePrecision": "0.01",
185
+ // "icebergAllowed": false,
186
+ // "isAggregate": false,
187
+ // "allowMargin": true
188
+ // }
189
+ const symbol = this.safeValue(market, 'symbol');
190
+ const baseAsset = this.safeValue(market, 'baseAsset');
191
+ const quoteAsset = this.safeValue(market, 'quoteAsset');
192
+ const baseAssetPrecision = this.safeValue(market, 'baseAssetPrecision');
193
+ const quotePrecision = this.safeValue(market, 'quotePrecision');
194
+ const allowMargin = this.safeValue(market, 'allowMargin', false);
195
+ const filters = this.safeValue(market, 'filters', []);
196
+ // Parse filters to extract limits and precision
197
+ let minPrice = undefined;
198
+ let maxPrice = undefined;
199
+ let tickSize = undefined;
200
+ let minQty = undefined;
201
+ let maxQty = undefined;
202
+ let stepSize = undefined;
203
+ let minNotional = undefined;
204
+ let minAmount = undefined;
205
+ let maxAmount = undefined;
206
+ for (let i = 0; i < filters.length; i++) {
207
+ const filter = filters[i];
208
+ const filterType = this.safeValue(filter, 'filterType');
209
+ if (filterType === 'PRICE_FILTER') {
210
+ minPrice = this.safeNumber(filter, 'minPrice');
211
+ maxPrice = this.safeNumber(filter, 'maxPrice');
212
+ tickSize = this.safeString(filter, 'tickSize');
213
+ }
214
+ else if (filterType === 'LOT_SIZE') {
215
+ minQty = this.safeNumber(filter, 'minQty');
216
+ maxQty = this.safeNumber(filter, 'maxQty');
217
+ stepSize = this.safeString(filter, 'stepSize');
218
+ }
219
+ else if (filterType === 'MIN_NOTIONAL') {
220
+ minNotional = this.safeNumber(filter, 'minNotional');
221
+ }
222
+ else if (filterType === 'TRADE_AMOUNT') {
223
+ minAmount = this.safeNumber(filter, 'minAmount');
224
+ maxAmount = this.safeNumber(filter, 'maxAmount');
225
+ }
226
+ }
227
+ const id = symbol;
228
+ const base = this.safeCurrencyCode(baseAsset);
229
+ const quote = this.safeCurrencyCode(quoteAsset);
230
+ const baseId = baseAsset.toLowerCase();
231
+ const quoteId = quoteAsset.toLowerCase();
232
+ // Calculate precision from step sizes and precision strings
233
+ const amountPrecision = stepSize ? this.precisionFromString(stepSize.toString()) : this.precisionFromString(baseAssetPrecision);
234
+ const pricePrecision = tickSize ? this.precisionFromString(tickSize.toString()) : this.precisionFromString(quotePrecision);
235
+ return {
236
+ 'id': id,
237
+ 'symbol': base + '/' + quote,
238
+ 'base': base,
239
+ 'quote': quote,
240
+ 'settle': undefined,
241
+ 'baseId': baseId,
242
+ 'quoteId': quoteId,
243
+ 'settleId': undefined,
244
+ 'type': 'spot',
245
+ 'spot': true,
246
+ 'margin': allowMargin,
247
+ 'swap': false,
248
+ 'future': false,
249
+ 'option': false,
250
+ 'active': true,
251
+ 'contract': false,
252
+ 'linear': undefined,
253
+ 'inverse': undefined,
254
+ 'contractSize': undefined,
255
+ 'expiry': undefined,
256
+ 'expiryDatetime': undefined,
257
+ 'strike': undefined,
258
+ 'optionType': undefined,
259
+ 'precision': {
260
+ 'amount': amountPrecision,
261
+ 'price': pricePrecision,
262
+ },
263
+ 'limits': {
264
+ 'leverage': {
265
+ 'min': undefined,
266
+ 'max': undefined,
267
+ },
268
+ 'amount': {
269
+ 'min': minQty,
270
+ 'max': maxQty,
271
+ },
272
+ 'price': {
273
+ 'min': minPrice,
274
+ 'max': maxPrice,
275
+ },
276
+ 'cost': {
277
+ 'min': minNotional || minAmount,
278
+ 'max': maxAmount,
279
+ },
280
+ },
281
+ 'created': undefined,
282
+ 'info': market,
283
+ };
284
+ }
285
+ async fetchTickers(symbols = undefined, params = {}) {
286
+ /**
287
+ * @method
288
+ * @name toobit#fetchTickers
289
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
290
+ * @see https://toobit-docs.github.io/apidocs/spot/v1/en/#tickers
291
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
292
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
293
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
294
+ */
295
+ await this.loadMarkets();
296
+ if (symbols !== undefined) {
297
+ symbols = this.marketSymbols(symbols);
298
+ }
299
+ const response = await this.publicGetQuoteV1Ticker24hr();
300
+ const result = {};
301
+ for (let i = 0; i < response.length; i++) {
302
+ const volume = this.safeFloat(response[i], 'v');
303
+ if (volume === 0) {
304
+ continue;
305
+ }
306
+ const ticker = this.parseTicker(response[i]);
307
+ const symbol = ticker['symbol'];
308
+ result[symbol] = ticker;
309
+ }
310
+ return this.filterByArrayTickers(result, 'symbol', symbols);
311
+ }
312
+ async fetchTicker(symbol, params = {}) {
313
+ /**
314
+ * @method
315
+ * @name toobit#fetchTicker
316
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
317
+ * @see https://toobit-docs.github.io/apidocs/spot/v1/en/#ticker
318
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
319
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
320
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
321
+ */
322
+ await this.loadMarkets();
323
+ const market = this.market(symbol);
324
+ const request = {
325
+ 'symbol': market['id'],
326
+ };
327
+ const response = await this.publicGetQuoteV1Ticker24hr(request);
328
+ const ticker = this.parseTicker(response[0]);
329
+ return ticker;
330
+ }
331
+ parseTicker(ticker, market = undefined) {
332
+ // {
333
+ // t: 1757164008834,
334
+ // s: "BTCUSDT",
335
+ // c: "110895.06",
336
+ // h: "113310.01",
337
+ // l: "110219.01",
338
+ // o: "112951.99",
339
+ // v: "3893.406649",
340
+ // qv: "433374169.27969515",
341
+ // pc: "-2056.93",
342
+ // pcp: "-0.0182"
343
+ // }
344
+ const marketType = 'spot';
345
+ let symbol = this.safeValue(ticker, 's');
346
+ const marketId = symbol;
347
+ symbol = this.safeSymbol(marketId, market, undefined, marketType);
348
+ const high = this.safeFloat(ticker, 'h');
349
+ const low = this.safeFloat(ticker, 'l');
350
+ const open = this.safeFloat(ticker, 'o');
351
+ const close = this.safeFloat(ticker, 'c');
352
+ const last = this.safeFloat(ticker, 'c');
353
+ const change = this.safeFloat(ticker, 'pcp');
354
+ const priceChange = this.safeFloat(ticker, 'pc');
355
+ const baseVolume = this.safeFloat(ticker, 'v');
356
+ const quoteVolume = this.safeFloat(ticker, 'qv');
357
+ const datetime = this.safeString(ticker, 't');
358
+ const bid = this.safeFloat(ticker, 'b', 0);
359
+ const ask = this.safeFloat(ticker, 'a', 0);
360
+ return this.safeTicker({
361
+ 'symbol': symbol,
362
+ 'timestamp': datetime,
363
+ 'datetime': this.parse8601(datetime),
364
+ 'high': high,
365
+ 'low': low,
366
+ 'bid': bid,
367
+ 'bidVolume': undefined,
368
+ 'ask': ask,
369
+ 'askVolume': undefined,
370
+ 'vwap': undefined,
371
+ 'open': open,
372
+ 'close': close,
373
+ 'last': last,
374
+ 'previousClose': undefined,
375
+ 'change': priceChange,
376
+ 'percentage': change,
377
+ 'average': undefined,
378
+ 'baseVolume': baseVolume,
379
+ 'quoteVolume': quoteVolume,
380
+ 'info': ticker,
381
+ }, market);
382
+ }
383
+ async fetchOHLCV(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
384
+ /**
385
+ * @method
386
+ * @name toobit#fetchOHLCV
387
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
388
+ * @see https://toobit-docs.github.io/apidocs/spot/v1/en/#chart
389
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
390
+ * @param {string} timeframe the length of time each candle represents
391
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
392
+ * @param {int} [limit] the maximum amount of candles to fetch
393
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
394
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
395
+ */
396
+ await this.loadMarkets();
397
+ const market = this.market(symbol);
398
+ const endTime = Date.now();
399
+ const request = {
400
+ 'symbol': market['id'],
401
+ 'from': (endTime - (24 * 60 * 60 * 1000)),
402
+ 'to': endTime,
403
+ 'interval': this.safeString(this.timeframes, timeframe, timeframe),
404
+ };
405
+ if (since !== undefined) {
406
+ request['from'] = since;
407
+ }
408
+ if (timeframe !== undefined) {
409
+ request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
410
+ }
411
+ const response = await this.publicGetQuoteV1Klines(request);
412
+ const ohlcvs = [];
413
+ for (let i = 0; i < response.length; i++) {
414
+ const candle = response[i];
415
+ const ts = this.safeTimestamp(candle, 0);
416
+ const open = this.safeFloat(candle, 1);
417
+ const high = this.safeFloat(candle, 2);
418
+ const low = this.safeFloat(candle, 3);
419
+ const close = this.safeFloat(candle, 4);
420
+ const volume = this.safeFloat(candle, 5);
421
+ ohlcvs.push([
422
+ ts,
423
+ open,
424
+ high,
425
+ low,
426
+ close,
427
+ volume,
428
+ ]);
429
+ }
430
+ return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
431
+ }
432
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
433
+ const query = this.omit(params, this.extractParams(path));
434
+ let url = this.urls['api']['public'] + '/' + path;
435
+ if (path === 'quote/v1/ticker/24hr') {
436
+ url = url + '?' + this.urlencode(query);
437
+ }
438
+ if (path === 'quote/v1/klines') {
439
+ url = url + '?' + this.urlencode(query);
440
+ }
441
+ headers = { 'Content-Type': 'application/json' };
442
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
443
+ }
444
444
  }
445
445
 
446
446
  exports["default"] = toobit;