Mida
Mida copied to clipboard
Profit calculation on currency pairs with JPY as the quote currency is not accurate.
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
- Make sure there is an open position with JPY as the quote currency e.g EURJPY, USDJPY e.tc
- Get the open positions.
- Loop through the open positions and calculate the unrealizedProfit/loss
WHAT TO NOTE
- The profit/loss calculation for other pairs is accurate
- 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) ;