forked from dwdwow/cex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder.go
71 lines (57 loc) · 1.94 KB
/
order.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package cex
type OrderType string
const (
OrderTypeLimit OrderType = "LIMIT"
OrderTypeMarket OrderType = "MARKET"
)
type OrderSide string
const (
OrderSideBuy OrderSide = "BUY"
OrderSideSell OrderSide = "SELL"
)
type OrderStatus string
const (
OrderStatusNew OrderStatus = "NEW"
OrderStatusPartiallyFilled OrderStatus = "PARTIALLY_FILLED"
OrderStatusFilled OrderStatus = "FILLED"
OrderStatusCanceled OrderStatus = "CANCELED"
OrderStatusRejected OrderStatus = "REJECTED"
OrderStatusExpired OrderStatus = "EXPIRED"
)
// Order
// Every field value in Order must be certain.
type Order struct {
// popular by user or code
Cex Name `json:"cex" bson:"cex"`
PairType PairType `json:"pairType" bson:"pairType"`
OrderType OrderType `json:"orderType" bson:"orderType"`
OrderSide OrderSide `json:"orderSide" bson:"orderSide"`
// popular by code
Symbol string `json:"symbol" bson:"symbol"`
TimeInForce string `json:"timeInForce" bson:"timeInForce"`
ClientOrderId string `json:"clientOrderId" bson:"clientOrderId"`
ApiKey string `json:"apiKey" bson:"apiKey"`
// popular by user self
OriQty float64 `json:"oriQty" bson:"oriQty"`
OriPrice float64 `json:"oriPrice" bson:"oriPrice"`
// popular as response
OrderId string `json:"orderId" bson:"orderId"`
Status OrderStatus `json:"status" bson:"status"`
// popular a order result
FilledQty float64 `json:"filledQty" bson:"filledQty"`
FilledQuote float64 `json:"filledQuote" bson:"filledQuote"`
FilledAvgPrice float64 `json:"filledAvgPrice" bson:"filledAvgPrice"`
RawOrder any `json:"rawOrder" bson:"rawOrder"`
//Asset string `json:"asset" bson:"asset"`
//Quote string `json:"quote" bson:"quote"`
}
func (o *Order) IsFinished() bool {
if o == nil {
return false
}
switch o.Status {
case OrderStatusRejected, OrderStatusExpired, OrderStatusFilled, OrderStatusCanceled:
return true
}
return false
}