mirror of
https://git.wownero.com/wowlet/wowlet-backend.git
synced 2024-08-15 01:03:13 +00:00
include satoshi and BTC value in crypto rates
This commit is contained in:
parent
a0bd7573ff
commit
3347306ba6
1 changed files with 16 additions and 5 deletions
|
@ -37,22 +37,33 @@ class CryptoRatesTask(WowletTask):
|
||||||
"price_change_percentage_24h": r["price_change_percentage_24h"]
|
"price_change_percentage_24h": r["price_change_percentage_24h"]
|
||||||
} for r in rates]
|
} for r in rates]
|
||||||
|
|
||||||
|
# limit the list, only include specific coins. see wowlet:src/utils/prices.cpp
|
||||||
|
whitelist = ["XMR", "ZEC", "BTC", "ETH", "BCH", "LTC", "EOS", "ADA", "XLM", "TRX", "DASH", "DCR", "VET", "DOGE", "XRP", "WOW"]
|
||||||
|
rates = [r for r in rates if r["symbol"].upper() in whitelist]
|
||||||
|
|
||||||
# additional coins as defined by `settings.CRYPTO_RATES_COINS_EXTRA`
|
# additional coins as defined by `settings.CRYPTO_RATES_COINS_EXTRA`
|
||||||
for coin, symbol in settings.CRYPTO_RATES_COINS_EXTRA.items():
|
for coin, symbol in settings.CRYPTO_RATES_COINS_EXTRA.items():
|
||||||
url = f"{self._http_api_gecko}/simple/price?ids={coin}&vs_currencies=usd"
|
|
||||||
try:
|
try:
|
||||||
data = await httpget(url, json=True)
|
results = {}
|
||||||
if coin not in data or "usd" not in data[coin]:
|
for vs_currency in ["usd", "btc"]:
|
||||||
continue
|
url = f"{self._http_api_gecko}/simple/price?ids={coin}&vs_currencies={vs_currency}"
|
||||||
|
data = await httpget(url, json=True)
|
||||||
|
results[vs_currency] = data[coin][vs_currency]
|
||||||
|
|
||||||
|
price_btc = "{:.8f}".format(results["btc"])
|
||||||
|
price_sat = int(price_btc.replace(".", "").lstrip("0")) # yolo
|
||||||
|
|
||||||
rates.append({
|
rates.append({
|
||||||
"id": coin,
|
"id": coin,
|
||||||
"symbol": symbol,
|
"symbol": symbol,
|
||||||
"image": "",
|
"image": "",
|
||||||
"name": coin.capitalize(),
|
"name": coin.capitalize(),
|
||||||
"current_price": data[coin]["usd"],
|
"current_price": results["usd"],
|
||||||
|
"current_price_btc": price_btc,
|
||||||
|
"current_price_satoshi": price_sat,
|
||||||
"price_change_percentage_24h": 0.0
|
"price_change_percentage_24h": 0.0
|
||||||
})
|
})
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
app.logger.error(f"extra coin: {coin}; {ex}")
|
app.logger.error(f"extra coin: {coin}; {ex}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue