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.

Close all positions - What code faster?
 Post subject: Close all positions - What code faster? Post rating: 0   New post Posted: Thu 31 Mar, 2011, 12:45 

User rating: -
What code from an example below will close all positions more faster?

1. List<IOrder> orders = engine.getOrders();
engine.closeOrders(orders.toArray(new IOrder[orders.size()]));


2. for (IOrder order:engine.getOrders())
if (order.getState()==IOrder.State.FILLED||
order.getState()==IOrder.State.CREATED||order.getState()==IOrder.State.OPENED)
order.close();


 
 Post subject: Re: Close all positions - What code faster? Post rating: 0   New post Posted: Thu 09 Jun, 2011, 14:48 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
First of all, the behaviour of both methods is not equivalent - IEgine.closeOrders can be called only on FILLED orders, while IOrder.close accepts orders of state CREATED and OPENED as well. And secondly, the check of order state for engine.getOrders() orders is redundant, see:
https://www.dukascopy.com/client/javadoc ... getOrders()


 

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