forked from zerodha/gokiteconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportfolio_test.go
56 lines (52 loc) · 1.45 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
package kiteconnect
import (
"testing"
)
func (ts *TestSuite) TestGetPositions(t *testing.T) {
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) {
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) {
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)
}
}