-
Notifications
You must be signed in to change notification settings - Fork 73
/
gtt_test.go
86 lines (80 loc) · 2 KB
/
gtt_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package kiteconnect
import (
"testing"
)
func (ts *TestSuite) TestGetGTTs(t *testing.T) {
t.Parallel()
gttOrders, err := ts.KiteConnect.GetGTTs()
if err != nil {
t.Errorf("Error while fetching GTT orders. %v", err)
}
for _, gttOrder := range gttOrders {
if gttOrder.ID == 0 {
t.Errorf("Error while parsing order id in GTT orders. %v", err)
}
}
}
func (ts *TestSuite) TestGetGTT(t *testing.T) {
t.Parallel()
gttOrder, err := ts.KiteConnect.GetGTT(123)
if err != nil {
t.Errorf("Error while fetching GTT orders. %v", err)
}
if gttOrder.ID != 123 {
t.Errorf("Error while parsing order id in GTT order. %v", err)
}
}
func (ts *TestSuite) TestModifyGTT(t *testing.T) {
t.Parallel()
gttOrder, err := ts.KiteConnect.ModifyGTT(123, GTTParams{
Tradingsymbol: "INFY",
Exchange: "NSE",
LastPrice: 800,
TransactionType: TransactionTypeBuy,
Trigger: >TSingleLegTrigger{
TriggerParams: TriggerParams{
TriggerValue: 2,
Quantity: 2,
LimitPrice: 2,
},
},
})
if err != nil {
t.Errorf("Error while fetching GTT orders. %v", err)
}
if gttOrder.TriggerID != 123 {
t.Errorf("Error while parsing order id in GTT order. %v", err)
}
}
func (ts *TestSuite) TestPlaceGTT(t *testing.T) {
t.Parallel()
gttOrder, err := ts.KiteConnect.PlaceGTT(GTTParams{
Tradingsymbol: "INFY",
Exchange: "NSE",
LastPrice: 800,
TransactionType: TransactionTypeBuy,
Trigger: >TSingleLegTrigger{
TriggerParams: TriggerParams{
TriggerValue: 1,
Quantity: 1,
LimitPrice: 1,
},
},
})
if err != nil {
t.Errorf("Error while fetching GTT orders. %v", err)
}
if gttOrder.TriggerID != 123 {
t.Errorf("Error while parsing order id in GTT order. %v", err)
}
}
func (ts *TestSuite) TestDeleteGTT(t *testing.T) {
t.Parallel()
gttOrder, err := ts.KiteConnect.DeleteGTT(123)
if err != nil {
t.Errorf("Error while fetching GTT orders. %v", err)
}
if gttOrder.TriggerID != 123 {
t.Errorf("Error while parsing order id in GTT order. %v", err)
}
}