mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-12 18:13:54 +00:00
types: add warning to the price type
This commit is contained in:
parent
1294cd95be
commit
0a83c26fd5
|
@ -5,6 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
)
|
)
|
||||||
|
@ -70,6 +71,11 @@ func (p *PriceType) UnmarshalJSON(data []byte) error {
|
||||||
|
|
||||||
// GetPrice returns the price from the given ticker based on the price type
|
// GetPrice returns the price from the given ticker based on the price type
|
||||||
func (p PriceType) GetPrice(ticker *Ticker, side SideType) fixedpoint.Value {
|
func (p PriceType) GetPrice(ticker *Ticker, side SideType) fixedpoint.Value {
|
||||||
|
switch p {
|
||||||
|
case PriceTypeBestBidOfferQueue5, PriceTypeBestBidOfferCounterParty5:
|
||||||
|
log.Warnf("price type %s is not supported with ticker", p)
|
||||||
|
}
|
||||||
|
|
||||||
price := ticker.Last
|
price := ticker.Last
|
||||||
|
|
||||||
switch p {
|
switch p {
|
||||||
|
@ -81,13 +87,13 @@ func (p PriceType) GetPrice(ticker *Ticker, side SideType) fixedpoint.Value {
|
||||||
price = ticker.Sell
|
price = ticker.Sell
|
||||||
case PriceTypeMid:
|
case PriceTypeMid:
|
||||||
price = ticker.Buy.Add(ticker.Sell).Div(fixedpoint.NewFromInt(2))
|
price = ticker.Buy.Add(ticker.Sell).Div(fixedpoint.NewFromInt(2))
|
||||||
case PriceTypeMaker, PriceTypeBestBidOfferQueue1:
|
case PriceTypeMaker, PriceTypeBestBidOfferQueue1, PriceTypeBestBidOfferQueue5:
|
||||||
if side == SideTypeBuy {
|
if side == SideTypeBuy {
|
||||||
price = ticker.Buy
|
price = ticker.Buy
|
||||||
} else if side == SideTypeSell {
|
} else if side == SideTypeSell {
|
||||||
price = ticker.Sell
|
price = ticker.Sell
|
||||||
}
|
}
|
||||||
case PriceTypeTaker, PriceTypeBestBidOfferCounterParty1:
|
case PriceTypeTaker, PriceTypeBestBidOfferCounterParty1, PriceTypeBestBidOfferCounterParty5:
|
||||||
if side == SideTypeBuy {
|
if side == SideTypeBuy {
|
||||||
price = ticker.Sell
|
price = ticker.Sell
|
||||||
} else if side == SideTypeSell {
|
} else if side == SideTypeSell {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user