Jump to content
Sign in to follow this  
marc

How to calculate the PnL for a trade open on the FX market?

Recommended Posts

Could someone point out to me how to calculate the PnL related to a trade opened on the FX market? From the markets API, I get the ConvertPriceToPipsMultiplier equal to 10000whatever the market (EUR/USD, USD/JPY and even for non FX makets like the UK 100 DFT, etc…)

I use the following formula to calculate the PnL for a “Buy” order (the Current Price is depending of the order direction and will be either the Buy or Sell price):

PnL = (Current Price – Opening Price) * Quantity * ConvertPriceToPipsMultiplier

The number of decimal places for EUR/USD and USD/JPY markets are not the same, so ideally the multpliers I’m expecting would be 10000 for EUR/USD (which has 5 decimal places) and 100 for USD/JPY (which has 3 decimal places). Instead as the multiplier is always 10000, I get a PnL way too big for the USD/JPY trade.

Is there something wrong with the ConvertPriceToPipsMultiplier value returned by the markets API or am I doing something wrong in using this multipier in the PnL calculation?

Marc

Share this post


Link to post

Marc:

ConvertPriceToPipsMultiplier is being used incorrectly. Using our new CIAPI docs Index of Parameters CIAPI Docs I can see the definition for this to be:

“Multiplier used to calculate the significance of the price tolerance to the appropriate decimal place.”

That’s why you are receiving 10,000 all the time.

Since we stream open trade equity for a trade via the TradeMargin stream, please pull the OTEConverted property from the TradeMarginDTO and that will give your open PnL. You don’t need to calculate PnL manually anymore.

Share this post


Link to post

Only problem with using the TradeMargin is that updates from that stream are far from being very frequent: over a 1 min period with a trade open on the EUR/USD DFT market, I received only 5 or 6 updates maximum from the TradeMargin stream (while the market was moving much more frequently!). As I’d like to display a PnL at trade level that changes at the same pace as the underlying market, I have to resort to calculating the PnL myself…

Marc

Share this post


Link to post

Only problem with using the TradeMargin is that updates from that stream are far from being very frequent: over a 1 min period with a trade open on the EUR/USD DFT market, I received only 5 or 6 updates maximum from the TradeMargin stream (while the market was moving much more frequently!). As I’d like to display a PnL at trade level that changes at the same pace as the underlying market, I have to resort to calculating the PnL myself…

Marc

Marc: Have you used the TradeMargin stream recently? There is a query in the FAQs here (http://faq.labs.cityindex.com/questions/big-delay-on-margin-stream-first-message-received-and-slow-update-cadence-unrealised-p-l), where the TradeMargin performance was slow. However, it appers to be responsive again.

Can you check if you are getting a responsive TradeMargin stream?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×