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.

Demo account, engine.getOrders(instrument)
 Post subject: Demo account, engine.getOrders(instrument) Post rating: 0   New post Posted: Tue 29 Apr, 2014, 12:35 
User avatar

User rating: 1
Joined: Thu 24 Nov, 2011, 09:09
Posts: 36
Location: FranceFrance
Demo account: Since this morning, April 29, 2014, the following method returns 0 counts of FILLED orders, while there are open positions !
Both Remote and Local modes are affected.

Thanks for fixing this malfunction.

almc


public int howMany() throws JFException {
int counter = 0;
for (IOrder order : engine.getOrders(instrumentG)) {
if (order.getState() == IOrder.State.FILLED) {
counter++;
}
}
return counter;
}


 
 Post subject: Re: Demo account, engine.getOrders(instrument) Post rating: 0   New post Posted: Tue 29 Apr, 2014, 15:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We could not replicate this by using the following startegy:
package jforex.orders2;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;

public class OneOrderGetOrdersByInstrument implements IStrategy {

    private IConsole console;
    private IEngine engine;

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

        // create an order and check if it is instantly in engine.getOrders()
        IOrder order = engine.submitOrder("MyOrder", Instrument.EURUSD, OrderCommand.BUY, 0.01);
        printOrderData(order, "on creation");
        order.waitForUpdate(2000, IOrder.State.FILLED);
        printOrderData(order, "after fill");
        order.close();
        order.waitForUpdate(2000, IOrder.State.CLOSED);
        printOrderData(order, "after close");
    }

    private void printOrderData(IOrder order, String comment) throws JFException {
        console.getOut().format(comment + " engine order count = %s engine contains MyOrder = %s ",
                        engine.getOrders(Instrument.EURUSD),
                        engine.getOrders(Instrument.EURUSD).contains(order)
        ).println();
    }

    public void onStop() throws JFException {
        for (IOrder o : engine.getOrders())
            o.close();
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
        if (message.getOrder() != null && message.getType() != IMessage.Type.NOTIFICATION) {
            console.getNotif().println(message);
        }
    }

    public void onAccount(IAccount account) throws JFException {
    }
}

Please provide a strategy which replicates the case.


Attachments:
OneOrderGetOrdersByInstrument.java [1.75 KiB]
Downloaded 140 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: Demo account, engine.getOrders(instrument) Post rating: 0   New post Posted: Tue 29 Apr, 2014, 16:36 
User avatar

User rating: 1
Joined: Thu 24 Nov, 2011, 09:09
Posts: 36
Location: FranceFrance
I see now that the problem is more particular.

Created by your code positions are well reported both by your code and by my snippet (see below).

This is the already existing position well reported in platform Tabs that remains hidden for both your code and for my snippet.
(I remember now that it happened to me once several months ago on my LIVE account, and lasted until the position was not closed by a stop loss order).

Thank you in advance for investigating.

almc

-------------------------

// create an order and check if it is instantly in engine.getOrders()
IOrder order = engine.submitOrder("MyOrder", Instrument.EURUSD, OrderCommand.BUY, 0.01);
printOrderData(order, "on creation");
order.waitForUpdate(2000, IOrder.State.FILLED);
printOrderData(order, "after fill");
// almc added:
int nTotal = 0;
for (IOrder o : engine.getOrders(Instrument.EURUSD)) {
if (o.getState() == IOrder.State.FILLED) {
nTotal++;
}
}
// end -- almc added
console.getOut( ).format(" (onStart): Number of FILLED orders : %d %n", nTotal);
order.close();
order.waitForUpdate(2000, IOrder.State.CLOSED);
printOrderData(order, "after close");


 
 Post subject: Re: Demo account, engine.getOrders(instrument) Post rating: 0   New post Posted: Tue 29 Apr, 2014, 16:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We updated only the printOrderData method:
package jforex.orders2;

import java.util.List;

import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IEngine.OrderCommand;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IOrder;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.Period;

public class OneOrderGetOrdersByInstrument implements IStrategy {

    private IConsole console;
    private IEngine engine;

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

        // create an order and check if it is instantly in engine.getOrders()
        IOrder order = engine.submitOrder("MyOrder", Instrument.EURUSD, OrderCommand.BUY, 0.01);
        printOrderData(order, "on creation");
        order.waitForUpdate(2000, IOrder.State.FILLED);
        printOrderData(order, "after fill");
        order.close();
        order.waitForUpdate(2000, IOrder.State.CLOSED);
        printOrderData(order, "after close");
    }

    private void printOrderData(IOrder order, String comment) throws JFException {
        List<IOrder> orders = engine.getOrders(Instrument.EURUSD);
        console.getOut().format(comment + " engine order count = %s engine contains MyOrder = %s all orders =%s ",
                orders.size(), orders.contains(order), orders
        ).println();
    }

    public void onStop() throws JFException {
        for (IOrder o : engine.getOrders())
            o.close();
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
        if (message.getOrder() != null && message.getType() != IMessage.Type.NOTIFICATION) {
            console.getNotif().println(message);
        }
    }

    public void onAccount(IAccount account) throws JFException {
    }
}
The filled order is there as one might expect:
Image
Please provide a full example strategy which demonstrates the problem.


Attachments:
messages.png [23.12 KiB]
Downloaded 307 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: Demo account, engine.getOrders(instrument) Post rating: 0   New post Posted: Tue 29 Apr, 2014, 17:49 
User avatar

User rating: 1
Joined: Thu 24 Nov, 2011, 09:09
Posts: 36
Location: FranceFrance
Dear Support,
The problem is actually elsewhere.
Both your code and the mine miss the already existing order.
It is displayed by the platform but is not seen by the codes.

I tried to attach the image of the platform Tabs with your code response
"after close engine order count = 0 engine contains MyOrder = false all orders = []"
and the Positions(1) Tab indicating the position which is here since yesterday or so.

Unfortunately, its size (50 k) exceeds the quota.

I have to write you a mail.

I restarted the Demo platform. The problem persists.

Thanks anyhow.

almc


 
 Post subject: Re: Demo account, engine.getOrders(instrument) Post rating: 0   New post Posted: Tue 29 Apr, 2014, 17:56 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
almc wrote:
I have to write you a mail.
Yes, we need more particular information on this - both your account and the position id.


 

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