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.

Instrument.values() has a non working entry of USD/CNH
 Post subject: Instrument.values() has a non working entry of USD/CNH Post rating: 0   New post Posted: Fri 11 Apr, 2014, 01:13 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
Instrument.USDCNH.getSecondaryCurrency() always gives null. Why?
It seems like a new instrument, but not working with the getSecondaryCurrency() function.


Example given.
If you start the following program with the relevant code snippet

        for (Instrument instr : Instrument.values()) { 
           try{
               console.getOut().println("instr = "+instr.toString());
               console.getOut().println("primary currency = "+instr.getPrimaryCurrency().toString());
               console.getOut().println("secondary currency = "+instr.getSecondaryCurrency().toString());
           }
           catch(Exception e){
               e.printStackTrace(console.getErr());
           }
        }


you will find the following output, generated in the messages from down to top:
[...]
00:05:22 at java.lang.Thread.run(Unknown Source)
00:05:22 at com.dukascopy.api.impl.execution.g$a.run(Unknown Source)
00:05:22 at com.dukascopy.api.impl.execution.g$a.f(Unknown Source)
00:05:22 at java.util.concurrent.FutureTask.run(Unknown Source)
00:05:22 at com.dukascopy.api.impl.execution.k.call(Unknown Source)
00:05:22 at com.dukascopy.api.impl.connect.bk.call(Unknown Source)
00:05:22 at com.dukascopy.api.impl.connect.bk.bz(Unknown Source)
00:05:22 at com.dukascopy.api.impl.connect.ag.a(Unknown Source)
00:05:22 at com.dukascopy.api.impl.execution.u.call(Unknown Source)
00:05:22 at com.dukascopy.api.impl.execution.u.call(Unknown Source)
00:05:22 at jforex.InstrumentValuesBug.onStart(InstrumentValuesBug.java:28)
00:05:22 java.lang.NullPointerException
00:05:22 primary currency = USD
00:05:22 instr = USD/CNH
[...]


seen in JForex DEMO 2.34.1 and 2.34, also in the last LIVE version


Attachments:
InstrumentValuesBug.jfx [3.28 KiB]
Downloaded 88 times
InstrumentValuesBug.java [1.51 KiB]
Downloaded 97 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: Instrument.values() has a non working entry of USD/CNH Post rating: 0   New post Posted: Fri 11 Apr, 2014, 10:26 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This is because it is a new instrument, whose currency is not a java.util.Currency. Threfore getPrimaryCurrency() and getSecondaryCurrency() are deprecated with JForex-API 2.9.8, instead one should use getPrimaryJFCurrency() and getSecondaryJFCurrency(). JForex-SDK (JForex-API 2.9.8) with the new instrument and the new currency class which handles this case will get released as soon as possible.


 
 Post subject: Re: Instrument.values() has a non working entry of USD/CNH Post rating: 0   New post Posted: Mon 14 Apr, 2014, 11:37 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
This update bug cost me about 5 hours of work and many further updates at customers. This is because we use this Instrument.values() in an important class, which is used in many strategies so far.

You still produce any kind of updates and nobody has a chance to start the old version anymore, specially when there are bugs in the new version.
This is a dangerous deadlock for our customers!

If a new version is compulsory, why can't you send BETAs to developers and other testers first, so we can approve a version and we will all save lots of work and discussions?

My urgent demand
JForex LIVE = JForex DEMO = stable and tested version
JForex BETA = testing environment


 
 Post subject: Re: Instrument.values() has a non working entry of USD/CNH Post rating: 0   New post Posted: Mon 14 Apr, 2014, 12:50 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
SFXbernhard wrote:
This update bug cost me about 5 hours of work and many further updates at customers. This is because we use this Instrument.values() in an important class, which is used in many strategies so far.
First of all this is not a bug. Your code makes an assumption that for all instruments that will get added in future to the API getPrimaryCurrency() != null and getSecondaryCurrency() != null. The assumption held while there were no non-standard-java currencies used by instruments, but relying on it was not fully justified, since it was not explicitly documented that there will never be an instrument with such currency (i.e., that for no new instrument java.util.Currency fields will be nulls). Thus, if you rely on undocumented API behaviour, then there can't be any guarantees that the code will work as you may expect with the future releases.


 

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