diff --git a/connect.go b/connect.go index 23cb8c3..3dc64b9 100644 --- a/connect.go +++ b/connect.go @@ -49,6 +49,7 @@ const ( ProductMIS = "MIS" ProductCNC = "CNC" ProductNRML = "NRML" + ProductMTF = "MTF" // Order types OrderTypeMarket = "MARKET" diff --git a/mock_responses b/mock_responses index 8afe0ed..7508355 160000 --- a/mock_responses +++ b/mock_responses @@ -1 +1 @@ -Subproject commit 8afe0ed9d1f0efbdf9e568859e32c33a26694aef +Subproject commit 7508355ed065efe5304f8ef4b2d521b2e24b8a20 diff --git a/orders_test.go b/orders_test.go index cd340b6..b37018c 100644 --- a/orders_test.go +++ b/orders_test.go @@ -35,6 +35,9 @@ func (ts *TestSuite) TestGetOrders(t *testing.T) { require.Equal(t, "22", orders[6].AuctionNumber) require.Equal(t, false, orders[6].Modified) }) + t.Run("test mtf order", func(t *testing.T) { + require.Equal(t, "MTF", orders[7].Product) + }) } func (ts *TestSuite) TestGetTrades(t *testing.T) { @@ -176,6 +179,28 @@ func (ts *TestSuite) TestPlaceAuctionOrder(t *testing.T) { } } +func (ts *TestSuite) TestPlaceMTFOrder(t *testing.T) { + t.Parallel() + mtfParams := OrderParams{ + Exchange: "test_mtf", + Tradingsymbol: "test_mtf", + Validity: "test_mtf", + Product: ProductMTF, + OrderType: "test_mtf", + TransactionType: "test_mtf", + Quantity: 100, + Price: 100, + Tag: "test_mtf", + } + orderResponse, err := ts.KiteConnect.PlaceOrder("test", mtfParams) + if err != nil { + t.Errorf("Error while placing mtf order. %v", err) + } + if orderResponse.OrderID == "" { + t.Errorf("No order id returned for placing mtf order. Error %v", err) + } +} + func (ts *TestSuite) TestModifyOrder(t *testing.T) { t.Parallel() params := OrderParams{ diff --git a/portfolio.go b/portfolio.go index e986020..0c5a8ba 100644 --- a/portfolio.go +++ b/portfolio.go @@ -45,6 +45,17 @@ type Holding struct { PnL float64 `json:"pnl"` DayChange float64 `json:"day_change"` DayChangePercentage float64 `json:"day_change_percentage"` + + MTF MTFHolding `json:"mtf"` +} + +// MTFHolding represents the mtf details for a holding +type MTFHolding struct { + Quantity int `json:"quantity"` + UsedQuantity int `json:"used_quantity"` + AveragePrice float64 `json:"average_price"` + Value float64 `json:"value"` + InitialMargin float64 `json:"initial_margin"` } // Holdings is a list of holdings diff --git a/portfolio_test.go b/portfolio_test.go index 4afbfdf..120f886 100644 --- a/portfolio_test.go +++ b/portfolio_test.go @@ -40,6 +40,13 @@ func (ts *TestSuite) TestGetHoldings(t *testing.T) { t.Errorf("Error while fetching tradingsymbol in holdings. %v", err) } } + // MTF fields + if holdings[0].MTF.Quantity != 1000 { + t.Errorf("Error while fetching quantity in mtf holdings. %v", err) + } + if holdings[0].MTF.Value != 100000 { + t.Errorf("Error while fetching value in mtf holdings. %v", err) + } } func (ts *TestSuite) TestGetAuctionInstruments(t *testing.T) {