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