-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exchange rate sometimes inexplicably 1.0 #4
Comments
I've got $100 for anyone who can replicate it and show a solution (not just a workaround). |
Here's the smallest bit of code that will produce the inconsistent results. It only does it on my production server, not on my development machine (not even in production mode). rails@li354-33:/srv/tinefcon-orders/current$ ./script/console production Loading production environment (Rails 2.3.8) >> ["AUD", "CAD", "EUR", "HKD", "PLN", "RUB", "ZAR", "GBP", "USD"].map {|c| ISO4217::Currency.from_code(c).exchange_rate } => [1.0, 0.6493, 0.8819, 0.0787, 0.2209, 0.0221, 1.0, 1.0, 505571776.0] >> ["AUD", "CAD", "EUR", "HKD", "PLN", "RUB", "ZAR", "GBP", "USD"].map {|c| ISO4217::Currency.from_code(c).exchange_rate } => [1.0, 0.6493, 0.8819, 0.0787, 0.2209, 0.0221, 1.0, 1.0, 505571776.0] >> exit rails@li354-33:/srv/tinefcon-orders/current$ ./script/console production Loading production environment (Rails 2.3.8) >> ["AUD", "CAD", "EUR", "HKD", "PLN", "RUB", "ZAR", "GBP", "USD"].map {|c| ISO4217::Currency.from_code(c).exchange_rate } => [0.665, 0.6493, 0.8819, 0.0787, 1.0, 0.0221, 0.0906, 1.0, 0.6135] >> exit |
Mystery solved. It's actually coming from Yahoo that way. ?> ["AUD", "CAD", "EUR", "HKD", "PLN", "RUB", "ZAR", "GBP", "USD"].each {|c| puts get_yahoo_response(c) } "AUDGBP=X",1.00,"N/A","N/A" "CADGBP=X",0.6494,"7/21/2011","12:59pm" "EURGBP=X",0.8821,"7/21/2011","12:59pm" "HKDGBP=X",0.0787,"7/21/2011","12:59pm" "PLNGBP=X",1.00,"N/A","N/A" "RUBGBP=X",1.00,"N/A","N/A" "ZARGBP=X",1.00,"N/A","N/A" "GBPGBP=X",1.00,"N/A","N/A" "USDGBP=X",0.6134,"7/21/2011","12:59pm" Now to figure out why. |
I'm going to use https://github.com/RubyMoney/eu_central_bank instead. So long and thanks for all the fish. |
Sorry for the slow response, I have been planning my wedding and very swamped. I will take a look at Yahoo and see if they changed something or are just mucking it up. |
I've dug through the code, but I can't figure out why sometimes in my Rails application, a few currencies come out with an exchange rate of 1.0.
In an initializer, I'm setting
ISO4217::Currency.base_currency = 'GBP'
Yet somehow:
I understand that
load_exchange_rate
doesn't actually store it in@exchange_rate
, I just wanted to show that it's getting it successfully from Yahoo Finance. What I don't understand is how@exchange_rate
got to be 1.0 in the first place. My only call to the Currency class is in a model...The text was updated successfully, but these errors were encountered: