ccxt-ir 4.12.3 → 4.13.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.
@@ -80,7 +80,6 @@ export default class hamtapay extends Exchange {
80
80
  'fetchTradingFee': false,
81
81
  'fetchTradingFees': false,
82
82
  'fetchWithdrawals': false,
83
- 'otc': true,
84
83
  'setLeverage': false,
85
84
  'setMarginMode': false,
86
85
  'transfer': false,
@@ -90,7 +89,7 @@ export default class hamtapay extends Exchange {
90
89
  'urls': {
91
90
  'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/hamtapay/64x64.png',
92
91
  'api': {
93
- 'public': 'https://oapi.hamtapay.org',
92
+ 'public': 'https://api.hamtapay.org',
94
93
  },
95
94
  'www': 'https://hamtapay.net/',
96
95
  'doc': [
@@ -101,7 +100,7 @@ export default class hamtapay extends Exchange {
101
100
  'public': {
102
101
  'get': {
103
102
  '/financial/api/market': 1,
104
- '/financial/api/market/{symbol}': 1,
103
+ '/financial/api/vitrin/prices': 1,
105
104
  },
106
105
  },
107
106
  },
@@ -120,7 +119,7 @@ export default class hamtapay extends Exchange {
120
119
  * @method
121
120
  * @name hamtapay#fetchMarkets
122
121
  * @description retrieves data on all markets for hamtapay
123
- * @see https://oapi.hamtapay.org/financial/api/market
122
+ * @see https://api.hamtapay.org/financial/api/market
124
123
  * @param {object} [params] extra parameters specific to the exchange API endpoint
125
124
  * @returns {object[]} an array of objects representing market data
126
125
  */
@@ -173,8 +172,8 @@ export default class hamtapay extends Exchange {
173
172
  'strike': undefined,
174
173
  'optionType': undefined,
175
174
  'precision': {
176
- 'amount': this.safeInteger(market, 'amount_decimals'),
177
- 'price': this.safeInteger(market, 'price_decimals'),
175
+ 'amount': undefined,
176
+ 'price': undefined,
178
177
  },
179
178
  'limits': {
180
179
  'leverage': {
@@ -203,7 +202,7 @@ export default class hamtapay extends Exchange {
203
202
  * @method
204
203
  * @name hamtapay#fetchTickers
205
204
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
206
- * @see https://oapi.hamtapay.org/financial/api/market
205
+ * @see https://api.hamtapay.org/financial/api/vitrin/prices
207
206
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
208
207
  * @param {object} [params] extra parameters specific to the exchange API endpoint
209
208
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -212,12 +211,23 @@ export default class hamtapay extends Exchange {
212
211
  if (symbols !== undefined) {
213
212
  symbols = this.marketSymbols(symbols);
214
213
  }
215
- const response = await this.publicGetFinancialApiMarket(params);
216
- const data = this.safeList(response, 'data', []);
214
+ const response = await this.publicGetFinancialApiVitrinPrices(params);
215
+ const data = this.safeDict(response, 'data', {});
217
216
  const result = {};
218
- for (let i = 0; i < data.length; i++) {
219
- const ticker = this.parseTicker(data[i]);
220
- result[ticker['symbol']] = ticker;
217
+ const quotes = ['IRT', 'USDT'];
218
+ for (let i = 0; i < quotes.length; i++) {
219
+ const current_qoute = quotes[i];
220
+ const corresponding_data = this.safeDict(data, current_qoute, {});
221
+ const baseSymbols = Object.keys(corresponding_data);
222
+ for (let j = 0; j < baseSymbols.length; j++) {
223
+ const current_base = baseSymbols[j];
224
+ const current_ticker = corresponding_data[current_base];
225
+ current_ticker['base'] = current_base;
226
+ current_ticker['quote'] = current_qoute;
227
+ current_ticker['symbol'] = current_base + '/' + current_qoute;
228
+ current_ticker['id'] = current_base + '-' + current_qoute;
229
+ result[current_ticker['symbol']] = this.parseTicker(current_ticker);
230
+ }
221
231
  }
222
232
  return this.filterByArrayTickers(result, 'symbol', symbols);
223
233
  }
@@ -226,42 +236,48 @@ export default class hamtapay extends Exchange {
226
236
  * @method
227
237
  * @name hamtapay#fetchTicker
228
238
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
229
- * @see https://oapi.hamtapay.org/financial/api/market/{symbol}
239
+ * @see https://hamtapay.com/management/all-coins/?format=json
230
240
  * @param {string} symbol unified symbol of the market to fetch the ticker for
231
241
  * @param {object} [params] extra parameters specific to the exchange API endpoint
232
242
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
233
243
  */
234
- await this.loadMarkets();
235
- const market = this.market(symbol);
236
- const request = {
237
- 'symbol': market['id'],
238
- };
239
- const response = await this.publicGetFinancialApiMarketSymbol(this.extend(request, params));
240
- const ticker = this.safeDict(response, 'data', response);
241
- return this.parseTicker(ticker, market);
244
+ const ticker = await this.fetchTickers([symbol]);
245
+ return ticker[symbol];
242
246
  }
243
247
  parseTicker(ticker, market = undefined) {
248
+ // {
249
+ // "id": "USDT-IRT",
250
+ // "symbol": "USDT/IRT",
251
+ // "base": "USDT",
252
+ // "quote": "IRT",
253
+ // "min_price_24h": "111702",
254
+ // "max_price_24h": "115872",
255
+ // "market_price": "115942",
256
+ // "buy_price": "117101",
257
+ // "sell_price": "114782",
258
+ // "change_rate_24h": 3.29,
259
+ // "amount_decimals": 0,
260
+ // "price_decimals": 0,
261
+ // "status": "ACTIVE"
262
+ // }
244
263
  const marketType = 'otc';
245
- const marketId = this.safeString2(ticker, 'id', 'symbol');
246
- const baseId = this.safeString(ticker, 'base');
247
- const quoteId = this.safeString(ticker, 'quote');
248
- const base = this.safeCurrencyCode(baseId);
249
- const quote = this.safeCurrencyCode(quoteId);
250
- let symbol = this.safeSymbol(marketId, market, undefined, marketType);
251
- if ((baseId !== undefined) && (quoteId !== undefined)) {
252
- symbol = base + '/' + quote;
253
- }
254
- const last = this.safeFloat(ticker, 'last_price');
255
- const percentage = this.safeFloat(ticker, 'percent_change_24h');
264
+ const marketId = this.safeString(ticker, 'id');
265
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
266
+ const last = this.safeFloat(ticker, 'buy_price', 0);
267
+ const change = this.safeFloat(ticker, 'change_rate_24h', 0);
268
+ const ask = this.safeFloat(ticker, 'buy_price', 0);
269
+ const bid = this.safeFloat(ticker, 'sell_price', 0);
270
+ const high = this.safeFloat(ticker, 'max_price_24h', 0);
271
+ const low = this.safeFloat(ticker, 'min_price_24h', 0);
256
272
  return this.safeTicker({
257
273
  'symbol': symbol,
258
274
  'timestamp': undefined,
259
275
  'datetime': undefined,
260
- 'high': undefined,
261
- 'low': undefined,
262
- 'bid': undefined,
276
+ 'high': high,
277
+ 'low': low,
278
+ 'bid': bid,
263
279
  'bidVolume': undefined,
264
- 'ask': undefined,
280
+ 'ask': ask,
265
281
  'askVolume': undefined,
266
282
  'vwap': undefined,
267
283
  'open': undefined,
@@ -269,7 +285,7 @@ export default class hamtapay extends Exchange {
269
285
  'last': last,
270
286
  'previousClose': undefined,
271
287
  'change': undefined,
272
- 'percentage': percentage,
288
+ 'percentage': change,
273
289
  'average': undefined,
274
290
  'baseVolume': undefined,
275
291
  'quoteVolume': undefined,
@@ -277,15 +293,7 @@ export default class hamtapay extends Exchange {
277
293
  }, market);
278
294
  }
279
295
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
280
- const query = this.omit(params, this.extractParams(path));
281
- let normalizedPath = path;
282
- while (normalizedPath.length && normalizedPath[0] === '/') {
283
- normalizedPath = normalizedPath.slice(1);
284
- }
285
- let url = this.urls['api']['public'] + '/' + this.implodeParams(normalizedPath, params);
286
- if (Object.keys(query).length) {
287
- url += '?' + this.urlencode(query);
288
- }
296
+ const url = this.urls['api']['public'] + '/' + path;
289
297
  headers = {
290
298
  'Content-Type': 'application/json',
291
299
  'Origin': 'https://hamtapay.net',
@@ -0,0 +1,21 @@
1
+ import Exchange from './abstract/bitwana.js';
2
+ import { Market, Strings, Ticker, Tickers } from './base/types.js';
3
+ /**
4
+ * @class bitwana
5
+ * @augments Exchange
6
+ * @description Set rateLimit to 1000 if fully verified
7
+ */
8
+ export default class bitwana extends Exchange {
9
+ describe(): any;
10
+ parseMarket(market: any): Market;
11
+ fetchMarkets(params?: {}): Promise<Market[]>;
12
+ fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
13
+ fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
14
+ parseTicker(ticker: any, market?: Market): Ticker;
15
+ sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
16
+ url: string;
17
+ method: string;
18
+ body: any;
19
+ headers: any;
20
+ };
21
+ }
package/js/test.js CHANGED
@@ -5,37 +5,89 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  import ccxt from './ccxt';
8
- async function testHamtapay() {
9
- const exchange = new ccxt.hamtapay({
8
+ async function testBitwana() {
9
+ const exchange = new ccxt.bitwana({
10
10
  enableRateLimit: true,
11
11
  timeout: 20000,
12
12
  });
13
13
  try {
14
- const markets = await exchange.fetchMarkets();
15
- console.log('markets count:', markets.length);
16
- console.log('first markets:', markets.slice(0, 10).map((market) => ({
17
- symbol: market.symbol,
18
- id: market.id,
19
- type: market.type,
20
- active: market.active,
21
- amountPrecision: market.precision && market.precision.amount,
22
- pricePrecision: market.precision && market.precision.price,
23
- })));
24
- const tickers = await exchange.fetchTickers();
25
- console.log('tickers count:', Object.keys(tickers).length);
26
- const symbol = 'USDT/IRT';
27
- const ticker = await exchange.fetchTicker(symbol);
28
- console.log('single ticker:', {
29
- symbol: ticker.symbol,
30
- last: ticker.last,
31
- percentage: ticker.percentage,
32
- baseVolume: ticker.baseVolume,
33
- quoteVolume: ticker.quoteVolume,
34
- info: ticker.info,
35
- });
14
+ const types = ['spot', 'otc'];
15
+ for (let i = 0; i < types.length; i++) {
16
+ const marketType = types[i];
17
+ const params = { 'type': marketType };
18
+ const markets = await exchange.fetchMarkets(params);
19
+ console.log(marketType + ' markets count:', markets.length);
20
+ console.log(marketType + ' first markets:', markets.slice(0, 10).map((market) => ({
21
+ symbol: market.symbol,
22
+ id: market.id,
23
+ type: market.type,
24
+ active: market.active,
25
+ amountPrecision: market.precision && market.precision.amount,
26
+ pricePrecision: market.precision && market.precision.price,
27
+ })));
28
+ const tickers = await exchange.fetchTickers(undefined, params);
29
+ const tickerSymbols = Object.keys(tickers);
30
+ console.log(marketType + ' tickers count:', tickerSymbols.length);
31
+ const missingFromFetchTickers = [];
32
+ const fetchTickerFailures = [];
33
+ const sampleTickers = [];
34
+ for (let j = 0; j < markets.length; j++) {
35
+ const market = markets[j];
36
+ const symbol = market.symbol;
37
+ const tickerFromBulk = tickers[symbol];
38
+ if (tickerFromBulk === undefined) {
39
+ missingFromFetchTickers.push(symbol);
40
+ continue;
41
+ }
42
+ if (sampleTickers.length < 10) {
43
+ sampleTickers.push({
44
+ symbol: tickerFromBulk.symbol,
45
+ type: market.type,
46
+ last: tickerFromBulk.last,
47
+ bid: tickerFromBulk.bid,
48
+ ask: tickerFromBulk.ask,
49
+ high: tickerFromBulk.high,
50
+ low: tickerFromBulk.low,
51
+ baseVolume: tickerFromBulk.baseVolume,
52
+ quoteVolume: tickerFromBulk.quoteVolume,
53
+ });
54
+ }
55
+ try {
56
+ const singleTicker = await exchange.fetchTicker(symbol, params);
57
+ console.log('checked ' + marketType + ' ticker:', {
58
+ symbol: singleTicker.symbol,
59
+ type: market.type,
60
+ last: singleTicker.last,
61
+ bid: singleTicker.bid,
62
+ ask: singleTicker.ask,
63
+ });
64
+ }
65
+ catch (error) {
66
+ fetchTickerFailures.push({
67
+ symbol,
68
+ type: market.type,
69
+ message: error instanceof Error ? error.message : String(error),
70
+ });
71
+ }
72
+ }
73
+ console.log(marketType + ' sample bulk tickers:', sampleTickers);
74
+ console.log(marketType + ' missing from fetchTickers:', missingFromFetchTickers);
75
+ console.log(marketType + ' fetchTicker failures:', fetchTickerFailures);
76
+ console.log(marketType + ' summary:', {
77
+ marketsCount: markets.length,
78
+ tickersCount: tickerSymbols.length,
79
+ missingFromFetchTickersCount: missingFromFetchTickers.length,
80
+ fetchTickerFailuresCount: fetchTickerFailures.length,
81
+ });
82
+ }
36
83
  }
37
84
  catch (error) {
38
- console.error('Error during testing hamtapay:', error);
85
+ console.error('Error during testing bitwana:', error);
86
+ }
87
+ finally {
88
+ if (exchange.close) {
89
+ await exchange.close();
90
+ }
39
91
  }
40
92
  }
41
- testHamtapay();
93
+ testBitwana();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt-ir",
3
- "version": "4.12.3",
3
+ "version": "4.13.0",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",