ccxt-ir 4.12.4 → 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.
@@ -89,7 +89,7 @@ export default class hamtapay extends Exchange {
89
89
  'urls': {
90
90
  'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/hamtapay/64x64.png',
91
91
  'api': {
92
- 'public': 'https://oapi.hamtapay.org',
92
+ 'public': 'https://api.hamtapay.org',
93
93
  },
94
94
  'www': 'https://hamtapay.net/',
95
95
  'doc': [
@@ -100,6 +100,7 @@ export default class hamtapay extends Exchange {
100
100
  'public': {
101
101
  'get': {
102
102
  '/financial/api/market': 1,
103
+ '/financial/api/vitrin/prices': 1,
103
104
  },
104
105
  },
105
106
  },
@@ -118,7 +119,7 @@ export default class hamtapay extends Exchange {
118
119
  * @method
119
120
  * @name hamtapay#fetchMarkets
120
121
  * @description retrieves data on all markets for hamtapay
121
- * @see https://oapi.hamtapay.org/financial/api/market
122
+ * @see https://api.hamtapay.org/financial/api/market
122
123
  * @param {object} [params] extra parameters specific to the exchange API endpoint
123
124
  * @returns {object[]} an array of objects representing market data
124
125
  */
@@ -155,8 +156,8 @@ export default class hamtapay extends Exchange {
155
156
  'baseId': baseId,
156
157
  'quoteId': quoteId,
157
158
  'settleId': undefined,
158
- 'type': 'spot',
159
- 'spot': true,
159
+ 'type': 'otc',
160
+ 'spot': false,
160
161
  'margin': false,
161
162
  'swap': false,
162
163
  'future': false,
@@ -171,8 +172,8 @@ export default class hamtapay extends Exchange {
171
172
  'strike': undefined,
172
173
  'optionType': undefined,
173
174
  'precision': {
174
- 'amount': this.safeInteger(market, 'amount_decimals'),
175
- 'price': this.safeInteger(market, 'price_decimals'),
175
+ 'amount': undefined,
176
+ 'price': undefined,
176
177
  },
177
178
  'limits': {
178
179
  'leverage': {
@@ -201,7 +202,7 @@ export default class hamtapay extends Exchange {
201
202
  * @method
202
203
  * @name hamtapay#fetchTickers
203
204
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
204
- * @see https://oapi.hamtapay.org/financial/api/market
205
+ * @see https://api.hamtapay.org/financial/api/vitrin/prices
205
206
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
206
207
  * @param {object} [params] extra parameters specific to the exchange API endpoint
207
208
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -210,12 +211,23 @@ export default class hamtapay extends Exchange {
210
211
  if (symbols !== undefined) {
211
212
  symbols = this.marketSymbols(symbols);
212
213
  }
213
- const response = await this.publicGetFinancialApiMarket(params);
214
- const data = this.safeList(response, 'data', []);
214
+ const response = await this.publicGetFinancialApiVitrinPrices(params);
215
+ const data = this.safeDict(response, 'data', {});
215
216
  const result = {};
216
- for (let i = 0; i < data.length; i++) {
217
- const ticker = this.parseTicker(data[i]);
218
- 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
+ }
219
231
  }
220
232
  return this.filterByArrayTickers(result, 'symbol', symbols);
221
233
  }
@@ -224,41 +236,48 @@ export default class hamtapay extends Exchange {
224
236
  * @method
225
237
  * @name hamtapay#fetchTicker
226
238
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
227
- * @see https://oapi.hamtapay.org/financial/api/market
239
+ * @see https://hamtapay.com/management/all-coins/?format=json
228
240
  * @param {string} symbol unified symbol of the market to fetch the ticker for
229
241
  * @param {object} [params] extra parameters specific to the exchange API endpoint
230
242
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
231
243
  */
232
- const tickers = await this.fetchTickers([symbol], params);
233
- return tickers[symbol];
244
+ const ticker = await this.fetchTickers([symbol]);
245
+ return ticker[symbol];
234
246
  }
235
247
  parseTicker(ticker, market = undefined) {
236
- const marketType = 'spot';
237
- const marketId = this.safeString2(ticker, 'id', 'symbol');
238
- const baseId = this.safeString(ticker, 'base');
239
- const quoteId = this.safeString(ticker, 'quote');
240
- const base = this.safeCurrencyCode(baseId);
241
- const quote = this.safeCurrencyCode(quoteId);
242
- let symbol = this.safeSymbol(marketId, market, undefined, marketType);
243
- if ((baseId !== undefined) && (quoteId !== undefined)) {
244
- symbol = base + '/' + quote;
245
- }
246
- const last = this.safeFloat(ticker, 'last_price');
247
- const baseVolume = this.safeFloat(ticker, 'volume_24h');
248
- const percentage = this.safeFloat(ticker, 'percent_change_24h');
249
- let quoteVolume = undefined;
250
- if ((baseVolume !== undefined) && (last !== undefined)) {
251
- quoteVolume = baseVolume * last;
252
- }
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
+ // }
263
+ const marketType = 'otc';
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);
253
272
  return this.safeTicker({
254
273
  'symbol': symbol,
255
274
  'timestamp': undefined,
256
275
  'datetime': undefined,
257
- 'high': undefined,
258
- 'low': undefined,
259
- 'bid': undefined,
276
+ 'high': high,
277
+ 'low': low,
278
+ 'bid': bid,
260
279
  'bidVolume': undefined,
261
- 'ask': undefined,
280
+ 'ask': ask,
262
281
  'askVolume': undefined,
263
282
  'vwap': undefined,
264
283
  'open': undefined,
@@ -266,23 +285,15 @@ export default class hamtapay extends Exchange {
266
285
  'last': last,
267
286
  'previousClose': undefined,
268
287
  'change': undefined,
269
- 'percentage': percentage,
288
+ 'percentage': change,
270
289
  'average': undefined,
271
- 'baseVolume': baseVolume,
272
- 'quoteVolume': quoteVolume,
290
+ 'baseVolume': undefined,
291
+ 'quoteVolume': undefined,
273
292
  'info': ticker,
274
293
  }, market);
275
294
  }
276
295
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
277
- const query = this.omit(params, this.extractParams(path));
278
- let normalizedPath = path;
279
- while (normalizedPath.length && normalizedPath[0] === '/') {
280
- normalizedPath = normalizedPath.slice(1);
281
- }
282
- let url = this.urls['api']['public'] + '/' + this.implodeParams(normalizedPath, params);
283
- if (Object.keys(query).length) {
284
- url += '?' + this.urlencode(query);
285
- }
296
+ const url = this.urls['api']['public'] + '/' + path;
286
297
  headers = {
287
298
  'Content-Type': 'application/json',
288
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 = 'BTC/USDT';
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.4",
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",