diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index a1910b4d3..e80bf3eb8 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -39,6 +39,11 @@ class Balance(BaseModel): used: float est_stake: float stake: str + # Starting with 2.x + side: str + leverage: float + is_position: bool + position: float class Balances(BaseModel): diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 1c0c32846..d151f8aab 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -609,6 +609,10 @@ class RPC: 'used': balance.used if balance.used is not None else 0, 'est_stake': est_stake or 0, 'stake': stake_currency, + 'side': 'long', + 'leverage': 1, + 'position': 0, + 'is_position': False, }) symbol: str position: PositionWallet @@ -617,22 +621,14 @@ class RPC: currencies.append({ 'currency': symbol, 'free': 0, - 'balance': position.position, + 'balance': 0, 'used': 0, - 'est_stake': position.collateral, - 'stake': stake_currency, - }) - - positions.append({ - 'currency': symbol, - # '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, 'position': position.position, - 'side': position.side, 'est_stake': position.collateral, - 'leverage': position.leverage, 'stake': stake_currency, + 'leverage': position.leverage, + 'side': position.side, + 'is_position': True }) value = self._fiat_converter.convert_amount( @@ -645,7 +641,6 @@ class RPC: return { 'currencies': currencies, - 'positions': positions, 'total': total, 'symbol': fiat_display_currency, 'value': value, diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index bfc56d2c7..f11003d52 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -827,13 +827,21 @@ class Telegram(RPCHandler): for curr in result['currencies']: curr_output = '' if curr['est_stake'] > balance_dust_level: - curr_output = ( - f"*{curr['currency']}:*\n" - f"\t`Available: {curr['free']:.8f}`\n" - f"\t`Balance: {curr['balance']:.8f}`\n" - f"\t`Pending: {curr['used']:.8f}`\n" - f"\t`Est. {curr['stake']}: " - f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n") + if curr['is_position']: + curr_output = ( + f"*{curr['currency']}:*\n" + f"\t`{curr['side']}: {curr['position']:.8f}`\n" + f"\t`Leverage: {curr['leverage']:.1f}`\n" + f"\t`Est. {curr['stake']}: " + f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n") + else: + curr_output = ( + f"*{curr['currency']}:*\n" + f"\t`Available: {curr['free']:.8f}`\n" + f"\t`Balance: {curr['balance']:.8f}`\n" + f"\t`Pending: {curr['used']:.8f}`\n" + f"\t`Est. {curr['stake']}: " + f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n") elif curr['est_stake'] <= balance_dust_level: total_dust_balance += curr['est_stake'] total_dust_currencies += 1 diff --git a/freqtrade/wallets.py b/freqtrade/wallets.py index f7ee95b0e..a04602075 100644 --- a/freqtrade/wallets.py +++ b/freqtrade/wallets.py @@ -118,8 +118,10 @@ class Wallets: for currency in deepcopy(self._wallets): if currency not in balances: del self._wallets[currency] + # TODO-lev: Implement dry-run/backtest counterpart positions = self._exchange.get_positions() + self._positions = [] for position in positions: symbol = position['symbol'] if position['side'] is None or position['collateral'] == 0.0: