In Portfolio API, PNL or MTM amount is not updated at each second.

yrb
In Portfolio API, PNL or MTM amount is not updated at each second. I am not sure at what duration is getting updated.
But in Kite App it shows for each tick, then why not in API?
Tagged:
  • sujith
    You can check out this thread.
  • zw0330
    zw0330 edited June 2020
    public void getmtm()
    {
    kite = new Kite(MyAPIKey, Debug: true);
    initSession();
    kite.SetAccessToken(MyAccessToken);

    PositionResponse positions = kite.GetPositions();
    //pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
    decimal pnls = 0;
    for (int i = 0; i < positions.Net.Count; i++)
    {
    Dictionary<string, Quote> ohlcs = kite.GetQuote(InstrumentId: new string[] { positions.Net[i].InstrumentToken.ToString() });
    decimal LastPrice = 0;
    foreach (KeyValuePair<string, Quote> entry in ohlcs)
    {
    LastPrice = entry.Value.LastPrice;
    }

    pnls += (positions.Net[i].SellValue - positions.Net[i].BuyValue) +
    (positions.Net[i].Quantity * LastPrice * positions.Net[i].Multiplier);
    }
    //get pnl in label
    lbl_mtm.Text = pnls.ToString();


    }
    Learn Algo Trading

    https://youtube.com/watch?v=wFih_6X5nV8&t=11s
Sign In or Register to comment.