question

Upvotes
Accepted
1 0 1 1

RDC Support query for CITIC Bank

The question is : Client is asking why there always has some string as end of every price, highlighted in below screen shot. And the full log is in attachment.

Best Regards!

treprfarfa-apitradesupport
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
1.5k 3 5 7

I suppose because those price are from a market place where quoting is still done in fractions. I can't tell from your screenshot exactly what that market is, but in all of the world there are still a few (very few) market places left where quoting is still done in fractions, meaning "910 3/8" instead of "910.375".

Quoting in fractions is a historical left-over. Most market places went through a process known as "decimalisation" about 10-15 years ago where quoting was changed from using fractions to using decimals. But as I said, there are still some markets left where quoting is done in fractions (hint of where to look for this in the world: Americans like to hang onto strange ways of measurement :-))

The RFA API has functionality to deal with fractions behind your back. It is only when you do things like "toString()" that you'll see that that the actual value is a fractional, not decimal. So it is not really something that you need to concern yourself with as a developer. However, for display purposes it is more correct to display the value as "910 3/8" (nine-hundred and ten plus three eigths) rather than "910.375".

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
9.5k 10 5 7

Hello @pengbiyang

Some string as an end of every price that the client sees is the fraction of price. That means REF_PRICE =910 2/8 is 910.25 in decimal format. This is calculated from 910 + 2/8(0.25).

An application can print a price in fraction format e.g. 910 2/8 when it calls OMMData.toString() method. The method applies a hint automatically. The hint is used in the REAL types (REAL, REAL32 or REAL64) which is the type of price fields. The hint specifies denominators for fractions, specifies exponents, or indicates the value is blank. If the client would like to print a price which hint is fraction divisor in decimal format e.g. 910.25 instead of 910 2/8, the application has to perform this by itself.

The example snipped source code in RFA Java to print decimal format instead of fraction divisor e.g. 910.25 instead of 910 2/8 is shown below:

private static void decodePrimitive(OMMData data)
{
    if (data == null)
		return;
    if( data.isBlank())
		return;
    short dataType = data.getType();
    switch (dataType)
    {
	case OMMTypes.REAL:
        case OMMTypes.REAL_4RB:
        case OMMTypes.REAL_8RB:
        {
	   OMMNumeric ommNum = ((OMMNumeric)data);
           //getLongValue() is to get the long part of real which is used in conjunction with hint.
            //For example: 910 2/8, the long value is 7282 and the hint is DIVISOR_8.
            long value = ommNum.getLongValue();
            byte hint = ommNum.getHint();
            prnDecimalofFractionalREAL(data, hint, value);
            break;
        }
	//another case
	...
    }
}
private static void prnDecimalofFractionalREAL(OMMData data, byte hint, long value)
{
    //check if the data is a fraction divisor e.g. 910 2/8 
    if(hint >= com.reuters.rfa.omm.OMMNumeric.DIVISOR_1) { 
       //Example: 910 2/8, the long value is 7282 and the hint is DIVISOR_8.
	//DIVISOR_8 value is 25 while DIVISOR_1 value is 22.
	//exponent = 25-22 =3
	byte exponent = (byte) ((byte)hint - (byte)OMMNumeric.DIVISOR_1); 
	//divisor = 2^3 = 8
	long divisor = (long)(Math.pow(2, exponent)); 
	//decimalValue 7282/8 = 910.25
       double decimalValue = (double)((double)value/(double)divisor); 
       //output: OMMData.toString() of REAL is 910 2/8; Decimal is 910.25
       System.out.println("OMMData.toString() of REAL is " 
		+ data.toString() + "; Decimal is " + decimalValue);    
   }
}

For more details of hint and REAL types (e.g. price fields), please refer to [RFA_Java_Package]/Docs/refman/rfajava/com/reuters/rfa/omm/OMMNumeric.html

Hope this help.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea