Some more fixes to % formatting
This commit is contained in:
		| @@ -284,10 +284,10 @@ class HyperoptTools(): | ||||
|         return (f"{results_metrics['total_trades']:6d} trades. " | ||||
|                 f"{results_metrics['wins']}/{results_metrics['draws']}" | ||||
|                 f"/{results_metrics['losses']} Wins/Draws/Losses. " | ||||
|                 f"Avg profit {results_metrics['profit_mean'] * 100: 6.2f}%. " | ||||
|                 f"Median profit {results_metrics['profit_median'] * 100: 6.2f}%. " | ||||
|                 f"Total profit {results_metrics['profit_total_abs']: 11.8f} {stake_currency} " | ||||
|                 f"({results_metrics['profit_total'] * 100: 7.2f}%). " | ||||
|                 f"Avg profit {results_metrics['profit_mean']:7.2%}. " | ||||
|                 f"Median profit {results_metrics['profit_median']:7.2%}. " | ||||
|                 f"Total profit {results_metrics['profit_total_abs']:11.8f} {stake_currency} " | ||||
|                 f"({results_metrics['profit_total']:8.2%}). " | ||||
|                 f"Avg duration {results_metrics['holding_avg']} min." | ||||
|                 ) | ||||
|  | ||||
|   | ||||
| @@ -725,7 +725,7 @@ def text_table_add_metrics(strat_results: Dict) -> str: | ||||
|                                                strat_results['stake_currency'])), | ||||
|             ('Absolute profit ', round_coin_value(strat_results['profit_total_abs'], | ||||
|                                                   strat_results['stake_currency'])), | ||||
|             ('Total profit %', f"{round(strat_results['profit_total'] * 100, 2)}%"), | ||||
|             ('Total profit %', f"{strat_results['profit_total']:.2%}"), | ||||
|             ('Trades per day', strat_results['trades_per_day']), | ||||
|             ('Avg. daily profit %', | ||||
|              f"{round(strat_results['profit_total'] / strat_results['backtest_days'] * 100, 2)}%"), | ||||
| @@ -738,9 +738,9 @@ def text_table_add_metrics(strat_results: Dict) -> str: | ||||
|                           f"{round(strat_results['best_pair']['profit_sum_pct'], 2)}%"), | ||||
|             ('Worst Pair', f"{strat_results['worst_pair']['key']} " | ||||
|                            f"{round(strat_results['worst_pair']['profit_sum_pct'], 2)}%"), | ||||
|             ('Best trade', f"{best_trade['pair']} {round(best_trade['profit_ratio'] * 100, 2)}%"), | ||||
|             ('Best trade', f"{best_trade['pair']} {best_trade['profit_ratio']:.2%}"), | ||||
|             ('Worst trade', f"{worst_trade['pair']} " | ||||
|                             f"{round(worst_trade['profit_ratio'] * 100, 2)}%"), | ||||
|                             f"{worst_trade['profit_ratio']:.2%}"), | ||||
|  | ||||
|             ('Best day', round_coin_value(strat_results['backtest_best_day_abs'], | ||||
|                                           strat_results['stake_currency'])), | ||||
| @@ -758,7 +758,7 @@ def text_table_add_metrics(strat_results: Dict) -> str: | ||||
|             ('Max balance', round_coin_value(strat_results['csum_max'], | ||||
|                                              strat_results['stake_currency'])), | ||||
|  | ||||
|             ('Drawdown', f"{round(strat_results['max_drawdown'] * 100, 2)}%"), | ||||
|             ('Drawdown', f"{strat_results['max_drawdown']:.2%}"), | ||||
|             ('Drawdown', round_coin_value(strat_results['max_drawdown_abs'], | ||||
|                                           strat_results['stake_currency'])), | ||||
|             ('Drawdown high', round_coin_value(strat_results['max_drawdown_high'], | ||||
| @@ -767,7 +767,7 @@ def text_table_add_metrics(strat_results: Dict) -> str: | ||||
|                                               strat_results['stake_currency'])), | ||||
|             ('Drawdown Start', strat_results['drawdown_start']), | ||||
|             ('Drawdown End', strat_results['drawdown_end']), | ||||
|             ('Market change', f"{round(strat_results['market_change'] * 100, 2)}%"), | ||||
|             ('Market change', f"{strat_results['market_change']:.2%}"), | ||||
|         ] | ||||
|  | ||||
|         return tabulate(metrics, headers=["Metric", "Value"], tablefmt="orgtbl") | ||||
|   | ||||
| @@ -972,6 +972,7 @@ class Trade(_DECL_BASE, LocalTrade): | ||||
|                 if not any(item["mix_tag"] == mix_tag for item in return_list): | ||||
|                     return_list.append({'mix_tag': mix_tag, | ||||
|                                         'profit': profit, | ||||
|                                         'profit_pct': round(profit * 100, 2), | ||||
|                                         'profit_abs': profit_abs, | ||||
|                                         'count': count}) | ||||
|                 else: | ||||
| @@ -980,11 +981,11 @@ class Trade(_DECL_BASE, LocalTrade): | ||||
|                             return_list[i] = { | ||||
|                                 'mix_tag': mix_tag, | ||||
|                                 'profit': profit + return_list[i]["profit"], | ||||
|                                 'profit_pct': round(profit + return_list[i]["profit"] * 100, 2), | ||||
|                                 'profit_abs': profit_abs + return_list[i]["profit_abs"], | ||||
|                                 'count': 1 + return_list[i]["count"]} | ||||
|                         i += 1 | ||||
|  | ||||
|         [x.update({'profit': round(x['profit'] * 100, 2)}) for x in return_list] | ||||
|         return return_list | ||||
|  | ||||
|     @staticmethod | ||||
|   | ||||
| @@ -169,8 +169,8 @@ def add_max_drawdown(fig, row, trades: pd.DataFrame, df_comb: pd.DataFrame, | ||||
|                 df_comb.loc[timeframe_to_prev_date(timeframe, lowdate), 'cum_profit'], | ||||
|             ], | ||||
|             mode='markers', | ||||
|             name=f"Max drawdown {max_drawdown * 100:.2f}%", | ||||
|             text=f"Max drawdown {max_drawdown * 100:.2f}%", | ||||
|             name=f"Max drawdown {max_drawdown:.2%}", | ||||
|             text=f"Max drawdown {max_drawdown:.2%}", | ||||
|             marker=dict( | ||||
|                 symbol='square-open', | ||||
|                 size=9, | ||||
|   | ||||
| @@ -82,7 +82,7 @@ class PriceFilter(IPairList): | ||||
|             changeperc = compare / ticker['last'] | ||||
|             if changeperc > self._low_price_ratio: | ||||
|                 self.log_once(f"Removed {pair} from whitelist, " | ||||
|                               f"because 1 unit is {changeperc * 100:.3f}%", logger.info) | ||||
|                               f"because 1 unit is {changeperc:.3%}", logger.info) | ||||
|                 return False | ||||
|  | ||||
|         # Perform low_amount check | ||||
|   | ||||
| @@ -47,7 +47,7 @@ class SpreadFilter(IPairList): | ||||
|             spread = 1 - ticker['bid'] / ticker['ask'] | ||||
|             if spread > self._max_spread_ratio: | ||||
|                 self.log_once(f"Removed {pair} from whitelist, because spread " | ||||
|                               f"{spread * 100:.3f}% > {self._max_spread_ratio * 100}%", | ||||
|                               f"{spread * 100:.3%} > {self._max_spread_ratio:.3%}", | ||||
|                               logger.info) | ||||
|                 return False | ||||
|             else: | ||||
|   | ||||
| @@ -224,9 +224,8 @@ class RPC: | ||||
|                         trade.pair, refresh=False, side="sell") | ||||
|                 except (PricingError, ExchangeError): | ||||
|                     current_rate = NAN | ||||
|                 trade_percent = (100 * trade.calc_profit_ratio(current_rate)) | ||||
|                 trade_profit = trade.calc_profit(current_rate) | ||||
|                 profit_str = f'{trade_percent:.2f}%' | ||||
|                 profit_str = f'{trade.calc_profit_ratio(current_rate):.2%}' | ||||
|                 if self._fiat_converter: | ||||
|                     fiat_profit = self._fiat_converter.convert_amount( | ||||
|                         trade_profit, | ||||
|   | ||||
| @@ -765,7 +765,7 @@ class IStrategy(ABC, HyperStrategyMixin): | ||||
|                 if self.trailing_stop_positive is not None and high_profit > sl_offset: | ||||
|                     stop_loss_value = self.trailing_stop_positive | ||||
|                     logger.debug(f"{trade.pair} - Using positive stoploss: {stop_loss_value} " | ||||
|                                  f"offset: {sl_offset:.4g} profit: {current_profit:.4f}%") | ||||
|                                  f"offset: {sl_offset:.4g} profit: {current_profit:.2%}") | ||||
|  | ||||
|                 trade.adjust_stop_loss(high or current_rate, stop_loss_value) | ||||
|  | ||||
|   | ||||
| @@ -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: | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user