show reserved balance
This commit is contained in:
parent
5c01969969
commit
a15572c705
@ -597,20 +597,25 @@ 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({
|
currency = {
|
||||||
'currency': coin,
|
'currency': coin,
|
||||||
# TODO: The below can be simplified if we don't assign None to values.
|
# TODO: The below can be simplified if we don't assign None to values.
|
||||||
'free': balance.free if balance.free is not None else 0,
|
'free': balance.free or 0,
|
||||||
'balance': balance.total if balance.total is not None else 0,
|
'balance': balance.total or 0,
|
||||||
'used': balance.used if balance.used is not None else 0,
|
'used': balance.used or 0,
|
||||||
'est_stake': est_stake or 0,
|
'est_stake': est_stake,
|
||||||
'stake': stake_currency,
|
'stake': stake_currency,
|
||||||
'side': 'long',
|
'side': 'long',
|
||||||
'leverage': 1,
|
'leverage': 1,
|
||||||
'position': 0,
|
'position': 0,
|
||||||
'is_position': False,
|
'is_position': False,
|
||||||
})
|
}
|
||||||
|
if coin == stake_currency:
|
||||||
|
currencies.insert(0, currency)
|
||||||
|
else:
|
||||||
|
currencies.append(currency)
|
||||||
|
|
||||||
symbol: str
|
symbol: str
|
||||||
position: PositionWallet
|
position: PositionWallet
|
||||||
for symbol, position in self._freqtrade.wallets.get_all_positions().items():
|
for symbol, position in self._freqtrade.wallets.get_all_positions().items():
|
||||||
@ -633,7 +638,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
|
||||||
|
|
||||||
|
@ -418,7 +418,8 @@ class Telegram(RPCHandler):
|
|||||||
if prev_avg_price:
|
if prev_avg_price:
|
||||||
minus_on_entry = (cur_entry_average - prev_avg_price) / prev_avg_price
|
minus_on_entry = (cur_entry_average - prev_avg_price) / prev_avg_price
|
||||||
|
|
||||||
dur_entry = cur_entry_datetime - arrow.get(filled_orders[x-1]["order_filled_date"])
|
dur_entry = cur_entry_datetime - \
|
||||||
|
arrow.get(filled_orders[x - 1]["order_filled_date"])
|
||||||
days = dur_entry.days
|
days = dur_entry.days
|
||||||
hours, remainder = divmod(dur_entry.seconds, 3600)
|
hours, remainder = divmod(dur_entry.seconds, 3600)
|
||||||
minutes, seconds = divmod(remainder, 60)
|
minutes, seconds = divmod(remainder, 60)
|
||||||
@ -840,7 +841,12 @@ class Telegram(RPCHandler):
|
|||||||
f"*{curr['currency']}:*\n"
|
f"*{curr['currency']}:*\n"
|
||||||
f"\t`Available: {curr['free']:.8f}`\n"
|
f"\t`Available: {curr['free']:.8f}`\n"
|
||||||
f"\t`Balance: {curr['balance']:.8f}`\n"
|
f"\t`Balance: {curr['balance']:.8f}`\n"
|
||||||
f"\t`Pending: {curr['used']:.8f}`\n"
|
f"\t`Pending: {curr['used']:.8f}`\n")
|
||||||
|
if curr['stake'] == curr['stake']:
|
||||||
|
reserved = self._rpc._freqtrade.wallets.get_reserved_stake_amount()
|
||||||
|
curr_output += f"\t`Reserved: {reserved}`\n"
|
||||||
|
else:
|
||||||
|
curr_output += (
|
||||||
f"\t`Est. {curr['stake']}: "
|
f"\t`Est. {curr['stake']}: "
|
||||||
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
||||||
elif curr['est_stake'] <= balance_dust_level:
|
elif curr['est_stake'] <= balance_dust_level:
|
||||||
@ -848,6 +854,7 @@ class Telegram(RPCHandler):
|
|||||||
total_dust_currencies += 1
|
total_dust_currencies += 1
|
||||||
|
|
||||||
# Handle overflowing message length
|
# Handle overflowing message length
|
||||||
|
output = output.replace('\t', ' ' * 4)
|
||||||
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE_LENGTH:
|
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE_LENGTH:
|
||||||
self._send_msg(output)
|
self._send_msg(output)
|
||||||
output = curr_output
|
output = curr_output
|
||||||
@ -872,6 +879,7 @@ class Telegram(RPCHandler):
|
|||||||
f"\t`{result['symbol']}: "
|
f"\t`{result['symbol']}: "
|
||||||
f"{round_coin_value(result['value'], result['symbol'], False)}`"
|
f"{round_coin_value(result['value'], result['symbol'], False)}`"
|
||||||
f"{fiat_val}\n")
|
f"{fiat_val}\n")
|
||||||
|
output = output.replace('\t', ' ' * 4)
|
||||||
self._send_msg(output, reload_able=True, callback_path="update_balance",
|
self._send_msg(output, reload_able=True, callback_path="update_balance",
|
||||||
query=update.callback_query)
|
query=update.callback_query)
|
||||||
except RPCException as e:
|
except RPCException as e:
|
||||||
|
@ -214,6 +214,18 @@ class Wallets:
|
|||||||
self._config['tradable_balance_ratio'])
|
self._config['tradable_balance_ratio'])
|
||||||
return available_amount
|
return available_amount
|
||||||
|
|
||||||
|
def get_reserved_stake_amount(self):
|
||||||
|
"""
|
||||||
|
Return the total currently reserved balance in stake currency.
|
||||||
|
Calculated as
|
||||||
|
(<open_trade stakes> + free amount) - tot_profit - available_capital
|
||||||
|
"""
|
||||||
|
available_capital = self._config.get('available_capital') or 0
|
||||||
|
tot_profit = Trade.get_total_closed_profit()
|
||||||
|
open_stakes = Trade.total_open_trades_stakes()
|
||||||
|
available_balance = self.get_free(self._config['stake_currency'])
|
||||||
|
return available_balance + open_stakes - tot_profit - available_capital
|
||||||
|
|
||||||
def get_available_stake_amount(self) -> float:
|
def get_available_stake_amount(self) -> float:
|
||||||
"""
|
"""
|
||||||
Return the total currently available balance in stake currency,
|
Return the total currently available balance in stake currency,
|
||||||
|
Loading…
Reference in New Issue
Block a user