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.

Global account - orders stay in CREATED state
 Post subject: Global account - orders stay in CREATED state Post rating: 0   New post Posted: Tue 21 Feb, 2017, 22:11 
User avatar

User rating: 0
Joined: Thu 21 Aug, 2014, 08:37
Posts: 17
Location: PolandPoland
Good morning,

I would like to report a problem I've encountered.

I use a global account, and a strategy running remotely. According to the diagram from API documentation, orders placed using IEngine.submitOrder() should have CREATED state at the beginning, and then go through OPENED to FILLED (assuming standard case). Next, object representing that order should end it's life, and the overall position on the account should be updated.

I've got a repeatable problem with this flow. I'm pretty sure it's a bug.

Scenario:

1) Strategy starts.
2) Strategy submits an order using IEngine.submitOrder() method.
3) Order is properly placed and filled. Account's position is updated. On platform's UI, everything looks correctly - there is one record in "positions" tab and none in "orders".
4) Some time later (e.g. 15 minutes), strategy gets a list of existing orders using IEngine.getOrders(Instrument) method. There are two separate orders on the list - the overall account's position and the order placed in 2nd step, still in CREATED state.

Expected:

In step 4) there should be only the overall account's position on the list. The second order should go from CREATED state through OPENED to FILLED, and finally should be deleted - after all, it was successfully filled, but on the list it's still in CREATED state.

As a side note - there should also be an onMessage() event generated with ORDER_FILL_OK message for this order. There was no such event.

Example:

Quote:
Messages from logs - submitting SELL order:

Order SELL 5000 EUR/USD @ MKT is sent at 2017-02-21 17:15:03.067 GMT by the strategy "EURUSD_15_20170219": from the remote server
Order ACCEPTED: #330923690 SELL 0.005 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0001
Order FILLED at 1.055 (#330923690 SELL 0.005 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0001) - Position #35937EUR/USD

List of orders - 15 minutes later:

[SHORT_1487696400000_0]-CREATED / EUR/USD / 1.055 / 0.005 / 0.005
[35937EUR/USD]-FILLED / EUR/USD / 1.055 / 0.005 / 0.005

This happens to every order submitted by the strategy. After submitting and filling 5 orders, I've got 6 records on the list, including 5 orders in CREATED state.

The only way to clear the list is to stop and restart the strategy.

What's more, I was using the same code over a year ago, and there were no problems like this. Everything was working exactly as described in API documentation.

Could you please take a look at this?

Best regards,
G.


 
 Post subject: Re: Global account - orders stay in CREATED state Post rating: 0   New post Posted: Mon 13 Mar, 2017, 13:57 
User avatar

User rating: 0
Joined: Thu 21 Aug, 2014, 08:37
Posts: 17
Location: PolandPoland
Hello,

Just a few additional notes.

Problem still occurs, currently my strategy is reporting 15 orders returned by IEngine.getOrders(Instrument), including one main position and 14 orders in CREATED state (although they were properly filled, modifying the main position). I'm pretty sure it's againt the documented flow.

Two weeks ago my strategy was running during the weekend, and the list of orders were cleared just before the market's opening (according to logs, CREATED orders has been cancelled / invalidated by the system). But yesterday it didn't happen - IEngine.getOrders(Instrument) still returns a list containing orders filled in the previous week.

Could someone please confirm if this should be considered a bug?


 
 Post subject: Re: Global account - orders stay in CREATED state Post rating: 0   New post Posted: Fri 24 Mar, 2017, 15:05 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We were unable to reproduce this. Please provide code that would reproduce the issue.


 
 Post subject: Re: Global account - orders stay in CREATED state Post rating: 0   New post Posted: Fri 07 Apr, 2017, 11:00 
User avatar

User rating: 0
Joined: Thu 21 Aug, 2014, 08:37
Posts: 17
Location: PolandPoland
Hello,

Yes, of course I can provide the code. But there is really nothing unusual.

Here's the simplest possible case implemented - a "strategy" submitting three orders and printing the list acquired by engine.getOrders() on every bar.

package jforex;

import java.util.*;
import com.dukascopy.api.*;

public class BugReproduce implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private boolean ordersSubmitted = false;
   
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
       
        Set<Instrument> instrumentSet = new HashSet<Instrument>();
        instrumentSet.add(Instrument.EURUSD);
        context.setSubscribedInstruments(instrumentSet, true);
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
        if (!ordersSubmitted)
        {
            ordersSubmitted = true;

            IOrder order1 = engine.submitOrder("ORDER_1", Instrument.EURUSD, IEngine.OrderCommand.BUY, 0.001, 0, 2);
            IOrder order2 = engine.submitOrder("ORDER_2", Instrument.EURUSD, IEngine.OrderCommand.BUY, 0.001, 0, 2);
            IOrder order3 = engine.submitOrder("ORDER_3", Instrument.EURUSD, IEngine.OrderCommand.BUY, 0.001, 0, 2);
        }
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        console.getOut().println("-----------------------------------");
       
        List<IOrder> orderList = engine.getOrders(instrument);
       
        for (IOrder order : orderList)
            console.getOut().println(order);
    }
   
    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }
}


