mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
fix max exchange order status conversion and document the order status
This commit is contained in:
parent
770c1067fc
commit
e08b2e9a85
|
@ -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 {
|
||||
|
|
|
@ -44,6 +44,7 @@ type OrderState string
|
|||
|
||||
const (
|
||||
OrderStateDone = OrderState("done")
|
||||
|
||||
OrderStateCancel = OrderState("cancel")
|
||||
OrderStateWait = OrderState("wait")
|
||||
OrderStateConvert = OrderState("convert")
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user