Dukascopy
 
 
Wiki JStore Search Login

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

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

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

check account for new orders
 Post subject: check account for new orders Post rating: 0   New post Posted: Thu 19 Aug, 2010, 00:26 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
How can I check an JForex account for new orders?
Is there any order listener available?


 
 Post subject: Re: check account for new orders Post rating: 0   New post Posted: Thu 19 Aug, 2010, 07:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
You can use the onMessage() event for this purpose.
Please consider the following code:
public void onMessage(IMessage message) throws JFException {
     if (message.getType() == Type.ORDER_SUBMIT_OK){
        console.getOut().println("Order submitted");
     }
     if (message.getType() == Type.ORDER_FILL_OK){
        console.getOut().println("Order filled");
     }
}


 
 Post subject: Re: check account for new orders Post rating: 0   New post Posted: Fri 20 Aug, 2010, 19:34 

User rating: 0
Joined: Mon 09 Aug, 2010, 21:49
Posts: 30
using the check message method makes me nervous. What if there is an error and this mesaage doesn't come up, but a new order has been filled? Better to actually check the list of orders with a function like this:

    //count open positions
    protected int positionsTotal(Instrument instrument) throws JFException {
        int counter = 0;
        for (IOrder order : engine.getOrders(instrument)) {
            if (order.getState() == IOrder.State.FILLED) {
                counter++;
            }
        }
        return counter;
    }


 

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