mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
bbgo: fix pending order event trigger
This commit is contained in:
parent
b666c8bf40
commit
7532c31631
|
@ -12,8 +12,14 @@ import (
|
||||||
|
|
||||||
func TestActiveOrderBook_pendingOrders(t *testing.T) {
|
func TestActiveOrderBook_pendingOrders(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
ob := NewActiveOrderBook("")
|
ob := NewActiveOrderBook("")
|
||||||
|
|
||||||
|
filled := false
|
||||||
|
ob.OnFilled(func(o types.Order) {
|
||||||
|
filled = true
|
||||||
|
})
|
||||||
|
|
||||||
// if we received filled order first
|
// if we received filled order first
|
||||||
// should be added to pending orders
|
// should be added to pending orders
|
||||||
ob.orderUpdateHandler(types.Order{
|
ob.orderUpdateHandler(types.Order{
|
||||||
|
@ -34,6 +40,11 @@ func TestActiveOrderBook_pendingOrders(t *testing.T) {
|
||||||
|
|
||||||
assert.Len(t, ob.pendingOrderUpdates.Orders(), 1)
|
assert.Len(t, ob.pendingOrderUpdates.Orders(), 1)
|
||||||
|
|
||||||
|
o99, ok := ob.pendingOrderUpdates.Get(99)
|
||||||
|
if assert.True(t, ok) {
|
||||||
|
assert.Equal(t, types.OrderStatusFilled, o99.Status)
|
||||||
|
}
|
||||||
|
|
||||||
// should be added to pending orders
|
// should be added to pending orders
|
||||||
ob.Add(types.Order{
|
ob.Add(types.Order{
|
||||||
OrderID: 99,
|
OrderID: 99,
|
||||||
|
@ -51,7 +62,6 @@ func TestActiveOrderBook_pendingOrders(t *testing.T) {
|
||||||
UpdateTime: types.Time(now.Add(-time.Second)),
|
UpdateTime: types.Time(now.Add(-time.Second)),
|
||||||
})
|
})
|
||||||
|
|
||||||
o99, ok := ob.Get(99)
|
assert.True(t, filled, "filled event should be fired")
|
||||||
assert.True(t, ok)
|
|
||||||
assert.Equal(t, types.OrderStatusFilled, o99.Status)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user