get tickers only once to show balance

This commit is contained in:
Matthias 2019-11-14 07:01:23 +01:00
parent cc0a733f1f
commit 8c64be3cfd

View File

@ -301,6 +301,7 @@ class RPC:
""" Returns current account balance per crypto """ """ Returns current account balance per crypto """
output = [] output = []
total = 0.0 total = 0.0
tickers = self._freqtrade.exchange.get_tickers()
for coin, balance in self._freqtrade.exchange.get_balances().items(): for coin, balance in self._freqtrade.exchange.get_balances().items():
if not balance['total']: if not balance['total']:
continue continue
@ -310,10 +311,11 @@ class RPC:
else: else:
try: try:
pair = self._freqtrade.exchange.get_valid_pair_combination(coin, "BTC") pair = self._freqtrade.exchange.get_valid_pair_combination(coin, "BTC")
if pair.startswith("BTC"): if pair.startswith("BTC"):
rate = 1.0 / self._freqtrade.get_sell_rate(pair, False) rate = 1.0 / tickers.get(pair, {}).get('bid', 1)
else: else:
rate = self._freqtrade.get_sell_rate(pair, False) rate = tickers.get(pair, {}).get('bid', 1)
except (TemporaryError, DependencyException): except (TemporaryError, DependencyException):
logger.warning(f" Could not get rate for pair {coin}.") logger.warning(f" Could not get rate for pair {coin}.")
continue continue