mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
style: set emoji repeat limit
This commit is contained in:
parent
838efe8295
commit
70c10cf6f9
|
@ -6,8 +6,12 @@ import (
|
||||||
|
|
||||||
var LossEmoji = "🔥"
|
var LossEmoji = "🔥"
|
||||||
var ProfitEmoji = "💰"
|
var ProfitEmoji = "💰"
|
||||||
|
|
||||||
|
// 0.1% = 10 bps
|
||||||
var DefaultPnLLevelResolution = fixedpoint.NewFromFloat(0.001)
|
var DefaultPnLLevelResolution = fixedpoint.NewFromFloat(0.001)
|
||||||
|
|
||||||
|
const MaxEmojiRepeat = 6
|
||||||
|
|
||||||
func PnLColor(pnl fixedpoint.Value) string {
|
func PnLColor(pnl fixedpoint.Value) string {
|
||||||
if pnl.Sign() > 0 {
|
if pnl.Sign() > 0 {
|
||||||
return GreenColor
|
return GreenColor
|
||||||
|
@ -41,7 +45,7 @@ func PnLEmojiMargin(pnl, margin, resolution fixedpoint.Value) (out string) {
|
||||||
|
|
||||||
if pnl.Sign() < 0 {
|
if pnl.Sign() < 0 {
|
||||||
out = LossEmoji
|
out = LossEmoji
|
||||||
level := (margin.Neg()).Div(resolution).Int()
|
level := max((margin.Neg()).Div(resolution).Int(), MaxEmojiRepeat)
|
||||||
for i := 1; i < level; i++ {
|
for i := 1; i < level; i++ {
|
||||||
out += LossEmoji
|
out += LossEmoji
|
||||||
}
|
}
|
||||||
|
@ -53,9 +57,10 @@ func PnLEmojiMargin(pnl, margin, resolution fixedpoint.Value) (out string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
out = ProfitEmoji
|
out = ProfitEmoji
|
||||||
level := margin.Div(resolution).Int()
|
level := max(margin.Div(resolution).Int(), MaxEmojiRepeat)
|
||||||
for i := 1; i < level; i++ {
|
for i := 1; i < level; i++ {
|
||||||
out += ProfitEmoji
|
out += ProfitEmoji
|
||||||
}
|
}
|
||||||
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user