mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
xfunding: add SlackAttachment method support on profit stats
This commit is contained in:
parent
4d59edc3d1
commit
6f961556d7
|
@ -4,7 +4,10 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/slack-go/slack"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/c9s/bbgo/pkg/style"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
)
|
||||
|
||||
|
@ -18,6 +21,20 @@ type ProfitStats struct {
|
|||
LastFundingFeeTime time.Time `json:"lastFundingFeeTime"`
|
||||
}
|
||||
|
||||
func (s *ProfitStats) SlackAttachment() slack.Attachment {
|
||||
var fields []slack.AttachmentField
|
||||
var totalProfit = fmt.Sprintf("Total Funding Fee Profit: %s %s", style.PnLSignString(s.TotalFundingFee), s.FundingFeeCurrency)
|
||||
|
||||
return slack.Attachment{
|
||||
Title: totalProfit,
|
||||
Color: style.PnLColor(s.TotalFundingFee),
|
||||
// Pretext: "",
|
||||
// Text: text,
|
||||
Fields: fields,
|
||||
Footer: fmt.Sprintf("Last Funding Fee Transation ID: %d Last Funding Fee Time %s", s.LastFundingFeeTxn, s.LastFundingFeeTime.Format(time.RFC822)),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ProfitStats) AddFundingFee(fee FundingFee) error {
|
||||
if s.FundingFeeCurrency == "" {
|
||||
s.FundingFeeCurrency = fee.Asset
|
||||
|
|
Loading…
Reference in New Issue
Block a user