From 5abc1e99bc837bf64135b309822040ef38daf6af Mon Sep 17 00:00:00 2001 From: sauravkuila <75120143+sauravkuila@users.noreply.github.com> Date: Mon, 25 Dec 2023 13:45:39 +0530 Subject: [PATCH 1/2] updated Holdings structure to fix json unmarshall error --- portfolio.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/portfolio.go b/portfolio.go index fe16919..5ef3ed2 100644 --- a/portfolio.go +++ b/portfolio.go @@ -6,27 +6,31 @@ import ( // Holding is an individual holdings response. type Holding struct { - Tradingsymbol string `json:"tradingsymbol"` - Exchange string `json:"exchange"` - ISIN string `json:"isin"` - T1Quantity string `json:"t1quantity"` - RealisedQuantity string `json:"realisedquantity"` - Quantity string `json:"quantity"` - AuthorisedQuantity string `json:"authorisedquantity"` - ProfitAndLoss string `json:"profitandloss"` - Product string `json:"product"` - CollateralQuantity string `json:"collateralquantity"` - CollateralType string `json:"collateraltype"` - Haircut string `json:"haircut"` + Tradingsymbol string `json:"tradingsymbol"` + Exchange string `json:"exchange"` + ISIN string `json:"isin"` + T1Quantity int64 `json:"t1quantity"` + RealisedQuantity int64 `json:"realisedquantity"` + Quantity int64 `json:"quantity"` + AveragePrice float64 `json:"averageprice"` + AuthorisedQuantity int64 `json:"authorisedquantity"` + ProfitAndLoss string `json:"profitandloss"` + Product string `json:"product"` + CollateralQuantity int64 `json:"collateralquantity"` + CollateralType string `json:"collateraltype"` + Haircut float64 `json:"haircut"` + Ltp float64 `json:"ltp"` + Symboltoken string `json:"symboltoken"` + Close float64 `json:"close"` + Pnlpercentage float64 `json:"pnlpercentage"` } // Holdings is a list of holdings type Holdings []Holding - // GetHoldings gets a list of holdings. func (c *Client) GetHoldings() (Holdings, error) { var holdings Holdings err := c.doEnvelope(http.MethodGet, URIGetHoldings, nil, nil, &holdings, true) return holdings, err -} \ No newline at end of file +} From 6811a8e3ab50b3d971d9975ff1cf86997d9a933d Mon Sep 17 00:00:00 2001 From: sauravkuila <75120143+sauravkuila@users.noreply.github.com> Date: Mon, 25 Dec 2023 14:02:39 +0530 Subject: [PATCH 2/2] updating pnl datatype --- portfolio.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portfolio.go b/portfolio.go index 5ef3ed2..20ad0e4 100644 --- a/portfolio.go +++ b/portfolio.go @@ -14,7 +14,7 @@ type Holding struct { Quantity int64 `json:"quantity"` AveragePrice float64 `json:"averageprice"` AuthorisedQuantity int64 `json:"authorisedquantity"` - ProfitAndLoss string `json:"profitandloss"` + ProfitAndLoss float64 `json:"profitandloss"` Product string `json:"product"` CollateralQuantity int64 `json:"collateralquantity"` CollateralType string `json:"collateraltype"`