diff --git a/pkg/types/ticker.go b/pkg/types/ticker.go index d985fbc35..903c63813 100644 --- a/pkg/types/ticker.go +++ b/pkg/types/ticker.go @@ -18,6 +18,22 @@ type Ticker struct { Sell fixedpoint.Value // `sell` from Max, `askPrice` from binance } +func (t *Ticker) GetValidPrice() fixedpoint.Value { + if !t.Last.IsZero() { + return t.Last + } + + if !t.Buy.IsZero() { + return t.Buy + } + + if !t.Sell.IsZero() { + return t.Sell + } + + return t.Open +} + func (t *Ticker) String() string { return fmt.Sprintf("O:%s H:%s L:%s LAST:%s BID/ASK:%s/%s TIME:%s", t.Open, t.High, t.Low, t.Last, t.Buy, t.Sell, t.Time.String()) }