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