Dukascopy
 
 
Wiki JStore Search Login

JFOREX-3408 Is there a problem with IOrder.getCommissionInUSD()?
 Post subject: back testing statistics Post rating: 0   Post Posted: Wed 14 Dec, 2011, 03:03 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
The function createReport() generates such a huge .html file that it is not possible to open it in any browser I have tried. Is there any way inside a JForex strategy to output the "Finish deposit" field that appears in the report?
Are there any back test result statistics functions? Such as, NAV as a function of time, number of wins, number of losses, distribution of trade results... you know, the standard stuff that backtesters need.

Yes, I could output all of the IOrder's which come into onMessage and then spend a week writing my own functions (reinventing the wheel)... but surely they already exist somewhere?


PS, I am registered as "DEMO3bcnAk" at the moment.


 
 Post subject: Re: back testing statistics Post rating: 0   Post Posted: Thu 15 Dec, 2011, 07:53 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
Hmm, I am really shocked at the lack of back testing statistics results. Am I just missing something? Is there a function somewhere to generate statistics for the results of a back test? CreateReport() is useless for any meaningful length of integration because the files are too large to load into any browser. 32MB for a couple of days.

Also, it is slightly annoying the way that if you type a comment into the forum but forgot to log in, then when you log in you get returned to the home page of the forums and lose what you typed!


 
 Post subject: Re: back testing statistics Post rating: 0   Post Posted: Thu 15 Dec, 2011, 12:56 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This functionality is planned to be implemented in the future.
For now there are two options:
  • run strategy in short periods of time
  • compute and output statistics in your code


 
 Post subject: Re: back testing statistics Post rating: 0   Post Posted: Tue 20 Dec, 2011, 04:51 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
Is it possible to access the "Eq:" field which is printed out during the JForex back tests?

E.g. this is output to the console:
"2011-12-11 05:33:53.978 INFO Main - Running, Thu 2011.12.08 12:30 Eq: 999,998.64 UoL: .00%"

If we could access the figure 999,998.64 after each transaction (FILLED order) then we could write something to output results statistics.

PS I am mtthwbrnd, this DEMO2NjPXV is a temporary account.


 
 Post subject: Re: back testing statistics Post rating: 0   Post Posted: Tue 20 Dec, 2011, 13:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Equity can be obtained from IAccount interface in onAccount method:
   public void onAccount(IAccount account) throws JFException {
        console.getOut().println(account.getEquity());
   }


 
 Post subject: JFOREX-3408 Is there a problem with IOrder.getCommissionInUSD()? Post rating: 0   Post Posted: Wed 28 Dec, 2011, 04:30 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
The attached extremely simple strategy, which opens a position and then closes it (and outputs some diagnostic info) results in commissions reported in report.html generated by ITesterClient.createReport(...) which are inconsistent with the reports from IOrder.getCommissionInUSD().

The IOrder.getCommissionInUSD() and IOrder.getCommission() both report $24 for the round trip.

ITesterClient.createReport(...) reports "Comission in USD" as $36.94.

Which one is correct?

This is the output from running the strategy on GBP for a few ticks...
Quote:
TICK:, 04/Oct/2011 21:00:00, 1.53925, 1.5391
TICK:, 04/Oct/2011 21:00:00, 1.53925, 1.5391
ORDER:, 0.0, 0.0, 0.0
MESSAGE:ORDER_SUBMIT_OK - Order submitted order: OPENED BUY 1.0 @ 0.0
MESSAGE.ORDER:1, AnOrder, 04/Oct/2011 21:00:00, 01/Jan/1970 10:00:00, BUY, OPENED, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
MESSAGE:ORDER_FILL_OK - Order filled order: FILLED BUY 1.0 @ 1.53925
MESSAGE.ORDER:1, AnOrder, 04/Oct/2011 21:00:00, 04/Oct/2011 21:00:00, BUY, FILLED, 1.0, 1.0, 1.53925, 0.0, 12.0, -150.0, -150.0, 12.0
TICK:, 04/Oct/2011 21:00:01, 1.53928, 1.53914
ORDER:, -110.0, 12.0, 12.0
TICK:, 04/Oct/2011 21:00:01, 1.53929, 1.53916
ORDER:, -90.0, 12.0, 12.0
MESSAGE:ORDER_CLOSE_OK - Order closed order: CLOSED BUY 1.0 @ 1.53925
MESSAGE.ORDER:1, AnOrder, 04/Oct/2011 21:00:00, 04/Oct/2011 21:00:00, BUY, CLOSED, 1.0, 1.0, 1.53925, 1.53916, 24.0, -90.0, -90.0, 24.0
TICK:, 04/Oct/2011 21:00:01, 1.53933, 1.53918
ORDER:, -90.0, 24.0, 24.0
TICK:, 04/Oct/2011 21:00:01, 1.53933, 1.5392
ORDER:, -90.0, 24.0, 24.0


