mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
types: add bestBidAndAsk method
This commit is contained in:
parent
e8205556ff
commit
f20e809940
|
@ -59,6 +59,16 @@ func (b *MutexOrderBook) IsValid() (ok bool, err error) {
|
|||
return ok, err
|
||||
}
|
||||
|
||||
func (b *MutexOrderBook) BestBidAndAsk() (bid, ask PriceVolume, ok bool) {
|
||||
var ok1, ok2 bool
|
||||
b.Lock()
|
||||
bid, ok1 = b.OrderBook.BestBid()
|
||||
ask, ok2 = b.OrderBook.BestAsk()
|
||||
ok = ok1 && ok2
|
||||
b.Unlock()
|
||||
return bid, ask, ok
|
||||
}
|
||||
|
||||
func (b *MutexOrderBook) BestBid() (pv PriceVolume, ok bool) {
|
||||
b.Lock()
|
||||
pv, ok = b.OrderBook.BestBid()
|
||||
|
|
Loading…
Reference in New Issue
Block a user