average price calculation for multiple orders

maddy123
Hello everyone,

I want to calculate the pnl for a particular instrument (similar to what is shown in kite web positions tab). If I place multiple orders of same instrument throughout the day, each executed at different "average_price" (which I get from websocket order update). how to calculate the final average price for that instrument.

I went through multiple discussions like getposition-is-not-having-updated-value in the forum where it was suggested to calculate pnl our own instead of abusing order api every few seconds.

also went throughpnl calculation discussion but not clear how to get average of the day. giving an example/formula will help

Example (websocket update)
  1. trading_symbol:BANKNIFTYXXX35000PE
    order_Id:1
    average_price :305
    filled_quantity:100
    transaction_type : BUY
  2. trading_symbol :BANKNIFTYXXX35000PE
    order_Id:2
    average_price:312
    filled_quantity:110
    transaction_type:BUY
  3. trading_symbol :BANKNIFTYXXX35000PE
    order_Id:3
    average_price:350
    filled_quantity:50
    transaction_type:SELL
  4. trading_symbol :BANKNIFTYXXX35000PE
    order_Id:4
    average_price:360
    filled_quantity:100
    transaction_type:BUY
now average_price of BANKNIFTYXXX35000PE ???

TIA
Sign In or Register to comment.