mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
bbgo: fix active book order removal
This commit is contained in:
parent
3907f99e70
commit
d57f8fedfe
|
@ -102,17 +102,9 @@ func (b *LocalActiveOrderBook) orderUpdateHandler(order types.Order) {
|
||||||
b.EmitFilled(order)
|
b.EmitFilled(order)
|
||||||
}
|
}
|
||||||
|
|
||||||
case types.OrderStatusPartiallyFilled:
|
case types.OrderStatusPartiallyFilled, types.OrderStatusNew:
|
||||||
b.Update(order)
|
b.Update(order)
|
||||||
|
|
||||||
case types.OrderStatusNew:
|
|
||||||
if order.Quantity == 0 {
|
|
||||||
log.Debugf("[LocalActiveOrderBook] order status %s, removing order %s", order.Status, order)
|
|
||||||
b.Remove(order)
|
|
||||||
} else {
|
|
||||||
b.Update(order)
|
|
||||||
}
|
|
||||||
|
|
||||||
case types.OrderStatusCanceled, types.OrderStatusRejected:
|
case types.OrderStatusCanceled, types.OrderStatusRejected:
|
||||||
log.Debugf("[LocalActiveOrderBook] order status %s, removing order %s", order.Status, order)
|
log.Debugf("[LocalActiveOrderBook] order status %s, removing order %s", order.Status, order)
|
||||||
b.Remove(order)
|
b.Remove(order)
|
||||||
|
|
|
@ -97,15 +97,14 @@ func (m *SyncOrderMap) Backup() (orders []SubmitOrder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SyncOrderMap) Remove(orderID uint64) (exists bool) {
|
func (m *SyncOrderMap) Remove(orderID uint64) (exists bool) {
|
||||||
exists = m.Exists(orderID)
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
|
|
||||||
|
exists = m.orders.Exists(orderID)
|
||||||
if exists {
|
if exists {
|
||||||
m.Lock()
|
|
||||||
m.orders.Remove(orderID)
|
m.orders.Remove(orderID)
|
||||||
m.Unlock()
|
|
||||||
} else {
|
} else {
|
||||||
m.Lock()
|
|
||||||
m.pendingRemoval[orderID] = time.Now()
|
m.pendingRemoval[orderID] = time.Now()
|
||||||
m.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return exists
|
return exists
|
||||||
|
|
Loading…
Reference in New Issue
Block a user