Skip to content

Unusual exchange rates that are actually incorrect #107

@DanilZherebtsov

Description

@DanilZherebtsov

forex_python returns incorrect exchange rates for some dates

# example
import pandas as pd
df = pd.DataFrame({'date': ['2011-08-01 02:12:55',
                            '2011-08-23 03:14:11',
                            '2011-08-27 14:11:51',
                            '2011-09-01 06:33:21',
                            '2011-09-05 23:15:11',
                            '2011-09-06 21:19:52',
                            '2011-09-08 17:01:16',
                            '2011-09-09 14:11:17',
                            '2011-09-10 19:15:12',
                            '2011-09-15 01:52:19']})

from forex_python import CurrencyRates
c = CurrencyRates()
rates = []
for val in df['date']:
    dt = datetime.strptime(val, '%Y-%m-%d %H:%M:%S')
    rate = c.get_rate('USD', 'RUB', dt)
    rates.append(rate)

print(rates)
[27.567811307665625,
28.92096528834186,
28.919594500763782,
28.990549527476368,
76.28786342123057, <--- incorrect
29.580679480814247,
26.931377115354756,
27.043069694596714,
76.15971737613398, <--- incorrect
76.15971737613398] <--- incorrect

And while we're at it, could you please comment: can I pass a list of dates to the api call? Because it takes a lot of time to make even 10 api calls. Some of my datasets have tens of thousands of rows with datetime values. It will take forever to parse them one by one as in the code above

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions