@icgio/icg-utils 1.9.15 → 1.9.16
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/lib/crypto-rates.js +26 -0
- package/package.json +1 -1
package/lib/crypto-rates.js
CHANGED
|
@@ -392,6 +392,32 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
392
392
|
console.error(pair, error)
|
|
393
393
|
}
|
|
394
394
|
})
|
|
395
|
+
} else if (exchange === 'weex') {
|
|
396
|
+
let pair = cur.toUpperCase() + 'USDT'
|
|
397
|
+
let url = `https://contract-openapi.weex.com/api/spot/v1/market/depth?symbol=${pair}_spbl&type=step0`
|
|
398
|
+
limiter.process(needle.get, url, (err, res, body) => {
|
|
399
|
+
try {
|
|
400
|
+
const asks = body.data.asks
|
|
401
|
+
const bids = body.data.bids
|
|
402
|
+
let rate = (parseFloat(asks[0][0]) + parseFloat(bids[0][0])) / 2
|
|
403
|
+
result[cur] = {
|
|
404
|
+
USD: rate,
|
|
405
|
+
USDT: rate,
|
|
406
|
+
}
|
|
407
|
+
let result_length = _.keys(result).length
|
|
408
|
+
if (result_length === length) {
|
|
409
|
+
for (let stable of stablecoins) {
|
|
410
|
+
result[stable] = {
|
|
411
|
+
USD: 1,
|
|
412
|
+
USDT: 1,
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
cb(result)
|
|
416
|
+
}
|
|
417
|
+
} catch (error) {
|
|
418
|
+
console.error(pair, error)
|
|
419
|
+
}
|
|
420
|
+
})
|
|
395
421
|
} else if (exchange === 'xt') {
|
|
396
422
|
let pair = cur.toLowerCase() + '_usdt'
|
|
397
423
|
let url = `https://sapi.xt.com/v4/public/depth?symbol=${pair}&limit=20`
|