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.

JFException: state is CREATED
 Post subject: JFException: state is CREATED Post rating: 0   New post Posted: Tue 05 May, 2009, 20:18 

User rating: 0
Joined: Sun 27 Jul, 2008, 16:17
Posts: 6
Hi all,

I'm getting the following error when using IOrder.close():

com.dukascopy.api.jFException: state is CREATED @ ...

I assume that it is to do with the state of the order so I tried using IOrder.setRequestedAmount(0) under certain state conditions and IOrder.close() under others but no combination seems to give me an adequate result. When the close command produces the error the strategy stops when the setRequestedAmount command produces the error the strategy continues to run but the trade is not closed. I can't really afford to have a whole set of 'if' statements to decide which command to use so I either need a simple way of closing or cancelling orders as required or perhaps better if when I get the error from the close() statement the strategy takes a moment to close and cancel everything and then restart from a blank order/position list.

Any advice would be hugely appreciated. Thanks in advance for your help


 
 Post subject: Re: JFException: state is CREATED Post rating: 0   New post Posted: Wed 06 May, 2009, 17:01 

User rating: 0
Joined: Sun 27 Jul, 2008, 16:17
Posts: 6
I'm also getting a similar problem producing the message: Order can't be processed: order in EXECUTING state, order...

which seems particularly odd since 'EXECUTING' is not a recognised enum constant.


 
 Post subject: Re: JFException: state is CREATED Post rating: 0   New post Posted: Wed 06 May, 2009, 19:19 

User rating: 0
Joined: Mon 03 Mar, 2008, 00:39
Posts: 6
>> CREATED:
if (order.getState() != IOrder.State.CREATED)
  order.close();

or
  try {
    order.close();
  } catch (JFException e) {
    e.printStackTrace(console.getErr());
  }


>> EXECUTING:
It's normal.


 
 Post subject: Re: JFException: state is CREATED Post rating: 0   New post Posted: Thu 07 May, 2009, 08:53 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello!
CREATED state means that order was just sent to the server and no response was received yet. There is nothing to close or cancel yet, because order doesn't exists. Transition from CREATED to OPENED is quite fast. If you need to close CREATED order then maybe you just don't need to send it in first place.


 
 Post subject: Re: JFException: state is CREATED Post rating: 0   New post Posted: Thu 07 May, 2009, 14:11 

User rating: 0
Joined: Sun 27 Jul, 2008, 16:17
Posts: 6
Thank you both. I see what you mean - the problem seems to be that my strategy submits an order then changes its mind. Would it work if did something along the lines of

if (order.getState()!=IOrder.State.valueOf("CREATED")) {
order.close();
}
else {
halt=true;
}

And then have a line in onMessage that waits for ORDER_SUBMIT_OK and then cancels the order and removes the halt flag. Where the halt flag prevents any other trading from taking place?

Thanks again

I've also started receiving the warning message 'Your order has been rejected. No corresponding order found' I can only assume that this again occurs when trying to close the order (as it clearly doesn't close). Any thoughts?

Thanks


 
 Post subject: Re: JFException: state is CREATED Post rating: 0   New post Posted: Thu 07 May, 2009, 21:49 

User rating: 0
Joined: Mon 03 Mar, 2008, 00:39
Posts: 6
>> CREATED
or
      order = engine.submitOrder(...);
      order.waitForUpdate(Pause);


>>REJECTED
It's normal.


 
 Post subject: Re: JFException: state is CREATED Post rating: 0   New post Posted: Fri 08 May, 2009, 12:33 

User rating: 0
Joined: Sun 27 Jul, 2008, 16:17
Posts: 6
Thanks again,

I think I've created methods of catching and resolving the various scenarios using onMessage. I've got it running at the moment and so far so good.

Thanks


 

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