mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
core: add order update trigger channel
This commit is contained in:
parent
e19aa8fa10
commit
1abb301af1
|
@ -15,12 +15,14 @@ type OrderStore struct {
|
|||
RemoveCancelled bool
|
||||
RemoveFilled bool
|
||||
AddOrderUpdate bool
|
||||
C chan types.Order
|
||||
}
|
||||
|
||||
func NewOrderStore(symbol string) *OrderStore {
|
||||
return &OrderStore{
|
||||
Symbol: symbol,
|
||||
orders: make(map[uint64]types.Order),
|
||||
C: make(chan types.Order),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,6 +131,7 @@ func (s *OrderStore) BindStream(stream types.Stream) {
|
|||
}
|
||||
|
||||
func (s *OrderStore) HandleOrderUpdate(order types.Order) {
|
||||
|
||||
switch order.Status {
|
||||
|
||||
case types.OrderStatusNew, types.OrderStatusPartiallyFilled, types.OrderStatusFilled:
|
||||
|
@ -152,4 +155,9 @@ func (s *OrderStore) HandleOrderUpdate(order types.Order) {
|
|||
case types.OrderStatusRejected:
|
||||
s.Remove(order)
|
||||
}
|
||||
|
||||
select {
|
||||
case s.C <- order:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ func (m Market) TruncateQuantity(quantity fixedpoint.Value) fixedpoint.Value {
|
|||
|
||||
qf := math.Trunc(quantity.Float64() * pow10)
|
||||
qf = qf / pow10
|
||||
|
||||
qs := strconv.FormatFloat(qf, 'f', prec, 64)
|
||||
return fixedpoint.MustNewFromString(qs)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user