Joined 26.06.2019
How to convert the price of the int64 form spot to the real price of the double form?
26 Jul 2019, 17:52
I received the spot from the server ,the spot is an integer in the form of int64. We all know that the real price is a double floating point number.
for example。
EURUSD: Spot: 111298 double:1.11298
ProtoOASymbol.digits is 5
so,I usually convert the spot to a real double using the value of ProtoOASymbol.digits
But. There are some problems on GBPJPY.
the spot from the server is 13472100 ,and ProtoOASymbol.digits is 3. I know that its real price is 134.721
so , How to convert? Maybe you can tell me to remove the 2 zeros from the back.
This is obvious,But in this case, I have to do a separate treatment for each currency pair.
And I'm not sure if there is a spot value for a currency pair that is 134721000 9-digit value。
so,Is there any general way to do this conversion?
Replies
66281850
29 Jul 2019, 09:27
RE:
Panagiotis Charalampous said:
Hi 66281850,
Use spot price * 10^(-Symbol Digits).
Best Regards,
Panagiotis
That's what I thought. But this method is useless for certain currency pairs. For example, GBPJPY, Is it a bug in the spot value of the GBPJPY?
GBPJPY : spot is 13472100 , ProtoOASymbol.digits is 3,
spot price *10^(-Symbol Digits). = 13472100 * 0.001= 13472.1
@66281850
66281850
30 Jul 2019, 05:57
I found that all currency pairs related to the yen and USDHUF have this problem. Its spot value is always 2 more zeros.
The correct conversion formula should be :
spot -》 double = spot price *10^(-(Symbol Digits+2) ).
Is this a server bug? Either the spot value is wrong or the Symbol.Digits is wrong?
@66281850


PanagiotisCharalampous
29 Jul 2019, 09:20
Hi 66281850,
Use spot price * 10^(-Symbol Digits).
Best Regards,
Panagiotis
@PanagiotisCharalampous