Hi Dukascopy Team,
Thanks for taking care of the issue. The result is significatly better but still wrong :/
Let me refer to the same Position Id = 44977981.
Following snippet produces incorrect result comparing to web Position Report (attached):
public void onStart(IContext context) throws JFException {
Set<Instrument> ins = new HashSet();
ins.add(Instrument.EURUSD);
context.setSubscribedInstruments(ins, true);
IOrder o = context.getHistory().getHistoricalOrderById("44977981");
if (o != null) {
System.out.println("Order Id ......... " + o.getId());
System.out.println(" (1)Amount ......... " + o.getAmount());
System.out.println(" (2)Open Price ..... " + o.getOpenPrice());
System.out.println(" (3)Close Price .... " + o.getClosePrice());
System.out.println(" (4)Profit Pips .... " + o.getProfitLossInPips());
System.out.println(" (5)P/L Gross ...... " + o.getProfitLossInAccountCurrency());
System.out.println(" (6)Comission ...... " + o.getCommission());
System.out.println(" (7)P/L Net ........ " + (o.getProfitLossInAccountCurrency() - o.getCommission()));
}
}
Results:
Order Id ......... 44977981
(1)Amount ......... 1.2
(2)Open Price ..... 1.29821
(3)Close Price .... 1.2984675
(4)Profit Pips .... 2.6
(5)P/L Gross ...... 235.54
(6)Comission ...... 26.4
(7)P/L Net ........ 209.14
1) According to Position Report amount should be equal to 0.8 Mio. not 1.2;
2) According to PR open price should be: 1.29807 = (0.4 *1.29664 + 0.4*1.29949)/0.8;
3) According to PR close price should be: 1.29848 (calculated as above);
4) As a result of correct 2) and 3) profit pips shoud be 4.2 not 2.6;
5) According to PR it should be 257 not 235;
6) Commision seems to be right but only one way, should be doubled.
Can you please move the post back to bug section?
Thanks for quick fix and regards,
kurak