Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

IOrder.getCommission returns 0.0
 Post subject: IOrder.getCommission returns 0.0 Post rating: 1   New post Posted: Tue 01 Jul, 2014, 12:16 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
Hello,

1 - Part of my code is a bit similar to the first onMessage example here: https://www.dukascopy.com/wiki/#Manage_Order_State.
I also need to get the commission and net Profit in account currency in that method. I have no problem to get the gross profit and other parameters. But, unfortunately, I always get 0.0 with getCommission (same in USD). This is weird; I don't see anything wrong in the simple code:
   public final void onMessage(final IMessage message) throws JFException {
        try {
            IOrder io;
            switch (message.getType()) {
                case ORDER_FILL_OK:
                    // for new positions
                    io = message.getOrder();
                    LOGGER.debug("[ORDER_FILL_OK][Order]: {}", io);
                    LOGGER.info("[ORDER_FILL_OK]Filled in: {} ms", io.getFillTime() - io.getCreationTime());
                    LOGGER.debug("[ORDER_FILL_OK]Commission: {}", io.getCommission());
                    //newPosition(io);
                    break;
                 case ORDER_CLOSE_OK:
                    //Closing automatically position (totally or partially)
                    io = message.getOrder();
                    LOGGER.debug("[ORDER_CLOSE_OK][Order]: {}", io);
                    LOGGER.debug("[ORDER_CLOSE_OK]Commission: {}", io.getCommission());
                    //closeTrade(io);
                    break;
         }
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
Example of log:
2014-07-01 06:45:12,109-DEBUG-         GetMessages:147 - [ORDER_FILL_OK][Order]: [jfnn9l618]-FILLED / EUR/USD / 1.3681 / 0.0049 / 0.0049
2014-07-01 06:45:12,109- INFO-         GetMessages:148 - [ORDER_FILL_OK]Filled in: 17 ms
2014-07-01 06:45:12,221-DEBUG-         GetMessages:267 - [ORDER_FILL_OK] Commission: 0.0
I also get 0.0 when the position is closed.

2 - To debug this (and also to get the swap), I tried to get a list of IReportPositions for all closed positions. Unfortunately this list is empty (size=0) when there are actually 5 closed positions in that timeframe! Here is an extract of the code:
    public void onStart(final IContext context) throws JFException {
       try {
            // Get commission for all trades in last 48h
            DateTime StartTime = DateTime.now().plusHours(-48);
            DateTime StopTime = DateTime.now();
            LOGGER.debug("Getting ReportService Closed Positions between {} and {}: starting", StartTime, StopTime);
            List<IReportPosition> mylist = context.getReportService().getClosedPositions(StartTime.getMillis(),
                    StopTime.getMillis());
            LOGGER.debug("Getting ReportService Closed Positions: ended");
            LOGGER.debug("Size of list = {}", mylist.size());
        } catch (Exception e) {
            LOGGER.error(e.getMessage(),e);
        }
    }
These are the logs:
2014-07-01 10:43:20,714-DEBUG-         GetMessages: 56 - Getting ReportService Closed Positions between 2014-06-29T10:43:20.542Z and 2014-07-01T10:43:20.634Z: starting
2014-07-01 10:43:21,167-DEBUG-         GetMessages: 59 - Getting ReportService Closed Positions: ended
2014-07-01 10:43:21,168-DEBUG-         GetMessages: 60 - Size of list = 0
Am I missing something here? I am using the latest version available on the maven repository (2.36) with a demo account.
Thank you in advance for any help on this!


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 01 Jul, 2014, 12:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
fxbird wrote:
But, unfortunately, I always get 0.0 with getCommission (same in USD). This is weird;
We have registered this.
fxbird wrote:
2 - To debug this (and also to get the swap), I tried to get a list of IReportPositions for all closed positions. Unfortunately this list is empty (size=0) when there are actually 5 closed positions in that timeframe! Here is an extract of the code:
Don't use the report service module, it will get deprecated with future releases.


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 01 Jul, 2014, 13:17 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
API Support wrote:
fxbird wrote:
But, unfortunately, I always get 0.0 with getCommission (same in USD). This is weird;
We have registered this.
fxbird wrote:
2 - To debug this (and also to get the swap), I tried to get a list of IReportPositions for all closed positions. Unfortunately this list is empty (size=0) when there are actually 5 closed positions in that timeframe! Here is an extract of the code:
Don't use the report service module, it will get deprecated with future releases.
Ok, is there another way to get commission and swap?


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 01 Jul, 2014, 13:52 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
fxbird wrote:
Ok, is there another way to get commission and swap?
Programmatically - no.


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 01 Jul, 2014, 13:59 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
API Support wrote:
fxbird wrote:
Ok, is there another way to get commission and swap?
Programmatically - no.
Then, is there a way, programmatically, to get a position net P&L?
I can get gross P&L with getProfitLossInAccountCurrency, but without commission and swap, I can't calculate net P&L :? This is a major metric for me.


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 01 Jul, 2014, 14:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
viewtopic.php?f=65&t=44817&p=58953#p58869


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 01 Jul, 2014, 18:02 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
API Support wrote:
Thank you for the link. All the methods in the Commissions object returned by the getCommissions (suggested in that topic) are marked as deprecated in the javadoc :? I will try anyway...

Edit: I understand why they are deprecated. The values returned are incorrect. I will "hard-code" the commissions levels before calculating the commission for each order.


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Mon 28 Jul, 2014, 11:43 

User rating: 0
Joined: Wed 10 Jul, 2013, 22:49
Posts: 24
Location: Slovakia, Bratislava
again there is this error
IOrder.getCommission returns 0.0


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Thu 07 Aug, 2014, 11:54 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We are working on this.


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Mon 08 Dec, 2014, 17:32 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
IOrder.getCommission returns 0.0 again on current JForex DEMO for open positions.
Find a code example attached.
Please fix this.

Seen on JForex DEMO 2.42.3


Attachments:
CommissionTest.java [1.54 KiB]
Downloaded 98 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: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 09 Dec, 2014, 08:32 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Do you have that problem on global account?


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 09 Dec, 2014, 10:43 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
No, it is a normal hedging account.
I just tried this bug on DEMO2dCZqn and JForex 2.42.3
Same behavior.
Please fix this bug.


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Tue 09 Dec, 2014, 14:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We will investigate.


 
 Post subject: Re: IOrder.getCommission returns 0.0 Post rating: 0   New post Posted: Wed 10 Dec, 2014, 13:18 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Fix for this issue will be available in next JForex platform release.


 

Jump to:  

cron
  © 1998-2025 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