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.

IPluginContext.getHistory().getLastTick() -> JFException: Instrument [GBP/CAD] is not subscribed
 Post subject: IPluginContext.getHistory().getLastTick() -> JFException: Instrument [GBP/CAD] is not subscribed Post rating: 0   New post Posted: Fri 29 Sep, 2017, 10:32 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
I have two problems in latest version of Jforex3 (v3.2.16).

1. I manually subscribe to roughly 20 instruments, but at some (unpredicatble) time _after_ restart of the platform number of subscribed instruments is automatically reset to 10. This does not happen every restart, but does happen during restarts within a day or two. After that i have to manually review which instruments are missing from the thoroughly selected list and re-add them - this is rather time consuming and very annoying.

2. To workaround that problem i've tried to automate re-adding instruments from plugin, but this does not work :( - after i subscribe to ticks feed platform still says
"Instrument [XXX/YYY] is not subscribed"

Here is the simple code to reproduce:

package jforex;

import com.dukascopy.api.*;
import com.dukascopy.api.plugins.*;
import com.dukascopy.api.feed.ITickFeedListener;

public class SubscriptionTestPlugin extends Plugin implements ITickFeedListener {
    private IPluginContext context;
   
    public void onStart(IPluginContext context) throws JFException {
        this.context = context;
        try {
            Instrument i = Instrument.fromString("GBP/CAD");
            context.subscribeToTicksFeed(i, this);
            context.getHistory().getLastTick(i);  // com.dukascopy.api.JFException: Instrument [GBP/CAD] is not subscribed
        }
        catch( Exception e ) {
            e.printStackTrace(context.getConsole().getErr());
        }       
    }

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


 
 Post subject: Re: IPluginContext.getHistory().getLastTick() -> JFException: Instrument [GBP/CAD] is not subscribed Post rating: 0   New post Posted: Mon 02 Oct, 2017, 22:00 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
Ok, I got what is wrong - the only working way to subscribe an instrument is IContext.setSubscribedInstruments(). The funny & misleading thing is that IContext.getHistory().getLastTick(instrument) throws 'not subscribed' exception whereas IContext.subscribeToTicksFeed(instrument) silently works in the same conditions ...

Thanks for timely support ;)


 

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