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.

Inconsistent behavior of IHistory.getBars method
 Post subject: Inconsistent behavior of IHistory.getBars method Post rating: 1   New post Posted: Sat 02 Nov, 2013, 21:55 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
The code and the Strategy Log are attached.
The question is:
If the line 31 of the code is correct why does the line 37 (with the same code) throw an exception?
package jforex;

import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IHistory;
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 java.io.PrintStream;
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;

public class JFTestGetBarsOnWeekend implements IStrategy {

    @Override
    public void onStart(IContext context) throws JFException {
        PrintStream out = context.getConsole().getOut();
        IHistory history = context.getHistory();
        Instrument instrument = Instrument.GBPUSD;
        Period period = Period.ONE_MIN;
        context.setSubscribedInstruments(EnumSet.of(instrument), true);
        out.println(context.getSubscribedInstruments());
        long to = history.getBarStart(period, System.currentTimeMillis());
        long from = to - 10 * period.getInterval();

        out.println("#1 " + history.getBars(instrument, period, OfferSide.BID, from, to)); // this line is correct
        try {
            TimeUnit.MINUTES.sleep(1);
        } catch (InterruptedException ex) {
            out.println(ex);
        }
        out.println("#2 " + history.getBars(instrument, period, OfferSide.BID, from, to)); // this line throws exception
        context.stop();
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {}

    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}

    @Override
    public void onMessage(IMessage message) throws JFException {}

    @Override
    public void onAccount(IAccount account) throws JFException {}

    @Override
    public void onStop() throws JFException {}
}

Image


Attachments:
File comment: The code with problem
JFTestGetBarsOnWeekend.java [1.88 KiB]
Downloaded 232 times
File comment: Strategy Log
IHistory.getBars-Error.png [113.03 KiB]
Downloaded 381 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.
 
 Post subject: Re: Inconsistent behavior of IHistory.getBars method Post rating: 0   New post Posted: Sun 03 Nov, 2013, 15:37 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
The question is rather this:
Why does the first line not throwing the exception on a Remote Run, as it does throw it on Local Run?

Interesting.
Let's wait for a Monday morning reply from Support ;).


 
 Post subject: Re: Inconsistent behavior of IHistory.getBars method Post rating: 0   New post Posted: Mon 04 Nov, 2013, 11:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We could not reproduce this:

Image


Attachments:
getBars2.png [61.89 KiB]
Downloaded 397 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.
 
 Post subject: Re: Inconsistent behavior of IHistory.getBars method Post rating: 0   New post Posted: Mon 04 Nov, 2013, 12:47 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
I also had the exception, on the Remote Server, yesterday (Sunday).

I guess the issue is related to the execution time. It replicated the issue at the weekend, and the original poster also.


 

Jump to:  

  © 1998-2024 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