FXjuxe wrote:
must the method orderUpdateWait(long, State) be executed on the strategy thread?
It is not mandatory, consider the following example:
package jforex.orders;
import com.dukascopy.api.*;
import com.dukascopy.api.util.DateUtils;
import com.dukascopy.api.IEngine.OrderCommand;
public class WaitForUpdateAnotherThread implements IStrategy {
private IConsole console;
public void onStart(IContext context) throws JFException {
this.console = context.getConsole();
context.setSubscribedInstruments(java.util.Collections.singleton(Instrument.EURUSD), true);
final IOrder order = context.getEngine().submitOrder("MarketOrder", Instrument.EURUSD, OrderCommand.BUY, 0.1);
print("after submit " + order);
new Thread(new Runnable() {
@Override
public void run() {
try {
print("before wait " + order);
order.waitForUpdate(12000, IOrder.State.FILLED);
print("after wait " + order);
} catch (JFException e) {
e.printStackTrace();
}
}
}) {
}.start();
print("after starting other thread " + order);
}
private void print(Object o){
console.getOut().println(Thread.currentThread().getName() + " " + DateUtils.format(System.currentTimeMillis()) + " " + o);
}
@Override
public void onMessage(IMessage message) throws JFException {
if(message.getOrder() != null){
console.getInfo().println(message);
}
}
@Override
public void onTick(Instrument instrument, ITick tick) throws JFException {}
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
@Override
public void onAccount(IAccount account) throws JFException {}
@Override
public void onStop() throws JFException {}
}
FXjuxe wrote:
Currently I run it from a separate thread but I'm not sure if the waiting time gets actually executed.
Consider checking it in a similar fashion as we did in our example.
FXjuxe wrote:
Is there a list of all methods which must be run from the strategy thread?
All order creation/modification methods.