Improve some formatting and typehints

This commit is contained in:
Matthias 2022-06-15 20:03:36 +02:00
parent ec40e79362
commit f9e2e87346

View File

@ -512,7 +512,7 @@ class RPC:
def _rpc_balance(self, stake_currency: str, fiat_display_currency: str) -> Dict: def _rpc_balance(self, stake_currency: str, fiat_display_currency: str) -> Dict:
""" Returns current account balance per crypto """ """ Returns current account balance per crypto """
currencies = [] currencies: List[Dict] = []
total = 0.0 total = 0.0
try: try:
tickers = self._freqtrade.exchange.get_tickers(cached=True) tickers = self._freqtrade.exchange.get_tickers(cached=True)
@ -547,13 +547,12 @@ class RPC:
except (ExchangeError): except (ExchangeError):
logger.warning(f" Could not get rate for pair {coin}.") logger.warning(f" Could not get rate for pair {coin}.")
continue continue
total = total + (est_stake or 0) total = total + est_stake
currencies.append({ currencies.append({
'currency': coin, 'currency': coin,
# TODO: The below can be simplified if we don't assign None to values. 'free': balance.free,
'free': balance.free if balance.free is not None else 0, 'balance': balance.total,
'balance': balance.total if balance.total is not None else 0, 'used': balance.used,
'used': balance.used if balance.used is not None else 0,
'est_stake': est_stake or 0, 'est_stake': est_stake or 0,
'stake': stake_currency, 'stake': stake_currency,
'side': 'long', 'side': 'long',
@ -583,7 +582,6 @@ class RPC:
total, stake_currency, fiat_display_currency) if self._fiat_converter else 0 total, stake_currency, fiat_display_currency) if self._fiat_converter else 0
trade_count = len(Trade.get_trades_proxy()) trade_count = len(Trade.get_trades_proxy())
starting_capital_ratio = 0.0
starting_capital_ratio = (total / starting_capital) - 1 if starting_capital else 0.0 starting_capital_ratio = (total / starting_capital) - 1 if starting_capital else 0.0
starting_cap_fiat_ratio = (value / starting_cap_fiat) - 1 if starting_cap_fiat else 0.0 starting_cap_fiat_ratio = (value / starting_cap_fiat) - 1 if starting_cap_fiat else 0.0