Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

getBars with CustomPeriod
 Post subject: getBars with CustomPeriod Post rating: 0   New post Posted: Sun 04 Jan, 2015, 15:47 
User avatar

User rating: 7
Joined: Tue 28 Feb, 2012, 09:45
Posts: 45
Location: JapanJapan
I found a bug with getBars() method.

Sample code:
package jforex;

import com.dukascopy.api.*;
import java.util.List;
import java.util.Date;
import java.io.PrintStream;

public class GetBarsTest2 implements IStrategy {
    //@Configurable(value="Instrument")
    public Instrument instrument = Instrument.EURUSD;
    //@Configurable(value="Period")
    public Period period = Period.DAILY;
    //@Configurable(value="OfferSide")
    public OfferSide offerside = OfferSide.BID;
    //@Configurable(value="Filter")
    public Filter filter = Filter.NO_FILTER;
    //@Configurable(value="JFTimeZone1")
    public JFTimeZone jft1 = JFTimeZone.UTC;
    //@Configurable(value="JFTimeZone2")
    public JFTimeZone jft2 = JFTimeZone.EET;
   
    public void onStart(IContext context) throws JFException {
        IConsole c = context.getConsole();
        IHistory history = context.getHistory();
        long twodaysago = history.getBarStart(period, new Date().getTime() - 48*60*60*1000);
        JFTimeZone[] jfts = {jft1, jft2};
        for(JFTimeZone jft: jfts){
            c.getOut().println("GetBarsTest: " + jft.toString());
            period = Period.createCustomPeriod(period.getUnit(), period.getNumOfUnits(), jft);
            long from = history.getBarStart(period, twodaysago);
            List<IBar> barlist = history.getBars(instrument, period, offerside, filter, 2,from,0);
            try{
                barlist = history.getBars(instrument, period, offerside, filter, 2,from,0);
            } catch (Exception e) {
                c.getNotif().println("Error with " + jft.toString());
                e.printStackTrace(context.getConsole().getErr());
                context.stop();
                return;
            }
            c.getInfo().println("GetBarsTest: " + jft.toString());
        }
    }

    public void onAccount(IAccount account) throws JFException {
    }

    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 {
    }
}


When I used this strategy as local run, I got an error message like this "com.dukascopy.charts.data.datacache.DataCacheException: Failed to load in-progress candle data in timeout period [EUR/USD, Daily, Bid] @ com.dukascopy.charts.data.datacache.bg.c(Unknown Source)".
Image

But, this strategy can run without such error on the historical tester.
Image

Regards,


Attachments:
oksamplepng.png [16.02 KiB]
Downloaded 421 times
bugsample.png [23.4 KiB]
Downloaded 426 times
GetBarsTest2.java [2.12 KiB]
Downloaded 205 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
The Best Answer  Post subject: Re: getBars with CustomPeriod Post rating: 1   New post Posted: Mon 05 Jan, 2015, 10:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello!

We couldn't replicate the problem you described. Did it happen on DEMO or LIVE? Does it still persist?


 
 Post subject: Re: getBars with CustomPeriod Post rating: 0   New post Posted: Tue 06 Jan, 2015, 14:22 
User avatar

User rating: 7
Joined: Tue 28 Feb, 2012, 09:45
Posts: 45
Location: JapanJapan
I don't know what happened..., but there is no bug now.
Thank you very much.


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com