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.

The latest version, this function (getorders() ) is incorrect
 Post subject: The latest version, this function (getorders() ) is incorrect Post rating: 0   New post Posted: Tue 19 Mar, 2019, 07:09 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 24
Location: China,
package COM.Mystrategies;

import java.util.*;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;
import java.text.SimpleDateFormat;


public class GetOrdersTest implements IStrategy {
       @Configurable("Instrument")
    public Instrument actinstru = Instrument.USDJPY;
        @Configurable("Amount")
    public double OrderAmount = 0.061;
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
     private final SimpleDateFormat gmtSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.history = context.getHistory();
        this.context = context;
        this.indicators = context.getIndicators();
        this.userInterface = context.getUserInterface();
         Set<Instrument> instruments = new HashSet<Instrument>();

        instruments.add(actinstru);
       
        context.setSubscribedInstruments(instruments, true);
    }

    public void onAccount(IAccount account) throws JFException {
       
       
    }

    public void onMessage(IMessage message) throws JFException {
       
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
       
          if (!instrument.equals(this.actinstru)) {
            return;

        }
           if (period.equals(Period.FIVE_MINS))
           {
               submitTwoOrder();
                List<IOrder>  tempOrders=this.engine.getOrders();
                if(tempOrders.size()>1)
                {
                    if(tempOrders.get(0)!=null)
                     DeloneOrder(tempOrders.get(0));
                }
                 List<IOrder>  afterDelOrders=this.engine.getOrders();
                 int norderNums=afterDelOrders.size();
                for(int i=0;i<norderNums;i++)
                {
                     print(String.format("after del one order --cur ordr label=%s,cur order instru=%s --cur order fill time =%s",afterDelOrders.get(i).getLabel(),afterDelOrders.get(i).getInstrument(),gmtSdf.format(afterDelOrders.get(i).getFillTime())));
                }
           }
    }
    public int submitTwoOrder() throws JFException
    {
       List<IOrder>  curOrders=this.engine.getOrders();
       print(String.format("before submit --cur ordr nums=%d",curOrders.size()));
      if(curOrders.size()<1)
      {
         engine.submitOrder("MyMaketBuyOrder_1", actinstru, OrderCommand.BUY, OrderAmount );
         engine.submitOrder("MyMaketBuyOrder_2", actinstru, OrderCommand.BUY, OrderAmount );
         
      }
      curOrders=this.engine.getOrders();
       print(String.format("after submit --cur ordr nums=%d",curOrders.size()));
      int nRetNums=curOrders.size();
      return nRetNums;
    }
    public boolean DeloneOrder(IOrder specOrder) throws JFException
    {
        boolean bRet=true;
        print(String.format("cur order state--=%s",specOrder.getState()));
        if(specOrder.getState()== IOrder.State.FILLED)
        {
            specOrder.close();
            specOrder.waitForUpdate(1000);
        }
        List<IOrder>  curOrders=this.engine.getOrders();
        print(String.format("after del order --cur ordr nums=%d",curOrders.size()));
        return bRet;
       
    }
    private void print(Object o)
    {
        console.getOut().println(o);
    }
}



console print message :
Image


Attachments:
getordernums--error.png [77.6 KiB]
Downloaded 87 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: The latest version, this function (getorders() ) is incorrect Post rating: 0   New post Posted: Tue 19 Mar, 2019, 17:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6078
We were unable to reproduce this issue.
Could you provide more info for reproducing? Especially about orders in console log. When and under what condition they were opened? Did you do it manually or by strategy?

specOrder.waitForUpdate(1000);

It doesn't give you guarantee what after timeout this order will be closed. Closing order may take more than 1000 ms.
Instead, it is recommended to use
specOrder.waitForUpdate(IOrder.State.CLOSED);


Then you can be sure that order will be in closed state after waitForUpdate() method.


 
 Post subject: Re: The latest version, this function (getorders() ) is incorrect Post rating: 0   New post Posted: Fri 29 Mar, 2019, 09:02 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 24
Location: China,
The steps are as follows:
1)
Running strategy program
2)On the platform, after many times of manual work, opening a position, after closing a position,
This bug will appear!!!!
See the print log :
--(note : The currency pair running in the program is USD/JPY. On the platform, if the manually operated currency pair is not USD/JPY, such as: open, EUR/USD or GBP/USD ..., this kind of BUG will appear)

Image


Attachments:
orderbug.png [87.11 KiB]
Downloaded 83 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: The latest version, this function (getorders() ) is incorrect Post rating: 0   New post Posted: Wed 03 Apr, 2019, 21:21 
User avatar

User rating: 8
Joined: Mon 09 Jun, 2014, 21:07
Posts: 49
Location: Poland, Warsaw
Hi Dukascopy support,

I confirm, I am encountering exactly the same issue.

To reproduce the issue, create a dummy strategy with following implementation of onMessage method.
1) Start the strategy, then
2) start selling or buying eur/usd manually from JForex platform
3) observe the console, you will see that for each new order filled there are two entries with the same ExtID. One of the entry is broken IOrder object. The broken object has null fields.

   @Override
   public void onMessage(IMessage message) throws JFException {

      for (IOrder order : engine.getOrders()) {
         System.out.println(order);
      }

   }


Please fix ASAP.

Best regards,
Greg


 
 Post subject: Re: The latest version, this function (getorders() ) is incorrect Post rating: 0   New post Posted: Thu 04 Apr, 2019, 14:48 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6078
Fix will be available in next platform release.


 
 Post subject: Re: The latest version, this function (getorders() ) is incorrect Post rating: 0   New post Posted: Fri 05 Apr, 2019, 21:56 

User rating: 15
Joined: Thu 20 Apr, 2017, 22:42
Posts: 144
Location: Russian Federation,
And ... it would be nice to release updated JForext Client SDK. The latest one was released almost 5 month ago ...


 

Jump to:  

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