mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
xfunding: add funding fee slack attachment support
This commit is contained in:
parent
c437837210
commit
4d59edc3d1
|
@ -54,7 +54,7 @@ crossExchangeStrategies:
|
|||
## shortFundingRate is the funding rate range you want to create your position
|
||||
shortFundingRate:
|
||||
## 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
|
||||
low: -0.01%
|
||||
|
||||
|
|
29
pkg/strategy/xfunding/fundingfee.go
Normal file
29
pkg/strategy/xfunding/fundingfee.go
Normal 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)),
|
||||
}
|
||||
}
|
|
@ -8,13 +8,6 @@ import (
|
|||
"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 {
|
||||
*types.ProfitStats
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user