Improve status table for position adjust

don't show "/max" if no maximum is set

closes #6317
This commit is contained in:
Matthias 2022-01-29 14:25:33 +01:00
parent e7409e74c2
commit d1d520769e
2 changed files with 8 additions and 2 deletions

View File

@ -252,9 +252,11 @@ class RPC:
profit_str profit_str
] ]
if self._config.get('position_adjustment_enable', False): if self._config.get('position_adjustment_enable', False):
max_buy = self._config['max_entry_position_adjustment'] + 1 max_buy_str = ''
if self._config.get('max_entry_position_adjustment', -1) > 0:
max_buy_str = f"/{self._config['max_entry_position_adjustment'] + 1}"
filled_buys = trade.nr_of_successful_buys filled_buys = trade.nr_of_successful_buys
detail_trade.append(f"{filled_buys}/{max_buy}") detail_trade.append(f"{filled_buys}{max_buy_str}")
trades_list.append(detail_trade) trades_list.append(detail_trade)
profitcol = "Profit" profitcol = "Profit"
if self._fiat_converter: if self._fiat_converter:

View File

@ -221,9 +221,13 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
assert '-0.06' == f'{fiat_profit_sum:.2f}' assert '-0.06' == f'{fiat_profit_sum:.2f}'
rpc._config['position_adjustment_enable'] = True rpc._config['position_adjustment_enable'] = True
rpc._config['max_entry_position_adjustment'] = 3
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD') result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
assert "# Buys" in headers assert "# Buys" in headers
assert len(result[0]) == 5 assert len(result[0]) == 5
# 4th column should be 1/4 - as 1 order filled (a total of 4 is possible)
# 3 on top of the initial one.
assert result[0][4] == '1/4'
mocker.patch('freqtrade.exchange.Exchange.get_rate', mocker.patch('freqtrade.exchange.Exchange.get_rate',
MagicMock(side_effect=ExchangeError("Pair 'ETH/BTC' not available"))) MagicMock(side_effect=ExchangeError("Pair 'ETH/BTC' not available")))