mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
grid2: add SlackAttachment on grid profit
This commit is contained in:
parent
a6a4be9878
commit
7a35a652c3
|
@ -2,9 +2,13 @@ package grid2
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/slack-go/slack"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/c9s/bbgo/pkg/style"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
)
|
||||
|
||||
|
@ -22,3 +26,23 @@ func (p *GridProfit) String() string {
|
|||
func (p *GridProfit) PlainText() string {
|
||||
return fmt.Sprintf("Grid profit: %f %s @ %s orderID %d", p.Profit.Float64(), p.Currency, p.Time.String(), p.Order.OrderID)
|
||||
}
|
||||
|
||||
func (p *GridProfit) SlackAttachment() slack.Attachment {
|
||||
title := fmt.Sprintf("Grid Profit %s %s", style.PnLSignString(p.Profit), p.Currency)
|
||||
return slack.Attachment{
|
||||
Title: title,
|
||||
Color: "warning",
|
||||
Fields: []slack.AttachmentField{
|
||||
{
|
||||
Title: "OrderID",
|
||||
Value: strconv.FormatUint(p.Order.OrderID, 10),
|
||||
Short: true,
|
||||
},
|
||||
{
|
||||
Title: "Time",
|
||||
Value: p.Time.String(),
|
||||
Short: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user