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.

Strategy stopping when connection is lost
 Post subject: Strategy stopping when connection is lost Post rating: 0   New post Posted: Fri 14 Jun, 2013, 19:10 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
Hi,

I'm using this method on my strategy:

public double getValue(Instrument instrument) throws JFException
{
JFUtils utils = context.getUtils();
double pipvalue = utils.convertPipToCurrency(instrument, cuenta.getCurrency());
return pipvalue;
}
I call this method on every 10sec bar. When Internet connection is lost and connection comes back I get this error message:

17:58:16 com.dukascopy.api.JFException: Unable to make the conversion. There are no active, subscirbed instruments containing EUR.


I guess that it is because the instruments are temporally unavailable. I would like to avoid this error because the strategy is supposed to monitor the prices every 10 sec and make a kind of trailing stop. How can I avoid this happening?

Thanks


 
 Post subject: Re: Strategy stopping when connection is lost Post rating: 0   New post Posted: Mon 17 Jun, 2013, 07:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
carlosfx wrote:
I would like to avoid this error because the strategy is supposed to monitor the prices every 10 sec and make a kind of trailing stop.
Consider handling the exception and returning the previous value in such case.
Quote:
How can I avoid this happening?
What in particular you want to avoid? If the connection is not there, you neither receive latest prices, nor can do trading operations.


 
 Post subject: Re: Strategy stopping when connection is lost Post rating: 0   New post Posted: Tue 18 Jun, 2013, 18:30 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
I have no experience handling exceptions. Actually I have limited knowledge of java, I'm slowly learning it with the only purpose to code strategies.

Could you please tell me if this would work to avoid the strategy stopping?

This is the method which throws the exception:

public double getValue(Instrument instrument) throws JFException
{
JFUtils utils = context.getUtils();
double pipvalue = utils.convertPipToCurrency(instrument, cuenta.getCurrency());
return pipvalue;

}


I used to call getValue method with the statement:

pipvalue = getValue(instrument);

Would this work to handle the exception and avoid the strategy stopping?

try
{
pipvalue = getValue(instrument);
}
catch (JFException exc)
{
print("exception:" + exc);
return;
}

Thanks a lot for your help


 
 Post subject: Re: Strategy stopping when connection is lost Post rating: 1   New post Posted: Tue 18 Jun, 2013, 19:33 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
The exception handling is fine.

As long as 'pipvalue' holding the value returned by getValue() holds its old value from a previous call to getValue(),
then when the exception occurs, you will catch it and 'pipvalue' will remain unchanged.


 
 Post subject: Re: Strategy stopping when connection is lost Post rating: 0   New post Posted: Tue 22 Oct, 2013, 19:11 

User rating: 0
Joined: Thu 30 Jun, 2011, 20:11
Posts: 41
Location: Spain,
Thanks a lot for your help. I didn't see your answer till now since I was not looking at the forum.


 

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