|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
getTickBar with shift 1 throws exception on backtest |
Edwin
|
Post subject: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Tue 20 Mar, 2012, 09:17
|
|
User rating: 1
Joined: Tue 20 Mar, 2012, 09:03 Posts: 41
|
The following code: history.getTickBar(eurusd, OfferSide.ASK, TickBarSize.valueOf(2), 1); throws the following exception on strategy backtests after some seconds on each call: Caused by - java.lang.IllegalArgumentException: In progress bar is not loaded, could not load history further at com.dukascopy.charts.data.datacache.priceaggregation.dataprovider.PriceAggregationDataProvider.loadBarsWithInProgressBarCheck(PriceAggregationDataProvider.java:1298) at com.dukascopy.charts.data.datacache.priceaggregation.dataprovider.PriceAggregationDataProvider.loadTickBarTimeInterval(PriceAggregationDataProvider.java:1486) at com.dukascopy.api.impl.History$34$1.load(History.java:1440) at com.dukascopy.api.impl.util.HistoryUtils.getByShift(HistoryUtils.java:355) at com.dukascopy.api.impl.History$34.run(History.java:1459) at com.dukascopy.api.impl.History$34.run(History.java:1427) at java.security.AccessController.doPrivileged(Native Method) at com.dukascopy.api.impl.History.getTickBar(History.java:1427) Using shift=0, the method works. This is on a demo account with latest jforex libs from maven repo. Increasing the TickBarSize does not change anything. The same exception occurs with calls on any getTickBars() method. The instrument has been subscribed to. Am I doing something wrong or is this a bug?
|
|
|
|
 |
Edwin
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Wed 21 Mar, 2012, 14:20
|
|
User rating: 1
Joined: Tue 20 Mar, 2012, 09:03 Posts: 41
|
Anybody else who has this problem? If yes, how do you get your TickBars? If not, why am I the only one affected? 
|
|
|
|
 |
API Support
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Wed 21 Mar, 2012, 14:21
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Subscribing to the particular feed should speed up the historical data loading. If the problem still persists, please provide the example strategy and a precise launch scenario.
|
|
|
|
 |
