mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
max: use websocket update time (TU) field
This commit is contained in:
parent
89c88c48a3
commit
542944b4cc
|
@ -268,7 +268,7 @@ func (b *ActiveOrderBook) Update(order types.Order) {
|
|||
|
||||
b.mu.Lock()
|
||||
if !b.orders.Exists(order.OrderID) {
|
||||
log.Infof("[ActiveOrderBook] order #%d does not exist, adding it to pending order update", order.OrderID)
|
||||
log.Infof("[ActiveOrderBook] order #%d %s does not exist, adding it to pending order update", order.OrderID, order.Status)
|
||||
b.pendingOrderUpdates.Add(order)
|
||||
b.mu.Unlock()
|
||||
return
|
||||
|
@ -278,7 +278,7 @@ func (b *ActiveOrderBook) Update(order types.Order) {
|
|||
if previousOrder, ok := b.orders.Get(order.OrderID); ok {
|
||||
previousUpdateTime := previousOrder.UpdateTime.Time()
|
||||
if !previousUpdateTime.IsZero() && order.UpdateTime.Before(previousUpdateTime) {
|
||||
log.Infof("[ActiveOrderBook] order #%d updateTime is out of date, skip it", order.OrderID)
|
||||
log.Infof("[ActiveOrderBook] order #%d updateTime %s is out of date, skip it", order.OrderID, order.UpdateTime)
|
||||
b.mu.Unlock()
|
||||
return
|
||||
}
|
||||
|
|
|
@ -67,7 +67,9 @@ func toGlobalRewards(maxRewards []max.Reward) ([]types.Reward, error) {
|
|||
return rewards, nil
|
||||
}
|
||||
|
||||
func toGlobalOrderStatus(orderState max.OrderState, executedVolume, remainingVolume fixedpoint.Value) types.OrderStatus {
|
||||
func toGlobalOrderStatus(
|
||||
orderState max.OrderState, executedVolume, remainingVolume fixedpoint.Value,
|
||||
) types.OrderStatus {
|
||||
switch orderState {
|
||||
|
||||
case max.OrderStateCancel:
|
||||
|
@ -328,6 +330,6 @@ func convertWebSocketOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
|
|||
Status: toGlobalOrderStatus(u.State, u.ExecutedVolume, u.RemainingVolume),
|
||||
ExecutedQuantity: u.ExecutedVolume,
|
||||
CreationTime: types.Time(time.Unix(0, u.CreatedAtMs*int64(time.Millisecond))),
|
||||
UpdateTime: types.Time(time.Unix(0, u.CreatedAtMs*int64(time.Millisecond))),
|
||||
UpdateTime: types.Time(time.Unix(0, u.UpdateTime*int64(time.Millisecond))),
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user