mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
style: set emoji repeat limit
This commit is contained in:
parent
838efe8295
commit
70c10cf6f9
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user