-
Notifications
You must be signed in to change notification settings - Fork 142
/
rule_position_test.go
55 lines (40 loc) · 1.04 KB
/
rule_position_test.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
package techan
import (
"testing"
"github.com/sdcoffey/big"
"github.com/stretchr/testify/assert"
)
func TestPositionNewRule(t *testing.T) {
t.Run("returns true when position new", func(t *testing.T) {
record := NewTradingRecord()
rule := PositionNewRule{}
assert.True(t, rule.IsSatisfied(0, record))
})
t.Run("returns false when position open", func(t *testing.T) {
record := NewTradingRecord()
record.Operate(Order{
Side: BUY,
Amount: big.ONE,
Price: big.ONE,
})
rule := PositionNewRule{}
assert.False(t, rule.IsSatisfied(0, record))
})
}
func TestPositionOpenRule(t *testing.T) {
t.Run("returns false when position new", func(t *testing.T) {
record := NewTradingRecord()
rule := PositionOpenRule{}
assert.False(t, rule.IsSatisfied(0, record))
})
t.Run("returns true when position open", func(t *testing.T) {
record := NewTradingRecord()
record.Operate(Order{
Side: BUY,
Amount: big.ONE,
Price: big.ONE,
})
rule := PositionOpenRule{}
assert.True(t, rule.IsSatisfied(0, record))
})
}