mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
bbgo: add mutli symbol support to active order book
This commit is contained in:
parent
f9fe5d7790
commit
cae8bc2882
|
@ -105,13 +105,22 @@ func (b *ActiveOrderBook) GracefulCancel(ctx context.Context, ex types.Exchange)
|
||||||
|
|
||||||
// verify the current open orders via the RESTful API
|
// verify the current open orders via the RESTful API
|
||||||
log.Warnf("[ActiveOrderBook] using REStful API to verify active orders...")
|
log.Warnf("[ActiveOrderBook] using REStful API to verify active orders...")
|
||||||
openOrders, err := ex.QueryOpenOrders(ctx, b.Symbol)
|
|
||||||
|
orders = b.Orders()
|
||||||
|
var symbols = map[string]struct{}{}
|
||||||
|
for _, order := range orders {
|
||||||
|
symbols[order.Symbol] = struct{}{}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for symbol := range symbols {
|
||||||
|
openOrders, err := ex.QueryOpenOrders(ctx, symbol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Errorf("can not query %s open orders", b.Symbol)
|
log.WithError(err).Errorf("can not query %s open orders", symbol)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
openOrderStore := NewOrderStore(b.Symbol)
|
openOrderStore := NewOrderStore(symbol)
|
||||||
openOrderStore.Add(openOrders...)
|
openOrderStore.Add(openOrders...)
|
||||||
for _, o := range orders {
|
for _, o := range orders {
|
||||||
// if it's not on the order book (open orders), we should remove it from our local side
|
// if it's not on the order book (open orders), we should remove it from our local side
|
||||||
|
@ -120,6 +129,7 @@ func (b *ActiveOrderBook) GracefulCancel(ctx context.Context, ex types.Exchange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("[ActiveOrderBook] all %s orders are cancelled successfully in %s", b.Symbol, time.Since(startTime))
|
log.Debugf("[ActiveOrderBook] all %s orders are cancelled successfully in %s", b.Symbol, time.Since(startTime))
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user