Merge branch 'develop' into configvalidation
This commit is contained in:
@@ -266,7 +266,11 @@ class FreqtradeBot:
|
||||
amount_reserve_percent += self.strategy.stoploss
|
||||
# it should not be more than 50%
|
||||
amount_reserve_percent = max(amount_reserve_percent, 0.5)
|
||||
return min(min_stake_amounts) / amount_reserve_percent
|
||||
|
||||
# The value returned should satisfy both limits: for amount (base currency) and
|
||||
# for cost (quote, stake currency), so max() is used here.
|
||||
# See also #2575 at github.
|
||||
return max(min_stake_amounts) / amount_reserve_percent
|
||||
|
||||
def create_trades(self) -> bool:
|
||||
"""
|
||||
|
@@ -354,7 +354,8 @@ class ApiServer(RPC):
|
||||
|
||||
Returns the current status of the trades in json format
|
||||
"""
|
||||
results = self._rpc_balance(self._config.get('fiat_display_currency', ''))
|
||||
results = self._rpc_balance(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', ''))
|
||||
return self.rest_dump(results)
|
||||
|
||||
@require_login
|
||||
|
@@ -297,34 +297,42 @@ class RPC:
|
||||
'best_rate': round(bp_rate * 100, 2),
|
||||
}
|
||||
|
||||
def _rpc_balance(self, fiat_display_currency: str) -> Dict:
|
||||
def _rpc_balance(self, stake_currency: str, fiat_display_currency: str) -> Dict:
|
||||
""" Returns current account balance per crypto """
|
||||
output = []
|
||||
total = 0.0
|
||||
for coin, balance in self._freqtrade.exchange.get_balances().items():
|
||||
if not balance['total']:
|
||||
try:
|
||||
tickers = self._freqtrade.exchange.get_tickers()
|
||||
except (TemporaryError, DependencyException):
|
||||
raise RPCException('Error getting current tickers.')
|
||||
|
||||
for coin, balance in self._freqtrade.wallets.get_all_balances().items():
|
||||
if not balance.total:
|
||||
continue
|
||||
|
||||
if coin == 'BTC':
|
||||
est_stake: float = 0
|
||||
if coin == stake_currency:
|
||||
rate = 1.0
|
||||
est_stake = balance.total
|
||||
else:
|
||||
try:
|
||||
pair = self._freqtrade.exchange.get_valid_pair_combination(coin, "BTC")
|
||||
if pair.startswith("BTC"):
|
||||
rate = 1.0 / self._freqtrade.get_sell_rate(pair, False)
|
||||
else:
|
||||
rate = self._freqtrade.get_sell_rate(pair, False)
|
||||
pair = self._freqtrade.exchange.get_valid_pair_combination(coin, stake_currency)
|
||||
rate = tickers.get(pair, {}).get('bid', None)
|
||||
if rate:
|
||||
if pair.startswith(stake_currency):
|
||||
rate = 1.0 / rate
|
||||
est_stake = rate * balance.total
|
||||
except (TemporaryError, DependencyException):
|
||||
logger.warning(f" Could not get rate for pair {coin}.")
|
||||
continue
|
||||
est_btc: float = rate * balance['total']
|
||||
total = total + est_btc
|
||||
total = total + (est_stake or 0)
|
||||
output.append({
|
||||
'currency': coin,
|
||||
'free': balance['free'] if balance['free'] is not None else 0,
|
||||
'balance': balance['total'] if balance['total'] is not None else 0,
|
||||
'used': balance['used'] if balance['used'] is not None else 0,
|
||||
'est_btc': est_btc,
|
||||
'free': balance.free if balance.free is not None else 0,
|
||||
'balance': balance.total if balance.total is not None else 0,
|
||||
'used': balance.used if balance.used is not None else 0,
|
||||
'est_stake': est_stake or 0,
|
||||
'stake': stake_currency,
|
||||
})
|
||||
if total == 0.0:
|
||||
if self._freqtrade.config.get('dry_run', False):
|
||||
|
@@ -325,15 +325,16 @@ class Telegram(RPC):
|
||||
def _balance(self, update: Update, context: CallbackContext) -> None:
|
||||
""" Handler for /balance """
|
||||
try:
|
||||
result = self._rpc_balance(self._config.get('fiat_display_currency', ''))
|
||||
result = self._rpc_balance(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', ''))
|
||||
output = ''
|
||||
for currency in result['currencies']:
|
||||
if currency['est_btc'] > 0.0001:
|
||||
if currency['est_stake'] > 0.0001:
|
||||
curr_output = "*{currency}:*\n" \
|
||||
"\t`Available: {free: .8f}`\n" \
|
||||
"\t`Balance: {balance: .8f}`\n" \
|
||||
"\t`Pending: {used: .8f}`\n" \
|
||||
"\t`Est. BTC: {est_btc: .8f}`\n".format(**currency)
|
||||
"\t`Est. {stake}: {est_stake: .8f}`\n".format(**currency)
|
||||
else:
|
||||
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
""" Wallet """
|
||||
|
||||
import logging
|
||||
from typing import Dict, NamedTuple
|
||||
from typing import Dict, NamedTuple, Any
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade import constants
|
||||
|
||||
@@ -72,3 +72,6 @@ class Wallets:
|
||||
)
|
||||
|
||||
logger.info('Wallets synced.')
|
||||
|
||||
def get_all_balances(self) -> Dict[str, Any]:
|
||||
return self._wallets
|
||||
|
Reference in New Issue
Block a user