% Change off by factor of 100

Hello,

I am finding that % change values returned by “currencies/ticker” need to be multiplied by 100 to get the actual % change.

Is this an error on the API side or deliberate?

I am happy to do the math on my side but don’t want things to blow up if this is in fact an error that may get fixed at some point.

Cheers,

Shaun

Hello Shaun,

They are intentionally implemented this way, it tends to be easier for math (i.e. multiply it by the price and you get the change in the price’s unit). The “multiply by 100” generally only occurs when you are preparing to present the data to the human eye, and is usually done at the presentation layer in a normalized way.

For example, in JavaScript, you would do this:

(new Intl.NumberFormat('en-us', {style: 'percent'})).format(0.50)
// -> "50%"

Since many formatting libraries expect percents without being multiplied by 100, it makes it easier to use.

Hello Nick,

Thank you for your very fast response and easy to understand explanation.

Cheers,

Shaun

1 Like