|
Attention! Read the forum rules carefully before posting a topic.
Submit JForex API bug reports in this forum only. Submit Converter issues in Converter Issues. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
FXjuxe
|
Post subject: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Sat 23 Aug, 2014, 10:21
|
|
User rating: 11
Joined: Tue 27 Mar, 2012, 17:47 Posts: 111 Location: GermanyGermany
|
Hello support,
In my strategy I use the waitForUpdate(long timeoutMills, IOrder.State... states) from IOrder. All is fine when the strategy runs on the live market. But when using the historical tester this method blocks forever. What can I do about this`?
Thanks, Juergen
|
|
|
|
|
API Support
|
Post subject: Re: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Mon 25 Aug, 2014, 07:26
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Please provide an example strategy to replicate this and the printscreen of the Historical Tester settings that you use.
|
|
|
|
|
FXjuxe
|
Post subject: Re: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Sat 15 Nov, 2014, 16:37
|
|
User rating: 11
Joined: Tue 27 Mar, 2012, 17:47 Posts: 111 Location: GermanyGermany
|
Hello Support, here is an example strategy for this: package jforex;
import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future;
import com.dukascopy.api.IAccount; import com.dukascopy.api.IBar; import com.dukascopy.api.IConsole; import com.dukascopy.api.IContext; import com.dukascopy.api.IEngine; import com.dukascopy.api.IHistory; import com.dukascopy.api.IIndicators; import com.dukascopy.api.IMessage; import com.dukascopy.api.IOrder; import com.dukascopy.api.IStrategy; import com.dukascopy.api.ITick; import com.dukascopy.api.IUserInterface; import com.dukascopy.api.Instrument; import com.dukascopy.api.JFException; import com.dukascopy.api.Period;
public class Strategy implements IStrategy { private IEngine engine; private IConsole console; private IHistory history; private IContext context; private IIndicators indicators; private IUserInterface userInterface;
private class BuyTask implements Callable<IOrder> { private final Instrument instrument; private final double stopLossPips;
public BuyTask(Instrument instrument, double stopLossPips) { this.instrument = instrument; this.stopLossPips = stopLossPips; }
@Override public IOrder call() throws Exception { double stopLossPrice = history.getLastTick(instrument).getBid() - stopLossPips * instrument.getPipValue(); IOrder order = engine.submitOrder("Buy_order1" + System.nanoTime(), instrument, IEngine.OrderCommand.BUY, 0.001, 0, 20, stopLossPrice, 0); return order; } }
private class BuyTaskWithContext implements Callable<IOrder> { private final IContext context;
public BuyTaskWithContext(IContext context) { this.context = context; }
@Override public IOrder call() throws Exception { BuyTask task = new BuyTask(Instrument.EURUSD, 40); Future<IOrder> orderFuture = context.executeTask(task); IOrder order = orderFuture.get(); IMessage message = null; try { System.out.println("before order.waitForUpdate call"); message = order.waitForUpdate(1000L, IOrder.State.FILLED); System.out.println("after order.waitForUpdate call"); } catch (JFException e) { } return order; } }
@Override public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; this.indicators = context.getIndicators(); this.userInterface = context.getUserInterface();
ExecutorService threadPool = Executors.newCachedThreadPool(); BuyTaskWithContext taskWithContext = new BuyTaskWithContext(context); threadPool.submit(taskWithContext); }
@Override public void onAccount(IAccount account) throws JFException { }
@Override public void onMessage(IMessage message) throws JFException { }
@Override public void onStop() throws JFException { }
@Override public void onTick(Instrument instrument, ITick tick) throws JFException { }
@Override public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { } }
This is not my real strategy but its doing essentially the same. My strategy runs fine on the live market but get stuck with the historical tester on this line: message = order.waitForUpdate(1000L, IOrder.State.FILLED); My guess is that the ExecutorService does not work with the backtesting framework. It's more work for me to always provide two different implementations for live market and historical tester. Thanks for feedback, Juergen
|
|
|
|
|
API Support
|
Post subject: Re: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Mon 17 Nov, 2014, 15:10
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
|
FXjuxe
|
Post subject: Re: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Tue 18 Nov, 2014, 09:02
|
|
User rating: 11
Joined: Tue 27 Mar, 2012, 17:47 Posts: 111 Location: GermanyGermany
|
Ok, thx. Could you please post here when it is done?
|
|
|
|
|
FXjuxe
|
Post subject: Re: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Thu 18 Dec, 2014, 19:23
|
|
User rating: 11
Joined: Tue 27 Mar, 2012, 17:47 Posts: 111 Location: GermanyGermany
|
Could you please give an update on this issue?
|
|
|
|
|
Platform Support
|
Post subject: Re: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Mon 29 Dec, 2014, 11:06
|
|
JForex Master | |
User rating: ∞
Joined: Wed 16 Sep, 2009, 18:23 Posts: 1049 Location: Geneva, Switzerland
|
Few deadlocks have been rectified in version 2.42.5. Please try on DEMO.
|
|
|
|
|
FXjuxe
|
Post subject: Re: IOrder.waitForUpdate(timeoutMills, state) blocks when using Historical Tester |
Post rating: 0
|
Posted: Fri 02 Jan, 2015, 22:05
|
|
User rating: 11
Joined: Tue 27 Mar, 2012, 17:47 Posts: 111 Location: GermanyGermany
|
Thanks, this fixed my problem.
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|