xfunding: add funding fee slack attachment support

This commit is contained in:
c9s 2023-03-26 16:09:29 +08:00
parent c437837210
commit 4d59edc3d1
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 30 additions and 8 deletions

View File

@ -54,7 +54,7 @@ crossExchangeStrategies:
## shortFundingRate is the funding rate range you want to create your position ## shortFundingRate is the funding rate range you want to create your position
shortFundingRate: shortFundingRate:
## when funding rate is higher than this high value, the strategy will start buying spot and opening a short position ## when funding rate is higher than this high value, the strategy will start buying spot and opening a short position
high: 0.001% high: 0.0005%
## when funding rate is lower than this low value, the strategy will start closing futures position and sell the spot ## when funding rate is lower than this low value, the strategy will start closing futures position and sell the spot
low: -0.01% low: -0.01%

View File

@ -0,0 +1,29 @@
package xfunding
import (
"fmt"
"time"
"github.com/slack-go/slack"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/style"
)
type FundingFee struct {
Asset string `json:"asset"`
Amount fixedpoint.Value `json:"amount"`
Txn int64 `json:"txn"`
Time time.Time `json:"time"`
}
func (f *FundingFee) SlackAttachment() slack.Attachment {
return slack.Attachment{
Title: "Funding Fee " + fmt.Sprintf("%s %s", style.PnLSignString(f.Amount), f.Asset),
Color: style.PnLColor(f.Amount),
// Pretext: "",
// Text: text,
Fields: []slack.AttachmentField{},
Footer: fmt.Sprintf("Transation ID: %d Transaction Time %s", f.Txn, f.Time.Format(time.RFC822)),
}
}

View File

@ -8,13 +8,6 @@ import (
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
) )
type FundingFee struct {
Asset string `json:"asset"`
Amount fixedpoint.Value `json:"amount"`
Txn int64 `json:"txn"`
Time time.Time `json:"time"`
}
type ProfitStats struct { type ProfitStats struct {
*types.ProfitStats *types.ProfitStats