-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathorders_test.go
91 lines (81 loc) · 2.37 KB
/
orders_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
87
88
89
90
91
package smartapigo
import (
"testing"
)
func (ts *TestSuite) TestGetOrders(t *testing.T) {
t.Parallel()
orders, err := ts.TestConnect.GetOrderBook()
if err != nil {
t.Errorf("Error while fetching orders. %v", err)
}
for _, order := range orders {
if order.OrderID == "" {
t.Errorf("Error while fetching order id in orders. %v", err)
}
}
}
func (ts *TestSuite) TestGetTrades(t *testing.T) {
t.Parallel()
trades, err := ts.TestConnect.GetTradeBook()
if err != nil {
t.Errorf("Error while fetching trades. %v", err)
}
for _, trade := range trades {
if trade.OrderID == "" {
t.Errorf("Error while fetching trade id in trades. %v", err)
}
}
}
func (ts *TestSuite) TestPlaceOrder(t *testing.T) {
t.Parallel()
params := OrderParams{"NORMAL", "SBIN-EQ", "3045", "BUY", "NSE", "LIMIT", "INTRADAY", "DAY", "19500", "0", "0", "1"}
orderResponse, err := ts.TestConnect.PlaceOrder(params)
if err != nil {
t.Errorf("Error while placing order. %v", err)
}
if orderResponse.OrderID == "" {
t.Errorf("No order id returned. Error %v", err)
}
}
func (ts *TestSuite) TestModifyOrder(t *testing.T) {
t.Parallel()
params := ModifyOrderParams{"NORMAL", "test", "LIMIT", "INTRADAY", "DAY", "19400", "1","SBI-EQ","3045","NSE"}
orderResponse, err := ts.TestConnect.ModifyOrder( params)
if err != nil {
t.Errorf("Error while updating order. %v", err)
}
if orderResponse.OrderID == "" {
t.Errorf("No order id returned. Error %v", err)
}
}
func (ts *TestSuite) TestCancelOrder(t *testing.T) {
t.Parallel()
parentOrderID := "test"
orderResponse, err := ts.TestConnect.CancelOrder("NORMAL",parentOrderID)
if err != nil {
t.Errorf("Error while cancellation of an order. %v", err)
}
if orderResponse.OrderID == "" {
t.Errorf("No order id returned. Error %v", err)
}
}
func (ts *TestSuite) TestGetPositions(t *testing.T) {
t.Parallel()
positions, err := ts.TestConnect.GetPositions()
if err != nil {
t.Errorf("Error while fetching positions. %v", err)
}
for _, position := range positions {
if position.Exchange == "" {
t.Errorf("Error while fetching exchange in positions. %v", err)
}
}
}
func (ts *TestSuite) TestConvertPosition(t *testing.T) {
t.Parallel()
params := ConvertPositionParams{"NSE","SBIN-EQ","DELIVERY","MARGIN","BUY",1,"DAY"}
err := ts.TestConnect.ConvertPosition(params)
if err != nil {
t.Errorf("Error while fetching positions. %v", err)
}
}