vlado/open_exchange_rates

Open Exchange Rates limit to four decimal precision

Closed this issue · 4 comments

In the binding.pry below, expected the exchange to be 0.846563, NOT 0.8466. Don't see a way to pass in precision. Am I missing something?

fx = OpenExchangeRates::Rates.new

=> #<OpenExchangeRates::Rates:0x007fb32c3fea58
 @app_id="ed313d98b7a74e6884dd35825ea13eef",
 @base="USD",
 @latest_parser=#<OpenExchangeRates::Parser:0x007fb32c394d88>,
 @latest_response=
  {"disclaimer"=>"Usage subject to terms: https://openexchangerates.org/terms",
   "license"=>"https://openexchangerates.org/license",
   "timestamp"=>1503342000,
   "base"=>"USD",
   "rates"=>
    {"AED"=>3.673018,
     "AFN"=>68.656,
     "ALL"=>112.06,
     ...
     "EUR"=>0.846563,

fx.exchange_rate(:from => "USD", :to => "EUR") # =>0.846563
=> 0.8466
vlado commented

Hi @pts-owentran, this is strange. If I open irb session and try the same I get 0.846563

screen_shot_2017-08-21_at_21_59_13

vlado commented

What version of gem are you using?

Hi @vlado, you're right. I forked the repo and saw the right precision as well. I believe it's an issue of a monkeypatch in our rails lib initializers Closing this out. Thanks so much for the quick reply!

vlado commented

I quickly checked and found this commit 5310437 that fixed rounding error.

If you use latest version (0.5.1 currently) you should be ok :)