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.

Mass close. Closes all orders passed in parameter(s);dynamic
 Post subject: Mass close. Closes all orders passed in parameter(s);dynamic Post rating: 0   New post Posted: Thu 09 Jul, 2009, 20:56 

User rating: -
closeOrders

void closeOrders(IOrder... orders)
throws JFException

Mass close. Closes all orders passed in parameter(s)

Parameters:
orders - orders to close
Throws:
JFException - if orders not in IOrder.State.FILLED state.


IEngine.closeOrders (....) for using mass closure of orders..
problem is if you have at runtime a dynamic number of parameters you have to pass to this function. MISSING EXAMPLES ON JFOREXBOARDS
HOW to do it?
amount of orders can varify at runtime so how to call this function correctly??

cheers,,


 
 Post subject: Re: Mass close. Closes all orders passed in parameter(s);dynamic Post rating: 0   New post Posted: Fri 10 Jul, 2009, 07:18 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You can pass array of orders as a parameter:
      List<IOrder> orders = engine.getOrders();
      engine.closeOrders(orders.toArray(new IOrder[orders.size()]));


 
 Post subject: Re: Mass close. Closes all orders passed in parameter(s);dyn Post rating: 0   New post Posted: Fri 10 Jul, 2009, 11:23 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
2 questions regarding closeOrders:

a) can the function be directly called outside onTick (without opening a new thread/Future)?

b) the function is throwing a JFException when an order is not in IOrder.State.FILLED.
What happens if an order in the passed order list is not in state IOrder.State.FILLED? Does closeOrders throw the error immediately, stopping the processing of further elements in the orderlist, or will all elements in the list get processed before the error is thrown at the end of the order loop?

Thanks, RR.


 
 Post subject: Re: Mass close. Closes all orders passed in parameter(s);dynamic Post rating: 0   New post Posted: Fri 10 Jul, 2009, 13:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
a) no it cannot be called from outside of strategy thread, you should use IContext.executeTask in this cases
b) it checks that all passed orders have FILLED state, if one of the order has some other state it throws JFException and no requests are sent to server. You should check yourself that orders are in FILLED state


 

Jump to:  

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