-
Notifications
You must be signed in to change notification settings - Fork 2
/
portfolio_test.go
59 lines (55 loc) · 1.49 KB
/
portfolio_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
package kiteapi
import (
"testing"
)
func (ts *TestSuite) TestGetPositions(t *testing.T) {
t.Parallel()
positions, err := ts.KiteConnect.GetPositions()
if err != nil {
t.Errorf("Error while fetching positions. %v", err)
}
if positions.Day == nil {
t.Errorf("Error while fetching day positions. %v", err)
}
if positions.Net == nil {
t.Errorf("Error while fetching net positions. %v", err)
}
for _, position := range positions.Day {
if position.Tradingsymbol == "" {
t.Errorf("Error while fetching trading symbol in day position. %v", err)
}
}
for _, position := range positions.Net {
if position.Tradingsymbol == "" {
t.Errorf("Error while fetching tradingsymbol in net position. %v", err)
}
}
}
func (ts *TestSuite) TestGetHoldings(t *testing.T) {
t.Parallel()
holdings, err := ts.KiteConnect.GetHoldings()
if err != nil {
t.Errorf("Error while fetching holdings. %v", err)
}
for _, holding := range holdings {
if holding.Tradingsymbol == "" {
t.Errorf("Error while fetching tradingsymbol in holdings. %v", err)
}
}
}
func (ts *TestSuite) TestConvertPosition(t *testing.T) {
t.Parallel()
params := ConvertPositionParams{
Exchange: "test",
TradingSymbol: "test",
OldProduct: "test",
NewProduct: "test",
PositionType: "test",
TransactionType: "test",
Quantity: "test",
}
response, err := ts.KiteConnect.ConvertPosition(params)
if err != nil || response != true {
t.Errorf("Error while converting position. %v", err)
}
}