ccxt-ir 4.9.31 → 4.10.0
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.
- package/README.md +4 -4
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/asretether.js +11 -0
- package/dist/cjs/src/asretether.js +325 -0
- package/dist/cjs/src/bit24.js +138 -3
- package/dist/cjs/src/raastin.js +144 -16
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/asretether.d.ts +8 -0
- package/js/src/abstract/asretether.js +11 -0
- package/js/src/abstract/bit24.d.ts +1 -0
- package/js/src/abstract/raastin.d.ts +1 -0
- package/js/src/asretether.d.ts +21 -0
- package/js/src/asretether.js +324 -0
- package/js/src/bit24.d.ts +3 -0
- package/js/src/bit24.js +138 -3
- package/js/src/raastin.d.ts +2 -0
- package/js/src/raastin.js +144 -16
- package/js/test.js +16 -16
- package/package.json +1 -1
package/js/src/raastin.js
CHANGED
|
@@ -80,6 +80,7 @@ export default class raastin extends Exchange {
|
|
|
80
80
|
'fetchTradingFee': false,
|
|
81
81
|
'fetchTradingFees': false,
|
|
82
82
|
'fetchWithdrawals': false,
|
|
83
|
+
'otc': true,
|
|
83
84
|
'setLeverage': false,
|
|
84
85
|
'setMarginMode': false,
|
|
85
86
|
'transfer': false,
|
|
@@ -102,6 +103,7 @@ export default class raastin extends Exchange {
|
|
|
102
103
|
'api/v1/market/symbols': 1,
|
|
103
104
|
'api/v1/market/symbols/{symbol}/': 1,
|
|
104
105
|
'api/v1/market/depth/{symbol}': 1,
|
|
106
|
+
'api/v1/market': 1,
|
|
105
107
|
},
|
|
106
108
|
},
|
|
107
109
|
},
|
|
@@ -123,10 +125,24 @@ export default class raastin extends Exchange {
|
|
|
123
125
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
124
126
|
* @returns {object[]} an array of objects representing market data
|
|
125
127
|
*/
|
|
128
|
+
const result = [];
|
|
129
|
+
const marketType = this.safeString(params, 'type', 'spot');
|
|
130
|
+
if (marketType === 'otc') {
|
|
131
|
+
const qoutes = ['irt', 'usdt'];
|
|
132
|
+
for (let i = 0; i < qoutes.length; i++) {
|
|
133
|
+
const quote = qoutes[i];
|
|
134
|
+
const OTCmarkets = await this.publicGetApiV1Market(this.extend(params, { 'quote': quote }));
|
|
135
|
+
for (let j = 0; j < OTCmarkets.length; j++) {
|
|
136
|
+
OTCmarkets[j]['quote'] = quote;
|
|
137
|
+
const market = this.parseOtcMarket(OTCmarkets[j]);
|
|
138
|
+
result.push(market);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
126
143
|
const response = await this.publicGetApiV1MarketSymbols(params);
|
|
127
144
|
// Response is a flat array, not nested in 'result'
|
|
128
145
|
const markets = response;
|
|
129
|
-
const result = [];
|
|
130
146
|
for (let i = 0; i < markets.length; i++) {
|
|
131
147
|
const market = this.parseMarket(markets[i]);
|
|
132
148
|
result.push(market);
|
|
@@ -241,6 +257,68 @@ export default class raastin extends Exchange {
|
|
|
241
257
|
'info': market,
|
|
242
258
|
};
|
|
243
259
|
}
|
|
260
|
+
parseOtcMarket(market) {
|
|
261
|
+
// {
|
|
262
|
+
// symbol: "USDT",
|
|
263
|
+
// ask: "1",
|
|
264
|
+
// bid: "1",
|
|
265
|
+
// name: "tether"
|
|
266
|
+
// },
|
|
267
|
+
const baseSymbol = this.safeString(market, 'symbol');
|
|
268
|
+
const base = this.safeCurrencyCode(baseSymbol.toUpperCase());
|
|
269
|
+
const quote = this.safeCurrencyCode(market['quote'].toUpperCase());
|
|
270
|
+
const id = base.toUpperCase() + quote.toUpperCase();
|
|
271
|
+
const enabled = true;
|
|
272
|
+
return {
|
|
273
|
+
'id': id,
|
|
274
|
+
'symbol': base + '/' + quote,
|
|
275
|
+
'base': base,
|
|
276
|
+
'quote': quote,
|
|
277
|
+
'settle': undefined,
|
|
278
|
+
'baseId': base,
|
|
279
|
+
'quoteId': quote,
|
|
280
|
+
'settleId': undefined,
|
|
281
|
+
'type': 'otc',
|
|
282
|
+
'spot': false,
|
|
283
|
+
'margin': false,
|
|
284
|
+
'swap': false,
|
|
285
|
+
'future': false,
|
|
286
|
+
'option': false,
|
|
287
|
+
'active': enabled,
|
|
288
|
+
'contract': false,
|
|
289
|
+
'linear': undefined,
|
|
290
|
+
'inverse': undefined,
|
|
291
|
+
'contractSize': undefined,
|
|
292
|
+
'expiry': undefined,
|
|
293
|
+
'expiryDatetime': undefined,
|
|
294
|
+
'strike': undefined,
|
|
295
|
+
'optionType': undefined,
|
|
296
|
+
'precision': {
|
|
297
|
+
'amount': undefined,
|
|
298
|
+
'price': undefined,
|
|
299
|
+
},
|
|
300
|
+
'limits': {
|
|
301
|
+
'leverage': {
|
|
302
|
+
'min': undefined,
|
|
303
|
+
'max': undefined,
|
|
304
|
+
},
|
|
305
|
+
'amount': {
|
|
306
|
+
'min': undefined,
|
|
307
|
+
'max': undefined,
|
|
308
|
+
},
|
|
309
|
+
'price': {
|
|
310
|
+
'min': undefined,
|
|
311
|
+
'max': undefined,
|
|
312
|
+
},
|
|
313
|
+
'cost': {
|
|
314
|
+
'min': undefined,
|
|
315
|
+
'max': undefined,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
'created': undefined,
|
|
319
|
+
'info': market,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
244
322
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
245
323
|
/**
|
|
246
324
|
* @method
|
|
@@ -250,13 +328,27 @@ export default class raastin extends Exchange {
|
|
|
250
328
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
251
329
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
252
330
|
*/
|
|
253
|
-
|
|
331
|
+
const marketType = this.safeString(params, 'type', 'spot');
|
|
332
|
+
await this.loadMarkets(false, { 'type': marketType });
|
|
254
333
|
if (symbols !== undefined) {
|
|
255
334
|
symbols = this.marketSymbols(symbols);
|
|
256
335
|
}
|
|
257
|
-
const response = await this.publicGetApiV1MarketSymbols(params);
|
|
258
|
-
const markets = this.safeList(response, response);
|
|
259
336
|
const result = {};
|
|
337
|
+
if (marketType === 'otc') {
|
|
338
|
+
const qoutes = ['irt', 'usdt'];
|
|
339
|
+
for (let i = 0; i < qoutes.length; i++) {
|
|
340
|
+
const quote = qoutes[i];
|
|
341
|
+
const OTCmarkets = await this.publicGetApiV1Market(this.extend(params, { 'quote': quote }));
|
|
342
|
+
for (let j = 0; j < OTCmarkets.length; j++) {
|
|
343
|
+
OTCmarkets[j]['quote'] = quote.toUpperCase();
|
|
344
|
+
const ticker = await this.parseOTCTicker(OTCmarkets[j]);
|
|
345
|
+
const symbol = ticker['symbol'];
|
|
346
|
+
result[symbol] = ticker;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
350
|
+
}
|
|
351
|
+
const markets = await this.publicGetApiV1MarketSymbols(params);
|
|
260
352
|
for (let i = 0; i < markets.length; i++) {
|
|
261
353
|
const marketData = markets[i];
|
|
262
354
|
const ticker = this.parseTicker(marketData);
|
|
@@ -274,7 +366,12 @@ export default class raastin extends Exchange {
|
|
|
274
366
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
275
367
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
276
368
|
*/
|
|
277
|
-
|
|
369
|
+
const marketType = this.safeString(params, 'type', 'spot');
|
|
370
|
+
await this.loadMarkets(false, { 'type': marketType });
|
|
371
|
+
if (marketType === 'otc') {
|
|
372
|
+
const tickers = await this.fetchTickers([symbol], { 'type': 'otc' });
|
|
373
|
+
return tickers[symbol];
|
|
374
|
+
}
|
|
278
375
|
const market = this.market(symbol);
|
|
279
376
|
const request = {
|
|
280
377
|
'symbol': market['id'],
|
|
@@ -290,36 +387,61 @@ export default class raastin extends Exchange {
|
|
|
290
387
|
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
291
388
|
// Since the exact ticker fields are not provided in the user's example,
|
|
292
389
|
// we'll set up the basic structure. These may need adjustment based on actual API response.
|
|
293
|
-
const last = this.safeFloat(ticker, '
|
|
294
|
-
const high = this.safeFloat(ticker, '
|
|
295
|
-
const low = this.safeFloat(ticker, '
|
|
296
|
-
const baseVolume = this.safeFloat(ticker, '
|
|
297
|
-
const quoteVolume = this.safeFloat(ticker, '
|
|
298
|
-
const
|
|
299
|
-
const ask = this.safeFloat(ticker, 'ask_price', 0);
|
|
390
|
+
const last = this.safeFloat(ticker, 'price', 0);
|
|
391
|
+
const high = this.safeFloat(ticker, 'high', 0);
|
|
392
|
+
const low = this.safeFloat(ticker, 'low', 0);
|
|
393
|
+
const baseVolume = this.safeFloat(ticker, 'base_volume', 0);
|
|
394
|
+
const quoteVolume = this.safeFloat(ticker, 'volume', 0);
|
|
395
|
+
const changePercentage = this.safeFloat(ticker, 'change_percentage', 0);
|
|
300
396
|
return this.safeTicker({
|
|
301
397
|
'symbol': symbol,
|
|
302
398
|
'timestamp': undefined,
|
|
303
399
|
'datetime': undefined,
|
|
304
400
|
'high': high,
|
|
305
401
|
'low': low,
|
|
306
|
-
'bid':
|
|
402
|
+
'bid': undefined,
|
|
307
403
|
'bidVolume': undefined,
|
|
308
|
-
'ask':
|
|
404
|
+
'ask': undefined,
|
|
309
405
|
'askVolume': undefined,
|
|
310
406
|
'vwap': undefined,
|
|
311
407
|
'open': undefined,
|
|
312
408
|
'close': last,
|
|
313
409
|
'last': last,
|
|
314
410
|
'previousClose': undefined,
|
|
315
|
-
'change':
|
|
316
|
-
'percentage':
|
|
411
|
+
'change': changePercentage,
|
|
412
|
+
'percentage': changePercentage,
|
|
317
413
|
'average': undefined,
|
|
318
414
|
'baseVolume': baseVolume,
|
|
319
415
|
'quoteVolume': quoteVolume,
|
|
320
416
|
'info': ticker,
|
|
321
417
|
}, market);
|
|
322
418
|
}
|
|
419
|
+
parseOTCTicker(ticker, market = undefined) {
|
|
420
|
+
const symbol = this.safeString(ticker, 'symbol') + '/' + this.safeString(ticker, 'quote');
|
|
421
|
+
const bid = this.safeFloat(ticker, 'bid');
|
|
422
|
+
const ask = this.safeFloat(ticker, 'ask');
|
|
423
|
+
return this.safeTicker({
|
|
424
|
+
'symbol': symbol,
|
|
425
|
+
'timestamp': undefined,
|
|
426
|
+
'datetime': undefined,
|
|
427
|
+
'high': undefined,
|
|
428
|
+
'low': undefined,
|
|
429
|
+
'bid': bid,
|
|
430
|
+
'bidVolume': undefined,
|
|
431
|
+
'ask': ask,
|
|
432
|
+
'askVolume': undefined,
|
|
433
|
+
'vwap': undefined,
|
|
434
|
+
'open': undefined,
|
|
435
|
+
'close': undefined,
|
|
436
|
+
'previousClose': undefined,
|
|
437
|
+
'change': undefined,
|
|
438
|
+
'percentage': undefined,
|
|
439
|
+
'average': undefined,
|
|
440
|
+
'baseVolume': undefined,
|
|
441
|
+
'quoteVolume': undefined,
|
|
442
|
+
'info': ticker,
|
|
443
|
+
}, market);
|
|
444
|
+
}
|
|
323
445
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
324
446
|
/**
|
|
325
447
|
* @method
|
|
@@ -360,6 +482,12 @@ export default class raastin extends Exchange {
|
|
|
360
482
|
if (Object.keys(query).length) {
|
|
361
483
|
url = url + '?' + this.urlencode(query);
|
|
362
484
|
}
|
|
485
|
+
if (path === 'api/v1/market') {
|
|
486
|
+
const quote = this.safeString(params, 'quote');
|
|
487
|
+
if (quote !== undefined) {
|
|
488
|
+
url = this.urls['api']['public'] + '/' + path + '/' + quote + '/info';
|
|
489
|
+
}
|
|
490
|
+
}
|
|
363
491
|
headers = { 'Content-Type': 'application/json' };
|
|
364
492
|
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
365
493
|
}
|
package/js/test.js
CHANGED
|
@@ -4,26 +4,26 @@
|
|
|
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
|
-
import ccxt from './ccxt
|
|
8
|
-
async function
|
|
9
|
-
const exchange = new ccxt.
|
|
7
|
+
import ccxt from './ccxt';
|
|
8
|
+
async function testAsretether() {
|
|
9
|
+
const exchange = new ccxt.asretether({
|
|
10
|
+
enableRateLimit: true,
|
|
11
|
+
timeout: 20000,
|
|
12
|
+
});
|
|
10
13
|
try {
|
|
11
|
-
|
|
14
|
+
console.log('Loading markets...');
|
|
12
15
|
await exchange.loadMarkets();
|
|
13
|
-
console.log('Markets loaded
|
|
14
|
-
// Test fetchMarkets
|
|
16
|
+
console.log('Markets loaded:', Object.keys(exchange.markets).length);
|
|
15
17
|
console.log('Testing fetchMarkets...');
|
|
16
18
|
const markets = await exchange.fetchMarkets();
|
|
17
|
-
console.log('fetchMarkets
|
|
18
|
-
console.log('
|
|
19
|
-
// Test fetchTickers
|
|
19
|
+
console.log('fetchMarkets returned', markets.length, 'markets');
|
|
20
|
+
console.log('Sample market:', markets.length ? markets[0] : 'none');
|
|
20
21
|
console.log('Testing fetchTickers...');
|
|
21
22
|
const tickers = await exchange.fetchTickers();
|
|
22
|
-
console.log('fetchTickers
|
|
23
|
-
console.log('
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const firstSymbol = Object.keys(markets)[0];
|
|
23
|
+
console.log('fetchTickers returned', Object.keys(tickers).length, 'tickers');
|
|
24
|
+
console.log('Sample ticker:', Object.values(tickers).length ? Object.values(tickers)[0] : 'none');
|
|
25
|
+
if (markets.length > 0) {
|
|
26
|
+
const firstSymbol = markets[20].symbol;
|
|
27
27
|
console.log('Testing fetchTicker for symbol:', firstSymbol);
|
|
28
28
|
const ticker = await exchange.fetchTicker(firstSymbol);
|
|
29
29
|
console.log('fetchTicker result:', ticker);
|
|
@@ -33,7 +33,7 @@ async function testBit24() {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
catch (error) {
|
|
36
|
-
console.error('Error during testing:', error);
|
|
36
|
+
console.error('Error during testing asretether:', error);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
testAsretether();
|
package/package.json
CHANGED