fix max exchange order status conversion and document the order status

This commit is contained in:
c9s 2021-12-26 15:58:12 +08:00
parent 770c1067fc
commit e08b2e9a85
3 changed files with 17 additions and 9 deletions

View File

@ -70,18 +70,16 @@ func toGlobalRewards(maxRewards []max.Reward) ([]types.Reward, error) {
return rewards, nil
}
func toGlobalOrderStatus(orderStatus max.OrderState, executedVolume, remainingVolume fixedpoint.Value) types.OrderStatus {
func toGlobalOrderStatus(orderState max.OrderState, executedVolume, remainingVolume fixedpoint.Value) types.OrderStatus {
switch orderState {
switch orderStatus {
case max.OrderStateCancel:
return types.OrderStatusCanceled
case max.OrderStateFinalizing, max.OrderStateDone:
case max.OrderStateFinalizing, max.OrderStateDone, max.OrderStateCancel:
if executedVolume > 0 && remainingVolume > 0 {
return types.OrderStatusPartiallyFilled
} else if remainingVolume == 0 {
return types.OrderStatusFilled
} else if executedVolume == 0 {
return types.OrderStatusCanceled
}
return types.OrderStatusFilled
@ -105,8 +103,8 @@ func toGlobalOrderStatus(orderStatus max.OrderState, executedVolume, remainingVo
}
logger.Errorf("unknown order status: %v", orderStatus)
return types.OrderStatus(orderStatus)
logger.Errorf("unknown order status: %v", orderState)
return types.OrderStatus(orderState)
}
func toGlobalOrderType(orderType max.OrderType) types.OrderType {

View File

@ -44,6 +44,7 @@ type OrderState string
const (
OrderStateDone = OrderState("done")
OrderStateCancel = OrderState("cancel")
OrderStateWait = OrderState("wait")
OrderStateConvert = OrderState("convert")

View File

@ -84,10 +84,19 @@ const NoClientOrderID = "0"
type OrderStatus string
const (
// OrderStatusNew means the order is active on the orderbook without any filling.
OrderStatusNew OrderStatus = "NEW"
// OrderStatusFilled means the order is fully-filled, it's an end state.
OrderStatusFilled OrderStatus = "FILLED"
// OrderStatusPartiallyFilled means the order is partially-filled, it's an end state, the order might be canceled in the end.
OrderStatusPartiallyFilled OrderStatus = "PARTIALLY_FILLED"
// OrderStatusCanceled means the order is canceled without partially filled or filled.
OrderStatusCanceled OrderStatus = "CANCELED"
// OrderStatusRejected means the order is not placed successfully, it's rejected by the api
OrderStatusRejected OrderStatus = "REJECTED"
)