ccxt-ir 4.9.15 → 4.9.19

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.
@@ -5,388 +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
- },
118
- },
119
- },
120
- 'fees': {
121
- 'trading': {
122
- 'tierBased': false,
123
- 'percentage': true,
124
- 'maker': this.parseNumber('0.001'),
125
- 'taker': this.parseNumber('0.001'),
126
- },
127
- },
128
- });
129
- }
130
- async fetchMarkets(params = {}) {
131
- /**
132
- * @method
133
- * @name toobit#fetchMarkets
134
- * @description retrieves data on all markets for toobit
135
- * @see https://apidocs.toobit.io/#tickers
136
- * @param {object} [params] extra parameters specific to the exchange API endpoint
137
- * @returns {object[]} an array of objects representing market data
138
- */
139
- const response = await this.publicGetQuoteV1Ticker24hr();
140
- const result = [];
141
- for (let i = 0; i < response.length; i++) {
142
- const volume = this.safeFloat(response[i], 'v');
143
- const symbol = this.safeValue(response[i], 's');
144
- if (volume === 0 || symbol === 'TESTA1S3TESTX8Z9') {
145
- continue;
146
- }
147
- const market = this.parseMarket(response[i]);
148
- result.push(market);
149
- }
150
- return result;
151
- }
152
- parseMarket(market) {
153
- // {
154
- // t: 1757164008834,
155
- // s: "BTCUSDT",
156
- // c: "110895.06",
157
- // h: "113310.01",
158
- // l: "110219.01",
159
- // o: "112951.99",
160
- // v: "3893.406649",
161
- // qv: "433374169.27969515",
162
- // pc: "-2056.93",
163
- // pcp: "-0.0182"
164
- // }
165
- const symbol = this.safeValue(market, 's');
166
- let baseId = symbol;
167
- let quoteId = undefined;
168
- if (symbol.endsWith('USDT')) {
169
- baseId = symbol.slice(0, -4);
170
- quoteId = 'USDT';
171
- }
172
- else if (symbol.endsWith('USDC')) {
173
- baseId = symbol.slice(0, -4);
174
- quoteId = 'USDC';
175
- }
176
- const id = symbol;
177
- const base = this.safeCurrencyCode(baseId);
178
- const quote = this.safeCurrencyCode(quoteId);
179
- baseId = baseId.toLowerCase();
180
- quoteId = quoteId.toLowerCase();
181
- return {
182
- 'id': id,
183
- 'symbol': base + '/' + quote,
184
- 'base': base,
185
- 'quote': quote,
186
- 'settle': undefined,
187
- 'baseId': baseId,
188
- 'quoteId': quoteId,
189
- 'settleId': undefined,
190
- 'type': 'spot',
191
- 'spot': true,
192
- 'margin': false,
193
- 'swap': false,
194
- 'future': false,
195
- 'option': false,
196
- 'active': true,
197
- 'contract': false,
198
- 'linear': undefined,
199
- 'inverse': undefined,
200
- 'contractSize': undefined,
201
- 'expiry': undefined,
202
- 'expiryDatetime': undefined,
203
- 'strike': undefined,
204
- 'optionType': undefined,
205
- 'precision': {
206
- 'amount': undefined,
207
- 'price': undefined,
208
- },
209
- 'limits': {
210
- 'leverage': {
211
- 'min': undefined,
212
- 'max': undefined,
213
- },
214
- 'amount': {
215
- 'min': undefined,
216
- 'max': undefined,
217
- },
218
- 'price': {
219
- 'min': undefined,
220
- 'max': undefined,
221
- },
222
- 'cost': {
223
- 'min': undefined,
224
- 'max': undefined,
225
- },
226
- },
227
- 'created': undefined,
228
- 'info': market,
229
- };
230
- }
231
- async fetchTickers(symbols = undefined, params = {}) {
232
- /**
233
- * @method
234
- * @name toobit#fetchTickers
235
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
236
- * @see https://apidocs.toobit.io/#tickers
237
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
238
- * @param {object} [params] extra parameters specific to the exchange API endpoint
239
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
240
- */
241
- await this.loadMarkets();
242
- if (symbols !== undefined) {
243
- symbols = this.marketSymbols(symbols);
244
- }
245
- const response = await this.publicGetQuoteV1Ticker24hr();
246
- const result = {};
247
- for (let i = 0; i < response.length; i++) {
248
- const volume = this.safeFloat(response[i], 'v');
249
- if (volume === 0) {
250
- continue;
251
- }
252
- const ticker = this.parseTicker(response[i]);
253
- const symbol = ticker['symbol'];
254
- result[symbol] = ticker;
255
- }
256
- return this.filterByArrayTickers(result, 'symbol', symbols);
257
- }
258
- async fetchTicker(symbol, params = {}) {
259
- /**
260
- * @method
261
- * @name toobit#fetchTicker
262
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
263
- * @see https://apidocs.toobit.io/#ticker
264
- * @param {string} symbol unified symbol of the market to fetch the ticker for
265
- * @param {object} [params] extra parameters specific to the exchange API endpoint
266
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
267
- */
268
- await this.loadMarkets();
269
- const market = this.market(symbol);
270
- const request = {
271
- 'symbol': market['id'],
272
- };
273
- const response = await this.publicGetQuoteV1Ticker24hr(request);
274
- const ticker = this.parseTicker(response[0]);
275
- return ticker;
276
- }
277
- parseTicker(ticker, market = undefined) {
278
- // {
279
- // t: 1757164008834,
280
- // s: "BTCUSDT",
281
- // c: "110895.06",
282
- // h: "113310.01",
283
- // l: "110219.01",
284
- // o: "112951.99",
285
- // v: "3893.406649",
286
- // qv: "433374169.27969515",
287
- // pc: "-2056.93",
288
- // pcp: "-0.0182"
289
- // }
290
- const marketType = 'spot';
291
- let symbol = this.safeValue(ticker, 's');
292
- const marketId = symbol;
293
- symbol = this.safeSymbol(marketId, market, undefined, marketType);
294
- const high = this.safeFloat(ticker, 'h');
295
- const low = this.safeFloat(ticker, 'l');
296
- const open = this.safeFloat(ticker, 'o');
297
- const close = this.safeFloat(ticker, 'c');
298
- const last = this.safeFloat(ticker, 'c');
299
- const change = this.safeFloat(ticker, 'pcp');
300
- const priceChange = this.safeFloat(ticker, 'pc');
301
- const baseVolume = this.safeFloat(ticker, 'v');
302
- const quoteVolume = this.safeFloat(ticker, 'qv');
303
- const datetime = this.safeString(ticker, 't');
304
- const bid = this.safeFloat(ticker, 'b', 0);
305
- const ask = this.safeFloat(ticker, 'a', 0);
306
- return this.safeTicker({
307
- 'symbol': symbol,
308
- 'timestamp': datetime,
309
- 'datetime': this.parse8601(datetime),
310
- 'high': high,
311
- 'low': low,
312
- 'bid': bid,
313
- 'bidVolume': undefined,
314
- 'ask': ask,
315
- 'askVolume': undefined,
316
- 'vwap': undefined,
317
- 'open': open,
318
- 'close': close,
319
- 'last': last,
320
- 'previousClose': undefined,
321
- 'change': priceChange,
322
- 'percentage': change,
323
- 'average': undefined,
324
- 'baseVolume': baseVolume,
325
- 'quoteVolume': quoteVolume,
326
- 'info': ticker,
327
- }, market);
328
- }
329
- async fetchOHLCV(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
330
- /**
331
- * @method
332
- * @name toobit#fetchOHLCV
333
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
334
- * @see https://apidocs.toobit.io/#chart
335
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
336
- * @param {string} timeframe the length of time each candle represents
337
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
338
- * @param {int} [limit] the maximum amount of candles to fetch
339
- * @param {object} [params] extra parameters specific to the exchange API endpoint
340
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
341
- */
342
- await this.loadMarkets();
343
- const market = this.market(symbol);
344
- const endTime = Date.now();
345
- const request = {
346
- 'symbol': market['id'],
347
- 'from': (endTime - (24 * 60 * 60 * 1000)),
348
- 'to': endTime,
349
- 'interval': this.safeString(this.timeframes, timeframe, timeframe),
350
- };
351
- if (since !== undefined) {
352
- request['from'] = since;
353
- }
354
- if (timeframe !== undefined) {
355
- request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
356
- }
357
- const response = await this.publicGetQuoteV1Klines(request);
358
- const ohlcvs = [];
359
- for (let i = 0; i < response.length; i++) {
360
- const candle = response[i];
361
- const ts = this.safeTimestamp(candle, 0);
362
- const open = this.safeFloat(candle, 1);
363
- const high = this.safeFloat(candle, 2);
364
- const low = this.safeFloat(candle, 3);
365
- const close = this.safeFloat(candle, 4);
366
- const volume = this.safeFloat(candle, 5);
367
- ohlcvs.push([
368
- ts,
369
- open,
370
- high,
371
- low,
372
- close,
373
- volume,
374
- ]);
375
- }
376
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
377
- }
378
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
379
- const query = this.omit(params, this.extractParams(path));
380
- let url = this.urls['api']['public'] + '/' + path;
381
- if (path === 'quote/v1/ticker/24hr') {
382
- url = url + '?' + this.urlencode(query);
383
- }
384
- if (path === 'quote/v1/klines') {
385
- url = url + '?' + this.urlencode(query);
386
- }
387
- headers = { 'Content-Type': 'application/json' };
388
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
389
- }
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
+ }
390
444
  }
391
445
 
392
446
  exports["default"] = toobit;