MicroPyramid / forex-python

Foreign exchange rates, Bitcoin price index and currency conversion using ratesapi.io
http://forex-python.readthedocs.io/en/latest/usage.html
MIT License
661 stars 195 forks source link

get_rate doesnt return correct rates #122

Open erkan612 opened 1 year ago

erkan612 commented 1 year ago

I'm trying to get rates of a day, I need to storage them in a list by 5min perioid but the problem is, even tho it takes hour-minute-second arguments, it doesnt give me the rate from the exact hour-minute-second that i want. Here's my example code:

from datetime import datetime
from forex_python.converter import CurrencyRates
c = CurrencyRates()
rates = []
for val in range(1):
    dt = datetime.strptime("2022-11-30 23:59:59", '%Y-%m-%d %H:%M:%S')
    rate = c.get_rate('USD', 'TRY', dt)
    rates.append(rate)

dt = datetime.strptime("2022-11-30 21:59:59", '%Y-%m-%d %H:%M:%S')
rate = c.get_rate('USD', 'TRY', dt)
rates.append(rate)
print(rates[1], "\n")
print(rates[0], "\n")

Doesn't matter which time i change, it always returns same value, which is 18.632710100231304