Dukascopy
 
 
Wiki JStore Search Login

IHistory getProfitLossInAccountCurrency and getCommision for merged positions returns very wrong results.
 Post subject: IHistory getProfitLossInAccountCurrency and getCommision for merged positions returns very wrong results. Post rating: 0   New post Posted: Thu 13 Dec, 2012, 11:36 
User avatar

User rating: 7
Joined: Fri 13 Jan, 2012, 20:49
Posts: 94
Location: Poland, Warsaw
Hi Support Team,

IMO there is a monster bug in the API. Methods getProfitLossInAccountCurrency() and getCommision() for IOrder retrieved from IHistory for merged orders returns completly wrong results.

Example from demo account, position id: 44977981:

Posistion report on Dukascopy web page: P/L Net = +204 EUR
getProfitLossInAccountCurrency() - getCommision() = -131-10= -141 EUR
Attachment:
ex2.png [36.76 KiB]
Downloaded 374 times

Please treat it with high priority.

thanks and best regards,
kurak


 
 Post subject: Re: IHistory getProfitLossInAccountCurrency and getCommision for merged positions returns very wrong results. Post rating: 0   New post Posted: Thu 20 Dec, 2012, 23:23 
User avatar

User rating: 7
Joined: Fri 13 Jan, 2012, 20:49
Posts: 94
Location: Poland, Warsaw
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


Attachments:
PositionReport.png [24.34 KiB]
Downloaded 398 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: IHistory getProfitLossInAccountCurrency and getCommision for merged positions returns very wrong results. Post rating: 0   New post Posted: Fri 21 Dec, 2012, 14:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The fix will be available in a next API version.


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com