mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
book: handle volume == 0
This commit is contained in:
parent
d29725119f
commit
26674effa1
|
@ -103,13 +103,21 @@ type OrderBook struct {
|
|||
|
||||
func (b *OrderBook) UpdateAsks(pvs PriceVolumePairSlice) {
|
||||
for _, pv := range pvs {
|
||||
b.Asks.UpdateOrInsert(pv, false)
|
||||
if pv.Volume == 0 {
|
||||
b.Asks.RemoveByPrice(pv.Price, false)
|
||||
} else {
|
||||
b.Asks.UpdateOrInsert(pv, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *OrderBook) UpdateBids(pvs PriceVolumePairSlice) {
|
||||
for _, pv := range pvs {
|
||||
b.Bids.UpdateOrInsert(pv, true)
|
||||
if pv.Volume == 0 {
|
||||
b.Bids.RemoveByPrice(pv.Price, true)
|
||||
} else {
|
||||
b.Bids.UpdateOrInsert(pv, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user