mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
types: add order status icon for slack
This commit is contained in:
parent
d1c981e0b3
commit
6008aaac5f
|
@ -247,17 +247,14 @@ func (o Order) PlainText() string {
|
||||||
|
|
||||||
func (o Order) SlackAttachment() slack.Attachment {
|
func (o Order) SlackAttachment() slack.Attachment {
|
||||||
var fields = []slack.AttachmentField{
|
var fields = []slack.AttachmentField{
|
||||||
{Title: "Exchange", Value: o.Exchange.String(), Short: true},
|
|
||||||
{Title: "Symbol", Value: o.Symbol, Short: true},
|
{Title: "Symbol", Value: o.Symbol, Short: true},
|
||||||
{Title: "Side", Value: string(o.Side), Short: true},
|
{Title: "Side", Value: string(o.Side), Short: true},
|
||||||
{Title: "Quantity", Value: trimTrailingZeroFloat(o.Quantity), Short: true},
|
{Title: "Price", Value: trimTrailingZeroFloat(o.Price), Short: true},
|
||||||
{Title: "Executed Quantity", Value: trimTrailingZeroFloat(o.ExecutedQuantity), Short: true},
|
{
|
||||||
}
|
Title: "Executed Quantity",
|
||||||
|
Value: trimTrailingZeroFloat(o.ExecutedQuantity) + "/" + trimTrailingZeroFloat(o.Quantity),
|
||||||
if len(o.PriceString) > 0 {
|
Short: true,
|
||||||
fields = append(fields, slack.AttachmentField{Title: "Price", Value: o.PriceString, Short: true})
|
},
|
||||||
} else {
|
|
||||||
fields = append(fields, slack.AttachmentField{Title: "Price", Value: trimTrailingZeroFloat(o.Price), Short: true})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fields = append(fields, slack.AttachmentField{
|
fields = append(fields, slack.AttachmentField{
|
||||||
|
@ -266,9 +263,23 @@ func (o Order) SlackAttachment() slack.Attachment {
|
||||||
Short: true,
|
Short: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
orderStatusIcon := ""
|
||||||
|
|
||||||
|
switch o.Status {
|
||||||
|
case OrderStatusNew:
|
||||||
|
orderStatusIcon = ":new:"
|
||||||
|
case OrderStatusCanceled:
|
||||||
|
orderStatusIcon = ":eject:"
|
||||||
|
case OrderStatusPartiallyFilled:
|
||||||
|
orderStatusIcon = ":arrow_forward:"
|
||||||
|
case OrderStatusFilled:
|
||||||
|
orderStatusIcon = ":white_check_mark:"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fields = append(fields, slack.AttachmentField{
|
fields = append(fields, slack.AttachmentField{
|
||||||
Title: "Status",
|
Title: "Status",
|
||||||
Value: string(o.Status),
|
Value: string(o.Status) + " " + orderStatusIcon,
|
||||||
Short: true,
|
Short: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user