Edwin
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Wed 21 Mar, 2012, 21:27
|
|
User rating: 1
Joined: Tue 20 Mar, 2012, 09:03 Posts: 41
|
Here is a sample that reproduces the problem: import java.util.HashSet; import java.util.Set;
import javax.annotation.concurrent.NotThreadSafe;
import com.dukascopy.api.IAccount; import com.dukascopy.api.IBar; import com.dukascopy.api.IContext; import com.dukascopy.api.IMessage; import com.dukascopy.api.IStrategy; import com.dukascopy.api.ITick; import com.dukascopy.api.Instrument; import com.dukascopy.api.JFException; import com.dukascopy.api.OfferSide; import com.dukascopy.api.Period; import com.dukascopy.api.TickBarSize; import com.dukascopy.api.system.ISystemListener; import com.dukascopy.api.system.ITesterClient; import com.dukascopy.api.system.TesterFactory;
import de.invesdwin.forexhandel.ForexProperties; import de.invesdwin.gemeinsam.log.Log; import de.invesdwin.gemeinsam.log.error.Err;
/** * This small program demonstrates how to initialize Dukascopy client and start a strategy */ @NotThreadSafe public final class TickBarsTest {
//url of the DEMO jnlp
private static final Log LOGGER = new Log(TickBarsTest.class);
private TickBarsTest() {}
//CHECKSTYLE:OFF public static void main(final String[] args) throws Exception { //CHECKSTYLE:ON //get the instance of the IClient interface final ITesterClient client = TesterFactory.getDefaultInstance(); //set the listener that will receive system events client.setSystemListener(new ISystemListener() { private int lightReconnects = 3;
@Override public void onStart(final long processId) { LOGGER.info("Strategy started: " + processId); }
@Override public void onStop(final long processId) { LOGGER.info("Strategy stopped: " + processId); if (client.getStartedStrategies().size() == 0) { System.exit(0); } }
@Override public void onConnect() { LOGGER.info("Connected"); lightReconnects = 3; }
@Override public void onDisconnect() { LOGGER.warn("Disconnected"); if (lightReconnects > 0) { client.reconnect(); --lightReconnects; } else { try { //sleep for 10 seconds before attempting to reconnect Thread.sleep(10000); } catch (final InterruptedException e) { Err.process(e); } try { client.connect(ForexProperties.JFOREX_JNLP_URL.toString(), ForexProperties.JFOREX_JNLP_USERNAME, ForexProperties.JFOREX_JNLP_PASSWORD); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } } } });
LOGGER.info("Connecting..."); //connect to the server using jnlp, user name and password client.connect(ForexProperties.JFOREX_JNLP_URL.toString(), ForexProperties.JFOREX_JNLP_USERNAME, ForexProperties.JFOREX_JNLP_PASSWORD);
//wait for it to connect int i = 10; //wait max ten seconds while (i > 0 && !client.isConnected()) { Thread.sleep(1000); i--; } if (!client.isConnected()) { LOGGER.error("Failed to connect Dukascopy servers"); System.exit(1); }
//subscribe to the instruments final Set<Instrument> instruments = new HashSet<Instrument>(); instruments.add(Instrument.EURUSD); LOGGER.info("Subscribing instruments..."); client.setSubscribedInstruments(instruments); //start the strategy LOGGER.info("Starting strategy"); client.startStrategy(new IStrategy() { private IContext context;
@Override public void onTick(final Instrument instrument, final ITick tick) throws JFException { if (instrument == Instrument.EURUSD) { final IBar bar = context.getHistory().getTickBar(Instrument.EURUSD, OfferSide.ASK, TickBarSize.valueOf(2), 1); LOGGER.info("" + bar); } }
@Override public void onStop() throws JFException {}
@Override public void onStart(final IContext context) throws JFException { this.context = context; }
@Override public void onMessage(final IMessage message) throws JFException {}
@Override public void onBar(final Instrument instrument, final Period period, final IBar askBar, final IBar bidBar) throws JFException {}
@Override public void onAccount(final IAccount account) throws JFException {} }); //now it's running } }
You have to replace the ForexProperties with values for a demo account and a url to the demo jnpl. To create this sample, I just modified your Main.java sample to run a backtest instead of a forward test. In forward tests this exception does not occur, it only occurs in backtests. Maybe checking for in progress bars needs to be disabled for backtesting, because the progress can't be downloaded because there is no live feed, but instead a cache file the data comes from. Also having it wait for new data is kind of wasted time during a backtest where fast execution time is most important. Instead it should just skip calculation of in progress bars or load the in progress data from cache (more desirable to keep backtesting more realistic).
|
|
|
|
 |
API Support
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Thu 22 Mar, 2012, 11:14
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
The issue will get fixed with the new version of JForex-API.
|
|
|
|
 |
Edwin
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Thu 22 Mar, 2012, 11:34
|
|
User rating: 1
Joined: Tue 20 Mar, 2012, 09:03 Posts: 41
|
Ok, thanks. I suspect not only the getTickBars() method is affected by this bug. But other bar types are aswell affected. 
|
|
|
|
 |
API Support
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Thu 22 Mar, 2012, 12:09
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
This is the case. The problem will get fixed for all of the feeds.
|
|
|
|
 |
Edwin
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Thu 26 Apr, 2012, 23:44
|
|
User rating: 1
Joined: Tue 20 Mar, 2012, 09:03 Posts: 41
|
Hi, with JForex 2.6.64 the exception does not occur anymore. Though with the sample above I cannot get proper tick bars. They are always from the same time even though they should get updated with progress of the backtest. This is the output I get from the same sample as above: 2012-04-27 00:37:32,342 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,343 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2012-04-27 00:37:32,344 [ |StrategyRunner Thre] INFO d.i.forextrading.sample.tickbars.TickBarsTest.onTick - StartTime: 2012-04-22 23:59:57.812 EndTime: 2012-04-22 23:59:58.359 O: 1.32079 C: 1.32079 H: 1.32079 L: 1.32079 V: 3.0 FEC: 2 2 Note that the StartTime and EndTime stays the same... Can you check if you can reproduce this on your end?
|
|
|
|
 |
Edwin
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Thu 26 Apr, 2012, 23:49
|
|
User rating: 1
Joined: Tue 20 Mar, 2012, 09:03 Posts: 41
|
Other bar types seem to have the same problem.
|
|
|
|
 |
Edwin
|
Post subject: Re: getTickBar with shift 1 throws exception on backtest |
Post rating: 0
|
Posted: Sun 29 Apr, 2012, 12:57
|
|
User rating: 1
Joined: Tue 20 Mar, 2012, 09:03 Posts: 41
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|