Yes the data is already avail and pre-calculated in the console but still want to know how is the calculation done, i am saving daily orderbook for lookback.
You can use the formula below: Closed position: Realised MTM for long = sell price - Previous close Realised MTM for short = Previous close - buy price
Open position: Unrealised MTM for long = LTP - Previous close Unrealised MTM for short = Previous close - LTP
Closed position:
Realised MTM for long = sell price - Previous close
Realised MTM for short = Previous close - buy price
Open position:
Unrealised MTM for long = LTP - Previous close
Unrealised MTM for short = Previous close - LTP