Hello,
I am trying to get the bars in an interval of dates but without the weekend data.
My strategy is exactly the same that
this one (Multiple candle periods), but with Filter.
for(Period period : periods){
long timeCandle = dataService.getTimeOfFirstCandle(Instrument.EURUSD, period);
List<IBar> bars = null;
List<IBar> filteredBars = null;
try{
long from = history.getBarStart(period, timeCandle + period.getInterval());
long to = history.getBarStart(period, timeCandle + 2 * period.getInterval());
bars = history.getBars(Instrument.EURUSD, period, OfferSide.BID, from, to);
filteredBars = history.getBars(Instrument.EURUSD, period, OfferSide.BID, Filter.WEEKENDS,from, to);
} catch (JFException e){
console.getErr().println(e);
}
where periods is:
Period[] periods = new Period[]{
ONE_SEC, ONE_MIN, FIVE_MINS, TEN_MINS, FIFTEEN_MINS, THIRTY_MINS, ONE_HOUR, FOUR_HOURS, DAILY, WEEKLY, MONTHLY
};
The conflicting line is:
filteredBars = history.getBars(Instrument.EURUSD, period, OfferSide.BID, Filter.WEEKENDS,from, to);
That line works fine for Period.ONE_SEC, but for the other periods it gives me the exception:
com.dukascopy.api.JFException: Requested time interval from [2003-08-11 00:02:00:000] to [2003-08-11 00:03:00:000] GMT is not valid
I attach my strategy in case it helps. I would appreciate any suggestion or a different approach to achieve this.
Thank you