I'm running this on remote server. Tested on both live and demo account (in global mode of course).

And here's the result:

   07.04.2017 09:39:51   [1392280EUR/USD]-FILLED / EUR/USD / 1.06337 / 0.003 / 0.003
   07.04.2017 09:39:51   [ORDER_3]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:39:51   [ORDER_2]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:39:51   [ORDER_1]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:39:51   -----------------------------------
   07.04.2017 09:39:41   [1392280EUR/USD]-FILLED / EUR/USD / 1.06337 / 0.003 / 0.003
   07.04.2017 09:39:41   [ORDER_3]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:39:41   [ORDER_2]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:39:41   [ORDER_1]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:39:41   -----------------------------------
   07.04.2017 09:39:36   Order FILLED at 1.06337 (#502545920 BUY 0.001 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0002) - Position #1392280EUR/USD
   07.04.2017 09:39:36   Order FILLED at 1.06337 (#502545921 BUY 0.001 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0002) - Position #1392280EUR/USD
   07.04.2017 09:39:36   Order ACCEPTED: #502545921 BUY 0.001 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0002
   07.04.2017 09:39:36   Order ACCEPTED: #502545920 BUY 0.001 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0002
   07.04.2017 09:39:36   Order FILLED at 1.06337 (#502545918 BUY 0.001 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0002) - Position #1392280EUR/USD
   07.04.2017 09:39:36   Order ACCEPTED: #502545918 BUY 0.001 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0002
   07.04.2017 09:39:35   Order BUY 1000 EUR/USD @ MKT is sent at 2017-04-07 09:39:35.875 GMT by the strategy "BugReproduce": from the remote server
   07.04.2017 09:39:35   Order BUY 1000 EUR/USD @ MKT is sent at 2017-04-07 09:39:35.777 GMT by the strategy "BugReproduce": from the remote server
   07.04.2017 09:39:35   Order BUY 1000 EUR/USD @ MKT is sent at 2017-04-07 09:39:35.760 GMT by the strategy "BugReproduce": from the remote server
   07.04.2017 09:39:29   Strategy "BugReproduce" Strategy ID: is started at 2017-04-07 09:39:29.223 GMT on the remote server with no parameters


No matter how long I wait, the orders are still on the list (in CREATED state):

   07.04.2017 09:41:21   [1392280EUR/USD]-FILLED / EUR/USD / 1.06337 / 0.003 / 0.003
   07.04.2017 09:41:21   [ORDER_3]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:41:21   [ORDER_2]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001
   07.04.2017 09:41:21   [ORDER_1]-CREATED / EUR/USD / 1.06337 / 0.001 / 0.001


Hope that will help you reproduce the problem.

Best regards,
G.


 
 Post subject: Re: Global account - orders stay in CREATED state Post rating: 0   New post Posted: Wed 10 May, 2017, 08:11 
User avatar

User rating: 13
Joined: Mon 27 Jul, 2015, 16:30
Posts: 110
Location: Canada, Mission
import java.util.*;
import com.dukascopy.api.*;

public class BugReproduce implements IStrategy {
private IEngine engine;
private IConsole console;
private boolean ordersSubmitted = false;

public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();

Set<Instrument> instrumentSet = new HashSet<Instrument>();
instrumentSet.add(Instrument.EURUSD);
context.setSubscribedInstruments(instrumentSet, true);
}

public void onTick(Instrument instrument, ITick tick) throws JFException {
if (!ordersSubmitted)
{
ordersSubmitted = true;

engine.submitOrder("ORDER_1", Instrument.EURUSD, IEngine.OrderCommand.BUY, 0.001, 0, 2);
engine.submitOrder("ORDER_2", Instrument.EURUSD, IEngine.OrderCommand.BUY, 0.001, 0, 2);
engine.submitOrder("ORDER_3", Instrument.EURUSD, IEngine.OrderCommand.BUY, 0.001, 0, 2);
}
}

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
console.getOut().println("-----------------------------------");

List<IOrder> orderList = engine.getOrders(instrument);

for (IOrder order : orderList)
console.getOut().println(order);
}

public void onAccount(IAccount account) throws JFException {
}

public void onMessage(IMessage message) throws JFException {
}

public void onStop() throws JFException {
}
}


 
 Post subject: Re: Global account - orders stay in CREATED state Post rating: 0   New post Posted: Fri 07 Jul, 2017, 13:12 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We were unable to reproduce this.


 

Jump to:  

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