-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
58 lines (50 loc) · 971 Bytes
/
types.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
package orderbook
import (
"fmt"
)
// Side represents order side (buy or sell)
type Side byte
var (
// Buy represents buy order
Buy Side = 'B'
// Sell represents sell order
Sell Side = 'S'
)
func (s Side) String() string {
if s == Buy {
return "Buy"
}
return "Sell"
}
// Execution represents the result of a match
type Execution struct {
BuyOrderID string
SellOrderID string
Quantity int
Price int
Timestamp int64
}
func (ex Execution) String() string {
return fmt.Sprintf("(BuyOrderID: %v, SellOrderID: %v, Quantity: %v, Price: %v, Timestamp: %d)",
ex.BuyOrderID,
ex.SellOrderID,
ex.Quantity,
ex.Price,
ex.Timestamp)
}
// Order represents an order
type Order struct {
Quantity int
Price int
Timestamp int64
Side Side
ID string
}
func (o Order) String() string {
return fmt.Sprintf("ID: %v, Side: %v, Quantity: %v, Price: %v, Timestamp: %d",
o.ID,
o.Side,
o.Quantity,
o.Price,
o.Timestamp)
}