-
Notifications
You must be signed in to change notification settings - Fork 1
/
trade.go
61 lines (54 loc) · 944 Bytes
/
trade.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
package bitmexwrap
import "time"
type ActionType int
const (
ActionBuy ActionType = iota
ActionSell
ActionOpenLong
ActionCloseLong
ActionOpenShort
ActionCloseShort
)
func (at ActionType) String() (msg string) {
switch at {
case ActionBuy:
msg = "buy"
case ActionSell:
msg = "sell"
case ActionOpenLong:
msg = "openLong"
case ActionCloseLong:
msg = "closeLong"
case ActionOpenShort:
msg = "openShort"
case ActionCloseShort:
msg = "closeShort"
default:
}
return
}
type Trade struct {
ID string
Symbol string
Time time.Time
Price float64
Amount float64
Side string
Remark string
}
type TradeAction struct {
Action ActionType
Amount float64
Price float64
Time time.Time
}
func (ta *TradeAction) IsBuy() bool {
switch ta.Action {
case ActionBuy, ActionOpenLong, ActionCloseShort:
return true
case ActionSell, ActionCloseLong, ActionOpenShort:
return false
default:
}
return false
}