max: use websocket update time (TU) field

This commit is contained in:
c9s 2023-09-17 18:29:14 +08:00
parent 89c88c48a3
commit 542944b4cc
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 6 additions and 4 deletions

View File

@ -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
}

View File

@ -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
}