mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
move convertPremiumIndex to convert.go
This commit is contained in:
parent
fbae368e6c
commit
71e043e4b2
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/adshao/go-binance/v2"
|
||||
"github.com/adshao/go-binance/v2/futures"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
|
@ -341,4 +342,26 @@ func convertSubscription(s types.Subscription) string {
|
|||
return fmt.Sprintf("%s@%s", strings.ToLower(s.Symbol), s.Channel)
|
||||
}
|
||||
|
||||
func convertPremiumIndex(index *futures.PremiumIndex) (*PremiumIndex, error) {
|
||||
markPrice, err := fixedpoint.NewFromString(index.MarkPrice)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lastFundingRate, err := fixedpoint.NewFromString(index.LastFundingRate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nextFundingTime := time.Unix(0, index.NextFundingTime*int64(time.Millisecond))
|
||||
t := time.Unix(0, index.Time*int64(time.Millisecond))
|
||||
|
||||
return &PremiumIndex{
|
||||
Symbol: index.Symbol,
|
||||
MarkPrice: markPrice,
|
||||
NextFundingTime: nextFundingTime,
|
||||
LastFundingRate: lastFundingRate,
|
||||
Time: t,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/adshao/go-binance/v2/futures"
|
||||
"golang.org/x/time/rate"
|
||||
|
||||
"github.com/adshao/go-binance/v2"
|
||||
|
@ -900,28 +899,6 @@ type PremiumIndex struct {
|
|||
Time time.Time `json:"time"`
|
||||
}
|
||||
|
||||
func convertPremiumIndex(index *futures.PremiumIndex) (*PremiumIndex, error) {
|
||||
markPrice, err := fixedpoint.NewFromString(index.MarkPrice)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lastFundingRate, err := fixedpoint.NewFromString(index.LastFundingRate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nextFundingTime := time.Unix(0, index.NextFundingTime*int64(time.Millisecond))
|
||||
t := time.Unix(0, index.Time*int64(time.Millisecond))
|
||||
|
||||
return &PremiumIndex{
|
||||
Symbol: index.Symbol,
|
||||
MarkPrice: markPrice,
|
||||
NextFundingTime: nextFundingTime,
|
||||
LastFundingRate: lastFundingRate,
|
||||
Time: t,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e *Exchange) QueryPremiumIndex(ctx context.Context, symbol string) (*PremiumIndex, error) {
|
||||
futuresClient := binance.NewFuturesClient(e.key, e.secret)
|
||||
|
|
Loading…
Reference in New Issue
Block a user