rssnyder / discord-stock-ticker

Add live stock & crypto prices to your discord sidebar.
https://rssnyder.github.io/discord-stock-ticker/
MIT License
293 stars 113 forks source link

[NEW STOCK] Get currency from CoinGecko API #97

Closed RodrigoNFT closed 2 months ago

RodrigoNFT commented 2 years ago

My suggestion is to get the price for cryptocurrencies in other currencies directly via CoinGecko API, instead of converting via Yahoo Finance. I know that a few thousandths of a cent in the price doesn't make a difference, but the members of my Discord always question me that Bot's price is different from Coingecko.

0.3745 -2.12% slp_brl_3


https://www.coingecko.com/en/coins/smooth-love-potion/brl

0.379154 -1.2% slp_brl_1


https://api.coingecko.com/api/v3/simple/price?ids=smooth-love-potion&vs_currencies=brl&include_24hr_change=true

0.379154 -1.2% slp_brl_2


https://api.coingecko.com/api/v3/simple/supported_vs_currencies

["btc","eth","ltc","bch","bnb","eos","xrp","xlm","link","dot","yfi","usd","aed","ars","aud","bdt","bhd","bmd","brl","cad","chf","clp","cny","czk","dkk","eur","gbp","hkd","huf","idr","ils","inr","jpy","krw","kwd","lkr","mmk","mxn","myr","ngn","nok","nzd","php","pkr","pln","rub","sar","sek","sgd","thb","try","twd","uah","vef","vnd","zar","xdr","xag","xau","bits","sats"]

rssnyder commented 2 years ago

Yeah I've always known this was the "right" way to do it.

To accomplish this we will first have to add all the currencies to https://github.com/rssnyder/coingecko-cache, and then update the utils/coin_gecko.go file to take in the target currency.

This would be an easy but time consuming feature, I will get to it some day.