diff --git a/cefi/main.py b/cefi/main.py index c1869dba..ebe1b7e1 100644 --- a/cefi/main.py +++ b/cefi/main.py @@ -112,7 +112,7 @@ async def get_quotes(self, symbol): quotes.append(f"🏦 {exchange_name}: Error fetching quote - {e}") return "\n".join(quotes) - async def get_quote(cex, symbol): + async def get_quote(self, symbol): """ Return a quote for a symbol of a given exchange ccxt object @@ -125,7 +125,7 @@ async def get_quote(cex, symbol): Returns: quote """ - ticker = cex.fetchTicker(symbol) + ticker = self.fetchTicker(symbol) return ticker.get("last") or "" async def get_account_balances(self): @@ -160,10 +160,9 @@ async def get_account_balance(self, cex): """ raw_balance = cex.fetch_free_balance() - filtered_balance = { + if filtered_balance := { k: v for k, v in raw_balance.items() if v is not None and v > 0 - } - if filtered_balance: + }: balance_str = "".join( f"{iterator}: {value} \n" for iterator, value in filtered_balance.items() @@ -205,8 +204,7 @@ async def get_account_position(self, cex): """ positions = cex.fetch_positions() - positions = [p for p in positions if p["type"] == "open"] - if positions: + if positions := [p for p in positions if p["type"] == "open"]: return f"{positions}" return "No Position"