bbgo: simplify order symbol filtering condition

This commit is contained in:
c9s 2023-02-17 19:24:08 +08:00
parent cf1be9fc6f
commit 10eba876c4
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -285,27 +285,23 @@ func (b *ActiveOrderBook) Print() {
func (b *ActiveOrderBook) Update(orders ...types.Order) {
hasSymbol := len(b.Symbol) > 0
for _, order := range orders {
if hasSymbol {
if b.Symbol == order.Symbol {
b.orders.Update(order)
if hasSymbol && b.Symbol != order.Symbol {
continue
}
} else {
b.orders.Update(order)
}
}
}
func (b *ActiveOrderBook) Add(orders ...types.Order) {
hasSymbol := len(b.Symbol) > 0
for _, order := range orders {
if hasSymbol {
if b.Symbol == order.Symbol {
b.add(order)
if hasSymbol && b.Symbol != order.Symbol {
continue
}
} else {
b.add(order)
}
}
}
// add the order to the active order book and check the pending order