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.

OrderState.CREATED in onStop()
 Post subject: OrderState.CREATED in onStop() Post rating: 0   New post Posted: Wed 06 Oct, 2010, 12:36 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Hi,

it seems that in onStop() orderStates are not getting updated anymore. Is this correct?

When onStop() is triggered when a PLACE_BID- or PLACE_OFFER-order is still in the state CREATED, trying to close that order leads to an error.
Waiting for a state change to OPENED with Thread.sleep(..) doesn't work, the status won't change. At the same time the position is already listed as PENDING in the JForex-client.

What would be the best procedure to close an order with state CREATED in onStop()?

Best regards,
RR.


 
 Post subject: Re: OrderState.CREATED in onStop() Post rating: 0   New post Posted: Thu 07 Oct, 2010, 08:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
unfortunately, there is no workaround. You must close them manually.


 
 Post subject: Re: OrderState.CREATED in onStop() Post rating: 0   New post Posted: Thu 07 Oct, 2010, 12:28 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Dear support,

thank you for your reply.

ok, this means the order would have to have the status "OPENED" before onStop is getting called?
In this case it might help to wait to issue a context.stop() until no order is in state CREATED anymore?

would it then help to replace context.stop()-calls by the following code?
   public void contextStop()
   {
      boolean bStatusOK = false;
      int nLoop = 0;
      try
      {
         while (bStatusOK && nLoop < 5)
         {
            bStatusOK = true;
            for (IOrder order: engine.getOrders())
            {
               if (order.getState() == IOrder.State.CREATED)
               {
                     bStatusOK = false;
                      Thread.currentThread();
                      Thread.sleep(2000,0);   //wait 2 seconds and then test again for the state...
                      break;
               }
            }
            nLoop++;
         }
      }
      catch (Exception e)
      {
         //...
      }
      finally
      {
         context.stop();
      }
   }


Best, RR.


 
 Post subject: Re: OrderState.CREATED in onStop() Post rating: 0   New post Posted: Wed 13 Oct, 2010, 09:16 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Hello SupportTeam,

if I understand correctly, the order states get updated in onMessage().
Would it be possible for you to update the order states during onStop?
Something like an internal onMessage(.., bOnStop=true) that is still triggered during onStop() and does process the order-messages?

Thanks a lot for considering,
RR.


 
 Post subject: Re: OrderState.CREATED in onStop() Post rating: 0   New post Posted: Thu 14 Oct, 2010, 08:00 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
RoadRunner wrote:
would it then help to replace context.stop()-calls by the following code?

Yes, i think it would. Try it


 

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