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.

reliability of order state-change notifications (onMessage)
 Post subject: reliability of order state-change notifications (onMessage) Post rating: 0   New post Posted: Tue 10 May, 2011, 23:04 

User rating: -
Hi

Which one of the following is correct?
1. Delivery of onMessage notifications that accompany order state-changes is best-effort. (i.e. A lost message is lost forever.)
2. Delivery of onMessage notifications that accompany order state-changes is guaranteed eventually if connectivity is not lost permanently. (i.e. A lost message will be retransmitted if delivery is not confirmed.)

In other words: Is it safe to use onMessage for any order management, or does the strategy have to poll the order state?

Isak


 
 Post subject: Re: reliability of order state-change notifications (onMessa Post rating: 0   New post Posted: Wed 11 May, 2011, 10:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,

If you need to monitor the platform connection in your strategy, you can use the CONNECTION_STATUS message. Please take a look at the following JForex Wiki page: https://www.dukascopy.com/wiki/index.php ... connecting.


 
 Post subject: Re: reliability of order state-change notifications (onMessa Post rating: 0   New post Posted: Wed 11 May, 2011, 10:48 

User rating: -
Hi Support

Sorry, my question was worded complicatedly. What I am asking is this:
For purposes of tracking the state of an order, can onMessage(...) notifications be considered reliable, or does one have to poll order.getState().

This would affect any design fundamentally so surely there must be a definite answer.

Thanks
Isak


 
 Post subject: Re: reliability of order state-change notifications (onMessa Post rating: 0   New post Posted: Wed 11 May, 2011, 12:06 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Isak wrote:
For purposes of tracking the state of an order, can onMessage(...) notifications be considered reliable

Yes, using onMessage notifications is reliable for order state management, if your platform reconnects after disconnection you will receive order change messages.


 
 Post subject: Re: reliability of order state-change notifications (onMessa Post rating: 0   New post Posted: Wed 11 May, 2011, 21:24 

User rating: -
Thank you Support. There are some in the JForex community who avoid using onMessage for order management, and this is an important consideration in making design decisions, so please bear with me as I ask for confirmation:

Suppose, for example, I have an order, and I want to reliably doSomething() when order is filled. Are the following solutions equally reliable? (Note that my question is about the general concept (of how the message framework is implemented) rather than the actual code provided below.)
 // Solution 1
public void onMessage(IMessage message) throws JFException {
     if(message.getType() == IMessage.Type.ORDER_FILL_OK){
          if(message.getOrder().getID().equals(order.getID())){
               doSomething();
          }
     }
}
 // Solution 2
private IOrder.State lastState;
public void onTick(Instrument instrument, ITick tick){
     if(lastState != IOrder.State.FILLED && order.getState() == IOrder.State.FILLED){
          doSomething();
     }
     lastState = order.getState();
}

Please don't hesitate to say if my question is unclear. Thanks in advance.


 
 Post subject: Re: reliability of order state-change notifications (onMessa Post rating: 0   New post Posted: Fri 13 May, 2011, 15:52 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
About solution 1: In case if fill happens during disconnect, you will not receive ORDER_FILL_OK, and doSomething method will not execute. You need to check ORDER_CHANGED_OK messages as well and see if order changed it's state to the filled.

Solution 2, will work correctly in any case.


 

Jump to:  

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