Dukascopy
 
 
Wiki JStore Search Login

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.

Instrument Subscription issues.
 Post subject: Instrument Subscription issues. Post rating: 0   New post Posted: Mon 04 Jul, 2011, 16:44 
User avatar

User rating: 0
Joined: Tue 24 May, 2011, 15:47
Posts: 8
Location: United KingdomUnited Kingdom
Everytime I subscribe to a certain instrument in my strategy (using the ICLIENT interface), an additional instrument (one which I dont want to subscribe to) also gets subscribed. For example, I subscribe to the instrument using the code below:

........
client.startStrategy(new ExpStrat());
Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Instrument.GBPNZD);
client.setSubscribedInstruments(instruments);
........

In the strategy, I print the instruments that are visible using the code below:
..........
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) {
if (period == Period.TEN_SECS){
System.out.println(instrument + " Close " + askBar.getClose() + " at " + DateMan.longToString_ss(askBar.getTime()));
}
}
..........

The output I get when the strategy runs is:
NZD/USD Close 0.82803 at 04-Jul-2011 16:24:10
GBP/NZD Close 1.94111 at 04-Jul-2011 16:24:10
NZD/USD Close 0.82804 at 04-Jul-2011 16:24:20
GBP/NZD Close 1.94111 at 04-Jul-2011 16:24:20
NZD/USD Close 0.82804 at 04-Jul-2011 16:24:30
GBP/NZD Close 1.9411 at 04-Jul-2011 16:24:30

I am not sure where the instrument "NZD/USD" came from. I am getting the same result from both API 2.6.38 and API 2.6.42.

Is this expected behavior.


 
 Post subject: Re: Instrument Subscription issues. Post rating: 0   New post Posted: Tue 05 Jul, 2011, 15:24 
User avatar

User rating: 0
Joined: Tue 05 Jul, 2011, 15:21
Posts: 28
Location: Switzerland,
Would like to add to this case: when I subscribe to EURUSD, GBPUSD and EURCHF in onBar method I'm also getting USDCHF data !

However with the very same code when I subscribe only to EURUSD no addtional pairs show up in onBar calls.

I'm running Java code from Eclipse or as standalone .jar.

And later today (since around 21h CET) I was only able to get USDCHF in onBar calls despite not being subscribed to it at all ???!!

Btw it's a demo account.


 
 Post subject: Re: Instrument Subscription issues. Post rating: 0   New post Posted: Wed 06 Jul, 2011, 07:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
nimpat wrote:
I am not sure where the instrument "NZD/USD" came from. I am getting the same result from both API 2.6.38 and API 2.6.42.

Is this expected behavior.
Yes, it is normal behaviour, because if your account currency is USD, then obviously P/L is displayed in USD. So in order to calculate your P/L NZD/USD is subscribed.


 
 Post subject: Re: Instrument Subscription issues. Post rating: 0   New post Posted: Sun 10 Jul, 2011, 15:25 
User avatar

User rating: 0
Joined: Tue 24 May, 2011, 15:47
Posts: 8
Location: United KingdomUnited Kingdom
Ah. That explains it. Thanks for the reply. I will use some kind a filter within the strategy to consider only the pairs I want.


 
 Post subject: Re: Instrument Subscription issues. Post rating: 0   New post Posted: Mon 11 Jul, 2011, 07:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
nimpat wrote:
I will use some kind a filter within the strategy to consider only the pairs I want.
See the suggested practice for this purpose:
https://www.dukascopy.com/wiki/index.php ... Ticks/Bars


 

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