On Tue, Mar 16, 2021 at 01:45:34PM -0700, [email protected] wrote:
> I am trying to loop through different crypto prices with the api calls, so 
> i can keep track on my portfolio with the widget.
> 
> It works sometimes, but at some point the widget just freezes and I have to 
> restart qtile. This may lead to the widget disappearing.
> 
> Here is the code I put for the poll function:
> 
> ```
> def get_crypto():
>     cryptos = dict(
>         btc="bitcoin",
>         eth="ethereum",
>         bnb="binancecoin",
>         ada="cardano",
>         cro="crypto-com-chain",
>         nexo="nexo",
>         cake="pancakeswap-token",
>         bifi="beefy-finance",
>         watch="yieldwatch",
>         kebab="kebab-token",
>         bdo="bdollar",
>         salt="saltswap",
>     )
> 
>     try:
>         cg = coingeckoapi()
>         symbol = list(cryptos.keys())[datetime.datetime.now().minute % 
> len(cryptos)]
>         crypto = cryptos[symbol]
> 
>         price = cg.get_price(
>             ids=crypto, vs_currencies="hkd", include_24hr_change="true"
>         )
>         price, change = price[crypto]["hkd"], 
> price[crypto]["hkd_24h_change"]
>         if change > 0:
>             change = "+" + str(round(change, 1)) + "%"
>             return symbol.upper() + ":$" + str(price) + " " + change

Here, you do not return anything. Python defaults to returning None if
nothing was explicitly returned. Presumably it stops when there are no
price changes.

>     except exception:
>         return "error {}".format(crypto)
> 
> ```
> 
> I think this is fairly straight forward and I set the time_interval to 60.
> Any suggestions? thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "qtile-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/qtile-dev/3c2964b2-95c8-4566-a603-92271f320068n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/20210316211130.GA3660639%40cisco.

Reply via email to