The folowing example can be compiled, but not started with the new API
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.feed.util.TicksFeedDescriptor;
import com.dukascopy.api.feed.IFeedDescriptor;
import com.dukascopy.api.feed.IFeedListener;
public class TestStrategy implements IStrategy,IFeedListener {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
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();
IFeedDescriptor fd = new TicksFeedDescriptor(Instrument.EURUSD);
this.context.subscribeToFeed(fd,this);
}
public void onFeedData(IFeedDescriptor fd, ITimedData data) {
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
}
Error message when starting is:
26.11.2014 11:47:58.521 SEVERE agent.o$b ] Exception thrown while running onStart method: Params are not correctly set - feedDescriptor=FeedDescriptor [dataType=TICKS, instrument=EUR/USD, period=Ticks, ] listener=com.dukascopy.api.impl.connect.bi@4711bac2 instrument=EUR/USD period=Ticks offerSide=null
java.lang.IllegalArgumentException: Params are not correctly set - feedDescriptor=FeedDescriptor [dataType=TICKS, instrument=EUR/USD, period=Ticks, ] listener=com.dukascopy.api.impl.connect.bi@4711bac2 instrument=EUR/USD period=Ticks offerSide=null
at com.dukascopy.dds2.greed.agent.strategy.a.b.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.a.b.a(Unknown Source)
at com.dukascopy.api.impl.connect.bj.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.dukascopy.api.impl.connect.av.subscribeToTicksFeed(Unknown Source)
at com.dukascopy.api.impl.connect.av.a(Unknown Source)
at com.dukascopy.api.impl.connect.av.subscribeToFeed(Unknown Source)
at jforex.TestStrategy.onStart(TestStrategy.java:26)
at com.dukascopy.api.impl.execution.u.call(Unknown Source)
at com.dukascopy.api.impl.execution.u.call(Unknown Source)
at com.dukascopy.api.impl.connect.ao.a(Unknown Source)
at com.dukascopy.api.impl.connect.bz.bO(Unknown Source)
at com.dukascopy.api.impl.connect.bz.call(Unknown Source)
at com.dukascopy.api.impl.execution.k.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.dukascopy.api.impl.execution.g$a.f(Unknown Source)
at com.dukascopy.api.impl.execution.g$a.run(Unknown Source)
at java.lang.Thread.run(Thread.java:724)