Merge pull request #5879 from freqtrade/improve_pct_formatting

Improve pct formatting
This commit is contained in:
Matthias
2021-11-11 19:30:55 +01:00
committed by GitHub
16 changed files with 63 additions and 60 deletions

View File

@@ -1004,7 +1004,7 @@ def test_mix_tag_performance_handle(default_conf, ticker, limit_buy_order, fee,
assert len(res) == 1
assert res[0]['mix_tag'] == 'Other Other'
assert res[0]['count'] == 1
assert prec_satoshi(res[0]['profit'], 6.2)
assert prec_satoshi(res[0]['profit_pct'], 6.2)
trade.buy_tag = "TESTBUY"
trade.sell_reason = "TESTSELL"
@@ -1013,7 +1013,7 @@ def test_mix_tag_performance_handle(default_conf, ticker, limit_buy_order, fee,
assert len(res) == 1
assert res[0]['mix_tag'] == 'TESTBUY TESTSELL'
assert res[0]['count'] == 1
assert prec_satoshi(res[0]['profit'], 6.2)
assert prec_satoshi(res[0]['profit_pct'], 6.2)
def test_mix_tag_performance_handle_2(mocker, default_conf, markets, fee):
@@ -1032,10 +1032,10 @@ def test_mix_tag_performance_handle_2(mocker, default_conf, markets, fee):
assert len(res) == 2
assert res[0]['mix_tag'] == 'TEST1 sell_signal'
assert res[0]['count'] == 1
assert prec_satoshi(res[0]['profit'], 0.5)
assert prec_satoshi(res[0]['profit_pct'], 0.5)
assert res[1]['mix_tag'] == 'Other roi'
assert res[1]['count'] == 1
assert prec_satoshi(res[1]['profit'], 1.0)
assert prec_satoshi(res[1]['profit_pct'], 1.0)
# Test for a specific pair
res = rpc._rpc_mix_tag_performance('ETC/BTC')
@@ -1043,7 +1043,7 @@ def test_mix_tag_performance_handle_2(mocker, default_conf, markets, fee):
assert len(res) == 1
assert res[0]['count'] == 1
assert res[0]['mix_tag'] == 'TEST1 sell_signal'
assert prec_satoshi(res[0]['profit'], 0.5)
assert prec_satoshi(res[0]['profit_pct'], 0.5)
def test_rpc_count(mocker, default_conf, ticker, fee) -> None:

View File

@@ -717,6 +717,7 @@ def test_api_profit(botclient, mocker, ticker, fee, markets):
assert rc.json() == {'avg_duration': ANY,
'best_pair': 'XRP/BTC',
'best_rate': 1.0,
'best_pair_profit_ratio': 0.01,
'first_trade_date': ANY,
'first_trade_timestamp': ANY,
'latest_trade_date': '5 minutes ago',

View File

@@ -189,16 +189,16 @@ def test_telegram_status(default_conf, update, mocker) -> None:
'amount': 90.99181074,
'stake_amount': 90.99181074,
'buy_tag': None,
'close_profit_pct': None,
'close_profit_ratio': None,
'profit': -0.0059,
'profit_pct': -0.59,
'profit_ratio': -0.0059,
'initial_stop_loss_abs': 1.098e-05,
'stop_loss_abs': 1.099e-05,
'sell_order_status': None,
'initial_stop_loss_pct': -0.05,
'initial_stop_loss_ratio': -0.0005,
'stoploss_current_dist': 1e-08,
'stoploss_current_dist_pct': -0.02,
'stop_loss_pct': -0.01,
'stoploss_current_dist_ratio': -0.0002,
'stop_loss_ratio': -0.0001,
'open_order': '(limit buy rem=0.00000000)',
'is_open': True
}]),

View File

@@ -3352,7 +3352,7 @@ def test_trailing_stop_loss_positive(
)
# stop-loss not reached, adjusted stoploss
assert freqtrade.handle_trade(trade) is False
caplog_text = f"ETH/USDT - Using positive stoploss: 0.01 offset: {offset} profit: 0.0249%"
caplog_text = f"ETH/USDT - Using positive stoploss: 0.01 offset: {offset} profit: 2.49%"
if trail_if_reached:
assert not log_has(caplog_text, caplog)
assert not log_has("ETH/USDT - Adjusting stoploss...", caplog)
@@ -3372,7 +3372,7 @@ def test_trailing_stop_loss_positive(
)
assert freqtrade.handle_trade(trade) is False
assert log_has(
f"ETH/USDT - Using positive stoploss: 0.01 offset: {offset} profit: 0.0572%",
f"ETH/USDT - Using positive stoploss: 0.01 offset: {offset} profit: 5.72%",
caplog
)
assert log_has("ETH/USDT - Adjusting stoploss...", caplog)

View File

@@ -171,7 +171,7 @@ def test_plot_trades(testdatadir, caplog):
assert len(trades) == len(trade_buy.x)
assert trade_buy.marker.color == 'cyan'
assert trade_buy.marker.symbol == 'circle-open'
assert trade_buy.text[0] == '4.0%, roi, 15 min'
assert trade_buy.text[0] == '3.99%, roi, 15 min'
trade_sell = find_trace_in_fig_data(figure.data, 'Sell - Profit')
assert isinstance(trade_sell, go.Scatter)
@@ -179,7 +179,7 @@ def test_plot_trades(testdatadir, caplog):
assert len(trades.loc[trades['profit_ratio'] > 0]) == len(trade_sell.x)
assert trade_sell.marker.color == 'green'
assert trade_sell.marker.symbol == 'square-open'
assert trade_sell.text[0] == '4.0%, roi, 15 min'
assert trade_sell.text[0] == '3.99%, roi, 15 min'
trade_sell_loss = find_trace_in_fig_data(figure.data, 'Sell - Loss')
assert isinstance(trade_sell_loss, go.Scatter)
@@ -187,7 +187,7 @@ def test_plot_trades(testdatadir, caplog):
assert len(trades.loc[trades['profit_ratio'] <= 0]) == len(trade_sell_loss.x)
assert trade_sell_loss.marker.color == 'red'
assert trade_sell_loss.marker.symbol == 'square-open'
assert trade_sell_loss.text[5] == '-10.4%, stop_loss, 720 min'
assert trade_sell_loss.text[5] == '-10.45%, stop_loss, 720 min'
def test_generate_candlestick_graph_no_signals_no_trades(default_conf, mocker, testdatadir, caplog):