From 70c10cf6f98bb301137fedcb94689787df88658f Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 15 Nov 2024 10:49:56 +0800 Subject: [PATCH] style: set emoji repeat limit --- pkg/style/pnl.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/style/pnl.go b/pkg/style/pnl.go index 8f9a68edd..6f5345177 100644 --- a/pkg/style/pnl.go +++ b/pkg/style/pnl.go @@ -6,8 +6,12 @@ import ( var LossEmoji = "🔥" var ProfitEmoji = "💰" + +// 0.1% = 10 bps var DefaultPnLLevelResolution = fixedpoint.NewFromFloat(0.001) +const MaxEmojiRepeat = 6 + func PnLColor(pnl fixedpoint.Value) string { if pnl.Sign() > 0 { return GreenColor @@ -41,7 +45,7 @@ func PnLEmojiMargin(pnl, margin, resolution fixedpoint.Value) (out string) { if pnl.Sign() < 0 { out = LossEmoji - level := (margin.Neg()).Div(resolution).Int() + level := max((margin.Neg()).Div(resolution).Int(), MaxEmojiRepeat) for i := 1; i < level; i++ { out += LossEmoji } @@ -53,9 +57,10 @@ func PnLEmojiMargin(pnl, margin, resolution fixedpoint.Value) (out string) { } out = ProfitEmoji - level := margin.Div(resolution).Int() + level := max(margin.Div(resolution).Int(), MaxEmojiRepeat) for i := 1; i < level; i++ { out += ProfitEmoji } + return out }