mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xmaker: check book before copying
This commit is contained in:
parent
f5a241a1a8
commit
3fd170a4ff
|
@ -194,9 +194,14 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
|
|||
return
|
||||
}
|
||||
|
||||
sourceBook := s.book.Copy()
|
||||
bestBid, bestAsk, hasPrice := s.book.BestBidAndAsk()
|
||||
if !hasPrice {
|
||||
return
|
||||
}
|
||||
|
||||
sourceBook := s.book.CopyDepth(20)
|
||||
if valid, err := sourceBook.IsValid(); !valid {
|
||||
log.WithError(err).Errorf("%s invalid order book, skip quoting: %v", s.Symbol, err)
|
||||
log.WithError(err).Errorf("%s invalid copied order book, skip quoting: %v", s.Symbol, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -281,12 +286,6 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
|
|||
return
|
||||
}
|
||||
|
||||
bestBid, hasBid := sourceBook.BestBid()
|
||||
bestAsk, hasAsk := sourceBook.BestAsk()
|
||||
if !hasBid || !hasAsk {
|
||||
return
|
||||
}
|
||||
|
||||
bestBidPrice := bestBid.Price
|
||||
bestAskPrice := bestAsk.Price
|
||||
log.Infof("%s book ticker: best ask / best bid = %f / %f", s.Symbol, bestAskPrice.Float64(), bestBidPrice.Float64())
|
||||
|
|
Loading…
Reference in New Issue
Block a user