After some testing I found the new JForex ver. 2.4.5, API ver. 2.6.12 buggy:
Function IHistory.getOrdersHistory(Instrument instrument, long from, long to) does not return any history orders any more.
Here is an example to demonstrate the bug:
package jforex;
import java.util.Calendar;
import java.util.List;
import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;
public class TestStrategy implements IStrategy {
private IEngine engine;
private IOrder order;
private IContext context;
private IConsole console;
private IAccount account;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.context = context;
this.console = context.getConsole();
Calendar startDate = Calendar.getInstance();
startDate.roll(Calendar.DAY_OF_YEAR, -1);
// startDate.roll(10, -5);
Calendar endDate = Calendar.getInstance();
console.getOut().print("startDate: "+startDate.getTime());
console.getOut().println(", endDate: "+endDate.getTime());
List<IOrder> orders = null;
try{
for (Instrument instr : context.getSubscribedInstruments()) {
console.getOut().println("checking "+instr.toString());
orders = context.getHistory().getOrdersHistory(instr, startDate.getTimeInMillis(), endDate.getTimeInMillis());
if (!orders.isEmpty()){
console.getOut().println("Last Element: ClosePrice: "+orders.get(orders.size()-1).getClosePrice()+", closeTime: "+orders.get(orders.size()-1).getCloseTime()+", openTime: "+orders.get(orders.size()-1).getCreationTime() );
}
}
}
catch (Exception e) {
console.getErr().println("Fehler: "+e.toString());
}
}
public void onAccount(IAccount account) throws JFException {
this.account = account;
}
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 {
}
}
If you run the same strategy on JForex ver. 2.4.3, API ver. 2.6.8 it returns values.
Please correct asap.