Mida icon indicating copy to clipboard operation
Mida copied to clipboard

Profit calculation on currency pairs with JPY as the quote currency is not accurate.

Open Georgemburu opened this issue 3 years ago • 0 comments

Calling the method getUnrealizedGrossProfit() on a position with a currency pair that has JPY as the quote currency gives an inaccurate profit value, even after adding commission gotten from the method call getUnrealizedGrossProfit() to the unrealizedGrossProfitValue.

ENVIRONMENT

##Broker : Pepperstone

##Trading Software: cTrader

##Account type: DEMO

##Libraries: Mida, Mida-ctrader

HOW TO REPRODUCE THE ERROR

  1. Make sure there is an open position with JPY as the quote currency e.g EURJPY, USDJPY e.tc
  2. Get the open positions.
  3. Loop through the open positions and calculate the unrealizedProfit/loss

WHAT TO NOTE

  1. The profit/loss calculation for other pairs is accurate
  2. The profit/loss calculation for currency pairs with JPY as the quote currency is inaccurat.

const unrealizedCommision = await position.getUnrealizedCommission(); const unrealizedGrossProfit = await position.getUnrealizedGrossProfit(); const profit = unrealizedGrossProfit-Math.abs(unrealizedCommision) ;

Georgemburu avatar Jun 09 '22 16:06 Georgemburu