Hello Dear Support,
Methods IContext.setSubscribedInstruments(ins) and IContext.getSubscribedInstruments() stopped working.
The first one does not subscribe to defined set of instruments. The latter returns empty Set even if there were instruments subscribed through IClient.setSubscribedInstruments(ins). As a result, among other problems, JFUtils does not work (for example convertPipToCurrency()).
I see no body reported the issue so maybe it is something specific to my config. I tested this on 3 pc - the result is the same: Java 1.6, JForex API 2.7.4
I am attaching the full code.
Below a snipped and result:
if (!client.isConnected()) {System.exit(1);}
Set<Instrument> instrumentsClient = new HashSet();
instrumentsClient.add(Instrument.EURSEK);
client.setSubscribedInstruments(instrumentsClient);
Thread.sleep(5000);
System.out.println("Subscribed instruments: " + client.getSubscribedInstruments());
client.startStrategy(new IStrategy(){
IContext context;
public void onStart(IContext context) throws JFException {
this.context = context;
Set<Instrument> instrumentsContext = new HashSet();
instrumentsContext.add(Instrument.EURJPY);
instrumentsContext.add(Instrument.GBPUSD);
context.setSubscribedInstruments(instrumentsContext);
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
System.out.println(
instrument.name()
+ ", subscribed instruments: "
+ context.getSubscribedInstruments() + " "
+ context.getSubscribedInstruments().size());
}
The result:
Subscribed instruments [IClinet]: [USD/SEK, AUD/USD, EUR/SEK]
USDSEK, subscribed instruments [IContext]: [] 0
AUDUSD, subscribed instruments [IContext]: [] 0
USDSEK, subscribed instruments [IContext]: [] 0
AUDUSD, subscribed instruments [IContext]: [] 0
AUDUSD, subscribed instruments [IContext]: [] 0
AUDUSD, subscribed instruments [IContext]: [] 0
AUDUSD, subscribed instruments [IContext]: [] 0
best regards,
Kurak