extend ticker method

This commit is contained in:
c9s 2024-09-27 18:30:51 +08:00
parent d5a6930545
commit 9194a9152c
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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())
}