ccxt-ir 4.9.29 → 4.9.32

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/js/src/binance.js CHANGED
@@ -3047,6 +3047,7 @@ export default class binance extends Exchange {
3047
3047
  */
3048
3048
  async fetchMarkets(params = {}) {
3049
3049
  const promisesRaw = [];
3050
+ params = this.omit(params, ['type']);
3050
3051
  let rawFetchMarkets = undefined;
3051
3052
  const defaultTypes = ['spot', 'linear', 'inverse'];
3052
3053
  const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets');
package/js/src/bit24.d.ts CHANGED
@@ -9,9 +9,12 @@ export default class bit24 extends Exchange {
9
9
  describe(): any;
10
10
  fetchMarkets(params?: {}): Promise<Market[]>;
11
11
  parseMarket(market: any): Market;
12
+ parseOtcMarket(market: any): Market;
12
13
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
13
14
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
14
15
  parseTicker(ticker: any, market?: Market): Ticker;
16
+ parseOtcTicker(ticker: any, market?: Market): Ticker;
17
+ removeDuplicateValues(markets: Market[]): Promise<Market[]>;
15
18
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
16
19
  url: string;
17
20
  method: string;
package/js/src/bit24.js CHANGED
@@ -90,7 +90,8 @@ export default class bit24 extends Exchange {
90
90
  'urls': {
91
91
  'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bit24/64x64.png',
92
92
  'api': {
93
- 'public': 'https://bit24.cash/api/',
93
+ 'public': 'https://rest.bit24.cash',
94
+ 'otc': 'https://otc-api.bit24.cash',
94
95
  },
95
96
  'www': 'https://bit24.cash/',
96
97
  'doc': [
@@ -100,7 +101,8 @@ export default class bit24 extends Exchange {
100
101
  'api': {
101
102
  'public': {
102
103
  'get': {
103
- 'pro/v3/markets': 1,
104
+ 'pro/capi/v1/markets': 1,
105
+ 'api/v1/coins/simple-list': 1,
104
106
  },
105
107
  },
106
108
  },
@@ -117,10 +119,18 @@ export default class bit24 extends Exchange {
117
119
  * @returns {object[]} an array of objects representing market data
118
120
  */
119
121
  const result = [];
122
+ const OTCresponse = await this.publicGetApiV1CoinsSimpleList();
123
+ const OTCmarkets = this.safeDict(OTCresponse, 'data');
124
+ const OTCmarketList = this.safeList(OTCmarkets, 'results', []);
125
+ for (let i = 0; i < OTCmarketList.length; i++) {
126
+ const marketdata = OTCmarketList[i];
127
+ const market = this.parseOtcMarket(marketdata);
128
+ result.push(market);
129
+ }
120
130
  let page = 1;
121
131
  const limit = 100; // check Bit24 docs for max allowed per page
122
132
  while (true) {
123
- const response = await this.publicGetProV3Markets(this.extend(params, {
133
+ const response = await this.publicGetProCapiV1Markets(this.extend(params, {
124
134
  'page': page,
125
135
  'per_page': limit,
126
136
  }));
@@ -137,7 +147,7 @@ export default class bit24 extends Exchange {
137
147
  }
138
148
  page += 1;
139
149
  }
140
- return result;
150
+ return this.removeDuplicateValues(result);
141
151
  }
142
152
  parseMarket(market) {
143
153
  // {
@@ -185,10 +195,70 @@ export default class bit24 extends Exchange {
185
195
  // last_price: "83669"
186
196
  // }
187
197
  // }
188
- const base_coin = this.safeDict(market, 'base_coin');
189
- let baseId = this.safeString(base_coin, 'symbol');
190
- const quote_coin = this.safeDict(market, 'quote_coin');
191
- let quoteId = this.safeString(quote_coin, 'symbol');
198
+ let baseId = this.safeString(market, 'base_coin_symbol');
199
+ let quoteId = this.safeString(market, 'quote_coin_symbol');
200
+ const base = this.safeCurrencyCode(baseId);
201
+ const quote = this.safeCurrencyCode(quoteId);
202
+ baseId = baseId.toLowerCase();
203
+ quoteId = quoteId.toLowerCase();
204
+ const id = baseId + '-' + quoteId;
205
+ return {
206
+ 'id': id,
207
+ 'symbol': base + '/' + quote,
208
+ 'base': base,
209
+ 'quote': quote,
210
+ 'settle': undefined,
211
+ 'baseId': baseId,
212
+ 'quoteId': quoteId,
213
+ 'settleId': undefined,
214
+ 'type': 'otc',
215
+ 'spot': false,
216
+ 'margin': false,
217
+ 'swap': false,
218
+ 'future': false,
219
+ 'option': false,
220
+ 'active': true,
221
+ 'contract': false,
222
+ 'linear': undefined,
223
+ 'inverse': undefined,
224
+ 'contractSize': undefined,
225
+ 'expiry': undefined,
226
+ 'expiryDatetime': undefined,
227
+ 'strike': undefined,
228
+ 'optionType': undefined,
229
+ 'precision': {
230
+ 'amount': undefined,
231
+ 'price': undefined,
232
+ },
233
+ 'limits': {
234
+ 'leverage': {
235
+ 'min': undefined,
236
+ 'max': undefined,
237
+ },
238
+ 'amount': {
239
+ 'min': undefined,
240
+ 'max': undefined,
241
+ },
242
+ 'price': {
243
+ 'min': undefined,
244
+ 'max': undefined,
245
+ },
246
+ 'cost': {
247
+ 'min': undefined,
248
+ 'max': undefined,
249
+ },
250
+ },
251
+ 'created': undefined,
252
+ 'info': market,
253
+ };
254
+ }
255
+ parseOtcMarket(market) {
256
+ // {
257
+ // symbol: "0G",
258
+ // name: "0G"
259
+ // },
260
+ let baseId = this.safeString(market, 'symbol');
261
+ let quoteId = 'IRT'; // assuming quote currency is always IRT for OTC markets
192
262
  const base = this.safeCurrencyCode(baseId);
193
263
  const quote = this.safeCurrencyCode(quoteId);
194
264
  baseId = baseId.toLowerCase();
@@ -258,11 +328,20 @@ export default class bit24 extends Exchange {
258
328
  if (symbols !== undefined) {
259
329
  symbols = this.marketSymbols(symbols);
260
330
  }
331
+ const result = {};
332
+ const Otcresponse = await this.publicGetApiV1CoinsSimpleList(params);
333
+ const Otcdata = this.safeDict(Otcresponse, 'data', {});
334
+ const OtctickerList = this.safeList(Otcdata, 'results', []);
335
+ for (let i = 0; i < OtctickerList.length; i++) {
336
+ const tickerData = OtctickerList[i];
337
+ const ticker = this.parseOtcTicker(tickerData);
338
+ const symbol = ticker['symbol'];
339
+ result[symbol] = ticker;
340
+ }
261
341
  let page = 1;
262
342
  const limit = 100; // adjust if Bit24 docs show a different default
263
- const result = {};
264
343
  while (true) {
265
- const response = await this.publicGetProV3Markets(this.extend(params, {
344
+ const response = await this.publicGetProCapiV1Markets(this.extend(params, {
266
345
  'page': page,
267
346
  'per_page': limit,
268
347
  }));
@@ -341,21 +420,18 @@ export default class bit24 extends Exchange {
341
420
  // }
342
421
  // },
343
422
  const marketType = 'spot';
344
- const base_coin = this.safeDict(ticker, 'base_coin', {});
345
- let base_symbol = this.safeString(base_coin, 'symbol');
423
+ let base_symbol = this.safeString(ticker, 'base_coin_symbol');
346
424
  base_symbol = base_symbol.toLowerCase();
347
- const quote_coin = this.safeDict(ticker, 'quote_coin', {});
348
- let quote_symbol = this.safeString(quote_coin, 'symbol');
425
+ let quote_symbol = this.safeString(ticker, 'quote_coin_symbol');
349
426
  quote_symbol = quote_symbol.toLowerCase();
350
427
  const marketId = base_symbol + '-' + quote_symbol;
351
428
  const symbol = this.safeSymbol(marketId, market, undefined, marketType);
352
429
  const last = this.safeFloat(ticker, 'each_price', 0);
353
- const markerInfo = this.safeDict(ticker, 'market_24h_information', {});
354
- const change = this.safeFloat(markerInfo, 'change_percent', 0);
355
- const minPrice = this.safeFloat(markerInfo, 'min_price', 0);
356
- const maxPrice = this.safeFloat(markerInfo, 'max_price', 0);
357
- const baseVolume = this.safeFloat(markerInfo, 'base_volume', 0);
358
- const quoteVolume = this.safeFloat(markerInfo, 'quote_volume', 0);
430
+ const change = this.safeFloat(ticker, '24h_change', 0);
431
+ const minPrice = this.safeFloat(ticker, 'min_price', 0);
432
+ const maxPrice = this.safeFloat(ticker, 'max_price', 0);
433
+ const baseVolume = this.safeFloat(ticker, 'base_coin_volume', 0);
434
+ const quoteVolume = this.safeFloat(ticker, 'quote_coin_volume', 0);
359
435
  return this.safeTicker({
360
436
  'symbol': symbol,
361
437
  'timestamp': undefined,
@@ -379,11 +455,65 @@ export default class bit24 extends Exchange {
379
455
  'info': ticker,
380
456
  }, market);
381
457
  }
458
+ parseOtcTicker(ticker, market = undefined) {
459
+ // {
460
+ // symbol: "0G",
461
+ // name: "0G"
462
+ // },
463
+ const marketType = 'otc';
464
+ let base_symbol = this.safeString(ticker, 'symbol');
465
+ base_symbol = base_symbol.toLowerCase();
466
+ const quote_symbol = 'irt'; // assuming quote currency is always IRT for OTC markets
467
+ const marketId = base_symbol + '-' + quote_symbol;
468
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
469
+ return this.safeTicker({
470
+ 'symbol': symbol,
471
+ 'timestamp': undefined,
472
+ 'datetime': undefined,
473
+ 'high': undefined,
474
+ 'low': undefined,
475
+ 'bid': undefined,
476
+ 'bidVolume': undefined,
477
+ 'ask': undefined,
478
+ 'askVolume': undefined,
479
+ 'vwap': undefined,
480
+ 'open': undefined,
481
+ 'close': undefined,
482
+ 'last': undefined,
483
+ 'previousClose': undefined,
484
+ 'change': undefined,
485
+ 'percentage': undefined,
486
+ 'average': undefined,
487
+ 'baseVolume': undefined,
488
+ 'quoteVolume': undefined,
489
+ 'info': ticker,
490
+ }, market);
491
+ }
492
+ async removeDuplicateValues(markets) {
493
+ const uniqueMarkets = [];
494
+ const seenIds = new Set();
495
+ for (let i = 0; i < markets.length; i++) {
496
+ const market = markets[i];
497
+ if (!seenIds.has(market['id'])) {
498
+ seenIds.add(market['id']);
499
+ uniqueMarkets.push(market);
500
+ }
501
+ }
502
+ return uniqueMarkets;
503
+ }
382
504
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
505
+ if (path === 'api/v1/coins/simple-list') {
506
+ api = 'otc';
507
+ }
383
508
  const query = this.omit(params, this.extractParams(path));
384
509
  let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
385
510
  url = url + '?' + this.urlencode(query);
386
- headers = { 'Content-Type': 'application/json' };
511
+ if (api === 'otc') {
512
+ headers = { 'Content-Type': 'application/json' };
513
+ }
514
+ else {
515
+ headers = { 'Content-Type': 'application/json', 'X-BIT24-APIKEY': 'bdfa2c8c971445d5a4a95c95a5a2a4c2' };
516
+ }
387
517
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
388
518
  }
389
519
  }