No m2m_realised or m2m_unrealised Data

sudarshangope
I wrote a code to fetch m2m realized and unrealized. It was working fine till afternoon, but suddenly it stopped giving any data in m2m_realized or unrealized section.

I use kite.margins() to fetch the data and filter using kite.margins['equity']['utilised']['m2m_realised']. Is there any issue with the api or am I doing it wrong.
  • SRIJAN
    SRIJAN edited August 2022
    There is no issue with KiteConnect APIs.

    Why don't you just read the traceback of the error in your code instead of writing on this forum for such common mistakes??

    This forum is purely dedicated to technical queries related to KiteConnect APIs.
  • sudarshangope
    Sorry if my question voids any forum rules. I am having a problem with the query output that KiteConnect API provides.

    There is no error messages or anything. I tried using new access token also ,but got the same data. Only change was when I buy any scrip the 'debits' value changes, but don't get any m2m_realized or unrealized value. It shows 0.

    As per my view, kite.margins function gives you the fund details. If you have any open position you get m2m_unrealized value and if the position is closed you get m2m_realized value.
  • sudarshangope
    This is the output that I got.


  • sudarshangope
    sudarshangope edited August 2022
    {'equity': {'enabled': True, 'net': 17639.95, 'available': {'adhoc_margin': 0, 'cash': 18987.9, 'opening_balance': 18987.9, 'live_balance': 17639.95, 'collateral': 0, 'intraday_payin': 0}, 'utilised': {'debits': 1347.95, 'exposure': 0, 'm2m_realised': 0, 'm2m_unrealised': 0, 'option_premium': 0, 'payout': 0, 'span': 0, 'holding_sales': 0, 'turnover': 0, 'liquid_collateral': 0, 'stock_collateral': 0, 'delivery': 0}}, 'commodity': {'enabled': False, 'net': 0, 'available': {'adhoc_margin': 0, 'cash': 0, 'opening_balance': 0, 'live_balance': 0, 'collateral': 0, 'intraday_payin': 0}, 'utilised': {'debits': 0, 'exposure': 0, 'm2m_realised': 0, 'm2m_unrealised': 0, 'option_premium': 0, 'payout': 0, 'span': 0, 'holding_sales': 0, 'turnover': 0, 'liquid_collateral': 0, 'stock_collateral': 0, 'delivery': 0}}}
  • sudarshangope
    @SRIJAN Do you think there is mistake from my end in the code?
  • SRIJAN
    SRIJAN edited August 2022
    You said, you are not getting any data,and the code you showed,you are directly using the method object kite.margins instead of calling the method like kite.margins().

    You should have said,you are getting 0 in the section,getting no data and getting 0 are 2 different things,and you also posted wrong code,I thought that's where the error is,a typo mistake,so I suggested you to check the traceback.



    Regarding the m2m_realised being 0,I checked the margins response and I am getting correct value for m2m_realised.

    Not sure what's the issue with you.
  • SRIJAN
    SRIJAN edited August 2022
    Did you square off your CNC positions today?

    https://support.zerodha.com/category/console/portfolio/holdings/articles/kite-funds-page-profit

    This might be the reason for both m2m_unrealised and m2m_realised being 0.
  • sudarshangope
    No, this is my test account. I don't do CNC trades in this. I had an open position yesterday, and I was fetching the m2m data, but I got 0 on both. Even today I got the same result.
  • themohammedfaisal
    themohammedfaisal edited August 2022
    Hi @sudarshangope, For futures marked to Market losses and MIS Equity, the m2m_realised field is updated in this field. Profits are not updated as same-day credit is not allowed as per the settlement cycle.
    If you need to keep a track of m2m/P&L, you can refer to positions m2m https://kite.trade/docs/connect/v3/portfolio/#positions
Sign In or Register to comment.