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.

JFE when trying to close an order
 Post subject: JFE when trying to close an order Post rating: 0   New post Posted: Fri 04 Dec, 2009, 16:25 

User rating: 0
Joined: Sun 29 Nov, 2009, 04:15
Posts: 11
I am getting this when trying to close an order:
Cannot mass close orders in state other than FILLED: com.dukascopy.api.JFException: Cannot mass close orders in state other than FILLED
at com.dukascopy.api.impl.connect.k.closeOrders(Unknown Source)
Before doing that I checked the order state should be (order.getState()==IOrder.State.CREATED || order.getState()==IOrder.State.OPENED) as what's said in the document. The order has entry filled, takeprofit and stoploss pending so I guess the state is OPENED.
My first question is how the order state changes. I thought it's CREATED at first, then OPENED once server confirmed, when entry filled, it's FILLED, when either TP or SL filled, it's CLOSED. But this seems I am wrong. The status is still OPENED after entry filled.
My second question is whether it's possible to close such an order, if not, how could I distinguish it from an order could be closed.
Thanks!


 
 Post subject: Re: JFE when trying to close an order Post rating: 0   New post Posted: Mon 07 Dec, 2009, 10:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Quote:
My first question is how the order state changes

Please consider added diagram.
A function closeOrders closes only filled orders. An order became closed(IOrder.State.CLOSED) only after its filled (IOrder.State.FILLED).
Quote:
My second question is whether it's possible to close such an order

It is possible, use a function close. Consider following example:
for (IOrder o : context.getEngine().getOrders()){
         if(o.getState() == IOrder.State.OPENED || o.getState() == IOrder.State.FILLED){
                o.close();
         }
      }

If you close an order that isn't filled, it became in the state IOrder.Satate.CANCELED.


Attachments:
Market Order States Diagram-1.pdf [144.43 KiB]
Downloaded 605 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.
 

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