xmaker: show order book last update time

This commit is contained in:
c9s 2022-01-12 22:11:28 +08:00
parent 2aeb9e870c
commit 5cc3a88911
2 changed files with 15 additions and 2 deletions

View File

@ -189,13 +189,19 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
// use mid-price for the last price // use mid-price for the last price
s.lastPrice = (bestBid.Price + bestAsk.Price).Float64() / 2 s.lastPrice = (bestBid.Price + bestAsk.Price).Float64() / 2
bookLastUpdateTime := s.book.LastUpdateTime()
if _, err := s.bidPriceHeartBeat.Update(bestBid, priceUpdateTimeout) ; err != nil { if _, err := s.bidPriceHeartBeat.Update(bestBid, priceUpdateTimeout) ; err != nil {
log.WithError(err).Errorf("quote update error, %s price not updating", s.Symbol) log.WithError(err).Errorf("quote update error, %s price not updating, order book last update: %s ago",
s.Symbol,
time.Since(bookLastUpdateTime))
return return
} }
if _, err := s.askPriceHeartBeat.Update(bestAsk, priceUpdateTimeout) ; err != nil { if _, err := s.askPriceHeartBeat.Update(bestAsk, priceUpdateTimeout) ; err != nil {
log.WithError(err).Errorf("quote update error, %s price not updating", s.Symbol) log.WithError(err).Errorf("quote update error, %s price not updating, order book last update: %s ago",
s.Symbol,
time.Since(bookLastUpdateTime))
return return
} }

View File

@ -51,6 +51,13 @@ func (b *MutexOrderBook) IsValid() (ok bool, err error) {
return ok, err return ok, err
} }
func (b *MutexOrderBook) LastUpdateTime() time.Time {
b.Lock()
t := b.OrderBook.LastUpdateTime()
b.Unlock()
return t
}
func (b *MutexOrderBook) BestBidAndAsk() (bid, ask PriceVolume, ok bool) { func (b *MutexOrderBook) BestBidAndAsk() (bid, ask PriceVolume, ok bool) {
var ok1, ok2 bool var ok1, ok2 bool
b.Lock() b.Lock()