-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.go
33 lines (26 loc) · 721 Bytes
/
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
package matchingengine
type OrderID = int
type OrderType = string
const (
OrderTypeBuy OrderType = "buy"
OrderTypeSell OrderType = "sell"
)
type OrderStatus = string
const (
OrderStatusPending OrderStatus = "pending"
OrderStatusPartiallyCompleted OrderStatus = "partially_completed"
OrderStatusCompleted OrderStatus = "completed"
OrderStatusCancelled OrderStatus = "cancelled"
OrderStatusDeleted OrderStatus = "deleted"
)
type Order struct {
ID OrderID
Amount int
CompletedAmount int
Price int
Type OrderType
Status OrderStatus
}
func (o Order) RemainingAmount() int {
return o.Amount - o.CompletedAmount
}