Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def _obtain_rates(self, base_currency, currencies, date_from, date_to):
since = date_from
until = since + step
while since <= date_to:
# The API answers HTTP 400 when "from" equals "to". That is
# exactly the shape of a scheduled run once the rates are up
# to date: the provider then asks for the single missing day.
# Widening the window by one day is enough — the endpoint only
# ever returns the days it actually has, so no spurious rate
# is created.
window_end = max(min(until, date_to), since + timedelta(days=1))
url = (
"https://api.transferwise.com/v1/rates"
+ "?from=%(from)s"
Expand All @@ -70,7 +77,7 @@ def _obtain_rates(self, base_currency, currencies, date_from, date_to):
"source": base_currency,
"target": currency,
"from": str(since),
"to": str(min(until, date_to)),
"to": str(window_end),
}
data = json.loads(self._transferwise_provider_retrieve(url))
if "error" in data and data["error"]:
Expand Down
Loading