Calculating P/L

Created at 27 May 2021, 02:47
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
RY

ryanjadidi

Joined 27.05.2021

Calculating P/L
27 May 2021, 02:47


Hi,

I am trying to calculate P/L when I open a new position by using ProtoOANewOrderReq and then closing it by ProtoOAClosePositionReq.

In either of requests, response messages do not include execution price.

Can you point me to how to calculate P/L?

Thank you


@ryanjadidi
Replies

amusleh
27 May 2021, 09:52 ( Updated at: 27 May 2021, 09:58 )

Hi,

Before sending a ProtoOANewOrderReq/ProtoOAClosePositionReq you must be subscribed to ProtoOAExecutionEvent, there is no individual response messages for trading requests, everything related to trading operations will go to the ProtoOAExecutionEvent.

When you receive a ProtoOAExecutionEvent you can check the deal field, this filed is of type ProtoOADeal which has the executionPrice of close price.

For more information regarding closed position you can use the ProtoOADeal closePositionDetail field.

Regarding calculation of P/L, once you got the position volume, entry and close price, you have to calculate each symbol tick value to calculate a position P/L.

You can check our new WPF trading UI Demo, the sample has all these features.

For a tutorial you can check our new documentation symbol data tutorial.


@amusleh

olegchubukov
09 Sep 2021, 15:05 ( Updated at: 09 Sep 2021, 15:06 )

RE:

amusleh said:

Hi,

Before sending a ProtoOANewOrderReq/ProtoOAClosePositionReq you must be subscribed to ProtoOAExecutionEvent, there is no individual response messages for trading requests, everything related to trading operations will go to the ProtoOAExecutionEvent.

When you receive a ProtoOAExecutionEvent you can check the deal field, this filed is of type ProtoOADeal which has the executionPrice of close price.

For more information regarding closed position you can use the ProtoOADeal closePositionDetail field.

Regarding calculation of P/L, once you got the position volume, entry and close price, you have to calculate each symbol tick value to calculate a position P/L.

You can check our new WPF trading UI Demo, the sample has all these features.

For a tutorial you can check our new documentation symbol data tutorial.

Hi! GitHub url for WPF trading UI Demo, is not found.


@olegchubukov

PanagiotisCharalampous
09 Sep 2021, 15:10

Hi Oleg,

Just clone the repository.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 


@PanagiotisCharalampous