Dear support,
it seems there is a bug in TickFeedListener and maybe in all other FeedListeners.
Please consider the following simple Strategie to reproduce the problem. The listeneres received a different number of ticks, especially the first listener "Listener 1" reveived ticks only sometimes!
package jforex;
import com.dukascopy.api.*;
import com.dukascopy.api.feed.ITickFeedListener;
import java.util.HashSet;
import java.util.Set;
/**
* Created by RN on 13.05.2015.
* Copyright 2015 Forex Money Maker
*/
public class ListenerTest implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
@Override
public void onStart(IContext context) throws JFException {
this.context = context;
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
Set<Instrument> instruments = new HashSet<>();
instruments.add(Instrument.GBPJPY);
this.context.setSubscribedInstruments(instruments,true);
TickListenerTest listener1 = new TickListenerTest("Listener 1",Instrument.GBPJPY,this.context);
TickListenerTest listener2 = new TickListenerTest("Listener 2",Instrument.GBPJPY,this.context);
TickListenerTest listener3 = new TickListenerTest("Listener 3",Instrument.GBPJPY,this.context);
TickListenerTest listener4 = new TickListenerTest("Listener 4",Instrument.GBPJPY,this.context);
listener1.registerListener();
listener2.registerListener();
listener3.registerListener();
listener4.registerListener();
}
@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 onMessage(IMessage message) throws JFException {
}
@Override
public void onAccount(IAccount account) throws JFException {
}
@Override
public void onStop() throws JFException {
}
class TickListenerTest implements ITickFeedListener {
private final String name;
private final Instrument instrument;
private final IContext context;
private int counter;
public TickListenerTest(String name, Instrument instrument, IContext context) {
if (name==null || instrument == null || context == null) {
throw new IllegalArgumentException("parameters must not be null!");
}
this.name = name;
this.instrument = instrument;
this.context = context;
}
public void registerListener() {
context.subscribeToTicksFeed(this.instrument, this);
}
@Override
public void onTick(Instrument instrument, ITick tick) {
context.getConsole().getOut().println("Tick received in: " + this.name + " total received ticks=" + ++counter);
//context.getConsole().getOut().println("Tick received in: " + this.name + " tick=" + tick);
}
}
}
Please investigate and let us know the result.
Thank you and best regards,
Jack
checked on demo account SDK and JForex
JClient 2.44.7
JForex-API 2.12.9