PS I am user mtthwbrnd but somehow that username does not appear when I post.


Attachments:
File comment: not allowed to upload .html so remove the .java tag to view Report.html file.
Report.html.java [3.47 KiB]
Downloaded 369 times
IncorrectCommissionInHTMLReport.java [2.23 KiB]
Downloaded 380 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: JFOREX-3408 Is there a problem with IOrder.getCommission Post rating: 0   Post Posted: Fri 30 Dec, 2011, 01:03 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
Here is some simpler code to illustrate the issue:

package Strategies;
import com.dukascopy.api.*;
public class IncorrectCommissionInHTMLReport implements IStrategy {
   IContext context;
   int callcount;
   IOrder Order;
   public void onStart(IContext context) throws JFException {
      this.context = context;
   }
   public void onTick(Instrument instrument, ITick tick) throws JFException {
      if (callcount == 1)
         Order = context.getEngine().submitOrder("AnOrder", instrument,
               IEngine.OrderCommand.BUY, 1);
      if (callcount == 3)
         Order.close();
      if (Order != null) {
         System.out
               .println("Order.getCommission():" + Order.getCommission());
         System.out.println("Order.getCommissionInUSD():"
               + Order.getCommissionInUSD());
      }
      callcount = callcount + 1;
   }

   public void onMessage(IMessage message) throws JFException {   }
   public void onAccount(IAccount account) throws JFException {}
   public void onStop() throws JFException {}
   public void onBar(Instrument instrument, Period period, IBar askBar,
         IBar bidBar) throws JFException {}
}


Here is the output:
Quote:
Order.getCommission():0.0
Order.getCommissionInUSD():0.0
Order.getCommission():12.0
Order.getCommissionInUSD():12.0
Order.getCommission():12.0
Order.getCommissionInUSD():12.0
Order.getCommission():24.0
Order.getCommissionInUSD():24.0
Order.getCommission():24.0
Order.getCommissionInUSD():24.0
Order.getCommission():24.0
Order.getCommissionInUSD():24.0
Order.getCommission():24.0
Order.getCommissionInUSD():24.0


So the Order.getCommissionInUSD() and Order.getCommission() both say the commission is 24 but the Report.html output by ITesterClient.createReport(...) which I attached in the previous post reports a commission of $36.94 in USD. They cannot all be correct. 24 GBP is 36.94 USD so it looks as though the Order.getCommissionInUSD() is incorrect.

Is somebody looking at this?


 
 Post subject: Re: JFOREX-3408 Is there a problem with IOrder.getCommission Post rating: 0   Post Posted: Fri 30 Dec, 2011, 09:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
DEMO2NjPXV wrote:
Is somebody looking at this?
The issue has been registered.


 
 Post subject: Re: JFOREX-3408 Is there a problem with IOrder.getCommission Post rating: 0   Post Posted: Wed 04 Jan, 2012, 01:28 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
Replacing calls to IOrder.getCommissionInUSD() with calls to
public static double GetCommissionUSD(IOrder Order)
below fixes the issue for currencies which involve USD as one side of the pair.

   // Dukas platform contains a bug, change to false when fixed.
   // https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=44988
   public static final boolean COMMISSIONBUG = true;

   public static boolean Inverted(Instrument instrument) {
      return !instrument.getSecondaryCurrency().getCurrencyCode()
            .equals("USD");
   }

   public static double GetCommissionUSD(IOrder Order) {
      if (!COMMISSIONBUG)
         return Order.getCommissionInUSD();

      if (Inverted(Order.getInstrument()))
         return Order.getCommissionInUSD();

      return Order.getCommissionInUSD() * Order.getOpenPrice();

   }


 
 Post subject: Re: back testing statistics Post rating: 0   Post Posted: Thu 05 Jan, 2012, 00:22 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
It does not work. It gives a different result to createReport(). I might post an example soon, more likely to do that if there is any interest shown in solving the issue and the related getCommissionInUSD() issue https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=44988.


 
 Post subject: Re: back testing statistics Post rating: 0   Post Posted: Thu 05 Jan, 2012, 12:51 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Could you please pinpoint where do you find equity shown in report?


 
 Post subject: Re: back testing statistics Post rating: 0   Post Posted: Thu 05 Jan, 2012, 14:34 
User avatar

User rating: 0
Joined: Tue 29 Nov, 2011, 02:17
Posts: 25
Location: Australia,
It is listed in the report under "Finish deposit". Is the Finish Deposit field the Equity after the strategy has finished running? I.e should it be equal to the value of getEquity() when called in onStop()?


 

Jump to:  

  © 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