feat: use helper method to format for pct
This commit is contained in:
@@ -47,6 +47,7 @@ from freqtrade.util import (
|
|||||||
dt_ts,
|
dt_ts,
|
||||||
dt_ts_def,
|
dt_ts_def,
|
||||||
format_date,
|
format_date,
|
||||||
|
format_pct,
|
||||||
shorten_date,
|
shorten_date,
|
||||||
)
|
)
|
||||||
from freqtrade.wallets import PositionWallet, Wallet
|
from freqtrade.wallets import PositionWallet, Wallet
|
||||||
@@ -302,7 +303,7 @@ class RPC:
|
|||||||
fiat_total_profit_sum = nan
|
fiat_total_profit_sum = nan
|
||||||
for trade in self._rpc_trade_status():
|
for trade in self._rpc_trade_status():
|
||||||
# Format profit as a string with the right sign
|
# Format profit as a string with the right sign
|
||||||
profit = f"{trade['profit_ratio']:.2%}"
|
profit = f"{format_pct(trade['profit_ratio'])}"
|
||||||
fiat_profit = trade.get("profit_fiat", None)
|
fiat_profit = trade.get("profit_fiat", None)
|
||||||
if fiat_profit is None or isnan(fiat_profit):
|
if fiat_profit is None or isnan(fiat_profit):
|
||||||
fiat_profit = trade.get("profit_abs", 0.0)
|
fiat_profit = trade.get("profit_abs", 0.0)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ from freqtrade.util import (
|
|||||||
fmt_coin,
|
fmt_coin,
|
||||||
fmt_coin2,
|
fmt_coin2,
|
||||||
format_date,
|
format_date,
|
||||||
|
format_pct,
|
||||||
round_value,
|
round_value,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -800,19 +801,19 @@ class Telegram(RPCHandler):
|
|||||||
else ""
|
else ""
|
||||||
),
|
),
|
||||||
("*Unrealized Profit:* " if r["is_open"] else "*Close Profit: *")
|
("*Unrealized Profit:* " if r["is_open"] else "*Close Profit: *")
|
||||||
+ f"`{r['profit_ratio']:.2%}` `({r['profit_abs_r']})`",
|
+ f"`{format_pct(r['profit_ratio'])}` `({r['profit_abs_r']})`",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
if r["is_open"]:
|
if r["is_open"]:
|
||||||
if r.get("realized_profit"):
|
if r.get("realized_profit"):
|
||||||
lines.append(
|
lines.append(
|
||||||
f"*Realized Profit:* `{r['realized_profit_ratio']:.2%} "
|
f"*Realized Profit:* `{format_pct(r['realized_profit_ratio'])} "
|
||||||
f"({r['realized_profit_r']})`"
|
f"({r['realized_profit_r']})`"
|
||||||
)
|
)
|
||||||
if r.get("total_profit_ratio"):
|
if r.get("total_profit_ratio"):
|
||||||
lines.append(
|
lines.append(
|
||||||
f"*Total Profit:* `{r['total_profit_ratio']:.2%} "
|
f"*Total Profit:* `{format_pct(r['total_profit_ratio'])} "
|
||||||
f"({r['total_profit_abs_r']})`"
|
f"({r['total_profit_abs_r']})`"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -829,17 +830,17 @@ class Telegram(RPCHandler):
|
|||||||
# Adding initial stoploss only if it is different from stoploss
|
# Adding initial stoploss only if it is different from stoploss
|
||||||
lines.append(
|
lines.append(
|
||||||
f"*Initial Stoploss:* `{r['initial_stop_loss_abs']:.8f}` "
|
f"*Initial Stoploss:* `{r['initial_stop_loss_abs']:.8f}` "
|
||||||
f"`({r['initial_stop_loss_ratio']:.2%})`"
|
f"`({format_pct(r['initial_stop_loss_ratio'])})`"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Adding stoploss and stoploss percentage only if it is not None
|
# Adding stoploss and stoploss percentage only if it is not None
|
||||||
lines.append(
|
lines.append(
|
||||||
f"*Stoploss:* `{round_value(r['stop_loss_abs'], 8)}` "
|
f"*Stoploss:* `{round_value(r['stop_loss_abs'], 8)}` "
|
||||||
+ (f"`({r['stop_loss_ratio']:.2%})`" if r["stop_loss_ratio"] else "")
|
+ (f"`({format_pct(r['stop_loss_ratio'])})`" if r["stop_loss_ratio"] else "")
|
||||||
)
|
)
|
||||||
lines.append(
|
lines.append(
|
||||||
f"*Stoploss distance:* `{round_value(r['stoploss_current_dist'], 8)}` "
|
f"*Stoploss distance:* `{round_value(r['stoploss_current_dist'], 8)}` "
|
||||||
f"`({r['stoploss_current_dist_ratio']:.2%})`"
|
f"`({format_pct(r['stoploss_current_dist_ratio'])})`"
|
||||||
)
|
)
|
||||||
if open_orders := r.get("open_orders"):
|
if open_orders := r.get("open_orders"):
|
||||||
lines.append(
|
lines.append(
|
||||||
|
|||||||
Reference in New Issue
Block a user