Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to calculate PNL using positions data & why PNL/MTM is not added in API itself ? #73

Closed
ShivdasBachewar opened this issue Oct 7, 2023 · 4 comments

Comments

@ShivdasBachewar
Copy link

I have two queries.

  1. Why Profit/loss value not added in response json positions_api
  2. considering its very complex to share profit/loss value in response,
    a) how to calculate profit or loss using given data..
    b) we get following data after hitting api
    {"stat": "Ok", "stCode": 200, "data": [{"buyAmt": "2625.00", "cfSellAmt": "0.00", "prod": "NRML", "exSeg": "nse_fo", "sqrFlg": "Y", "actId": "PRS2206", "cfBuyQty": "0", "cfSellQty": "0", "tok": "53179", "flBuyQty": "25", "flSellQty": "25", "sellAmt": "2625.00", "posFlg": "true", "cfBuyAmt": "0.00", "stkPrc": "0.00", "trdSym": "BANKNIFTY21JULFUT", "sym": "BANKNIFTY", "expDt": "29 Jul, 2021", "type": "FUTIDX", "series": "XX", "brdLtQty": "25", "exp": "1627569000", "optTp": "XX", "genNum": "1", "genDen": "1", "prcNum": "1", "prcDen": "1", "lotSz": "25", "multiplier": "1", "precision": "2", "hsUpTm": "2021/07/13 18:34:44"}]}
@geek-coder
Copy link

For intraday
use (buyAmt -sellAmt ) as initialValue .
get currentValue by getting netQty by ( flBuyQty - flSellQty) * current ltp
pnl = currentValue - initialValue

For carry forward use cf fields, similarlly.

@ShivdasBachewar
Copy link
Author

understood
you mean to say

pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);

@ShivdasBachewar
Copy link
Author

can kotak neo api add a field on pnl in json response

@Kotak-Neo
Copy link
Owner

Kotak-Neo commented Oct 10, 2023

Hi we have added the PnL calculation documentation in the Positions.md file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants