mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
bbgo: simplify order symbol filtering condition
This commit is contained in:
parent
cf1be9fc6f
commit
10eba876c4
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user