bbgo_origin/bbgo/order.go

45 lines
817 B
Go
Raw Normal View History

package bbgo
2020-06-19 01:30:27 +00:00
import (
"github.com/adshao/go-binance"
"github.com/slack-go/slack"
)
const Green = "#228B22"
const Red = "#800000"
type Order struct {
Symbol string
Side binance.SideType
Type binance.OrderType
VolumeStr string
PriceStr string
TimeInForce binance.TimeInForceType
}
2020-06-19 01:30:27 +00:00
func (o *Order) SlackAttachment() slack.Attachment {
return slack.Attachment{
Color: SideToColorName(o.Side),
Title: "Market Order " + string(o.Side),
// Text: "",
Fields: []slack.AttachmentField{
{Title: "Side", Value: string(o.Side), Short: true,},
{Title: "Volume", Value: o.VolumeStr, Short: true,},
},
}
}
func SideToColorName(side binance.SideType) string {
if side == binance.SideTypeBuy {
return Green
}
if side == binance.SideTypeSell {
return Red
}
return "#f0f0f0"
}