-
Notifications
You must be signed in to change notification settings - Fork 195
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
Getting wrong values for conversion rate EUR to USD and GBP to USD using forex_python package #145
Comments
It's broken? from forex_python.converter import CurrencyRates
from datetime import datetime
# Get the current date in the format "YYYY-MM-DD"
current_date = datetime.now().strftime("%Y-%m-%d")
# Define the currency pairs
from_currency = 'GBP'
to_currency_usd = 'USD'
to_currency_eur = 'EUR'
# Initialize the CurrencyRates object
cr = CurrencyRates()
# Fetch the exchange rates for today
rates = cr.get_rates('EUR') # same as https://theforexapi.com/api/latest?base=EUR
eur_to_usd = cr.get_rate('EUR', 'USD') # same as https://theforexapi.com/api/latest?base=EUR&symbols=USD (Seems to be broken, shows rates for ILS)
print(rates)
print(eur_to_usd) https://theforexapi.com/api/latest?base=EUR&symbols=USD returns ILS (Israeli new shekel) as base
Wrong date too, maybe a hacker manipulating the market!! Puts on tinfoil hat |
Still has the same values for me. No change |
This is not something the creator of the package can fix, it's TheForexAPI's problem apiforfun/theforexapi#18 if anything MicroPyramid could just add a warning or return NULL until this is fixed so people who might have automations around this don't possibly lose money. |
I have written a python script for converting EUR to USD and GBP to USD based on today's value using python package forex_python, but I am getting incorrect conversion rates for both.
Here is my code -
from forex_python.converter import CurrencyRates
from datetime import datetime
Get the current date in the format "YYYY-MM-DD"
current_date = datetime.now().strftime("%Y-%m-%d")
Define the currency pairs
from_currency = 'GBP'
to_currency_usd = 'USD'
to_currency_eur = 'EUR'
Initialize the CurrencyRates object
c = CurrencyRates()
Fetch the exchange rates for today
y = c.get_rate(from_currency, to_currency_usd)
z = c.get_rate(to_currency_eur, to_currency_usd)
I am getting EUR to USD as 0.27 whereas today's value is 1.07
I am getting GBP to USD as 1.27 whereas today's value is 1.25
Any solution for it?
The text was updated successfully, but these errors were encountered: