pull out side type

This commit is contained in:
c9s 2020-07-11 13:21:23 +08:00
parent d38c3afb40
commit efca619949
2 changed files with 16 additions and 6 deletions

View File

@ -1,17 +1,27 @@
package types
import "github.com/adshao/go-binance"
const Green = "#228B22"
const Red = "#800000"
func SideToColorName(side binance.SideType) string {
if side == binance.SideTypeBuy {
// 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 == binance.SideTypeSell {
if side == SideTypeSell {
return Red
}
return "#f0f0f0"
}
func SideToColorName(side SideType) string {
return side.Color()
}

View File

@ -27,7 +27,7 @@ func (o *Order) SlackAttachment() slack.Attachment {
}
return slack.Attachment{
Color: SideToColorName(o.Side),
Color: SideToColorName(SideType(o.Side)),
Title: string(o.Type) + " Order " + string(o.Side),
// Text: "",
Fields: fields,