add color.go

This commit is contained in:
c9s 2020-07-11 15:00:35 +08:00
parent efca619949
commit 1c99ca52cb
2 changed files with 24 additions and 22 deletions

View File

@ -3,25 +3,3 @@ package types
const Green = "#228B22"
const Red = "#800000"
// SideType define side type of order
type SideType string
const (
SideTypeBuy = SideType("BUY")
SideTypeSell = SideType("SELL")
)
func (side SideType) Color() string {
if side == SideTypeBuy {
return Green
}
if side == SideTypeSell {
return Red
}
return "#f0f0f0"
}
func SideToColorName(side SideType) string {
return side.Color()
}

24
types/side.go Normal file
View File

@ -0,0 +1,24 @@
package types
// SideType define side type of order
type SideType string
const (
SideTypeBuy = SideType("BUY")
SideTypeSell = SideType("SELL")
)
func (side SideType) Color() string {
if side == SideTypeBuy {
return Green
}
if side == SideTypeSell {
return Red
}
return "#f0f0f0"
}
func SideToColorName(side SideType) string {
return side.Color()
}