-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
144 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
|
||
|
||
def check_dts(stored_dts, requested_dts): | ||
""" | ||
Validate that ``requested_dts`` are valid for querying from an FX reader | ||
that has data for ``stored_dts``. | ||
""" | ||
request_end = requested_dts[-1] | ||
data_end = stored_dts[-1] | ||
|
||
if not is_sorted_ascending(requested_dts): | ||
raise ValueError("Requested fx rates with non-ascending dts.") | ||
|
||
if request_end > data_end: | ||
raise ValueError( | ||
"Requested fx rates ending at {}, but data ends at {}" | ||
.format(request_end, data_end) | ||
) | ||
|
||
|
||
def is_sorted_ascending(array): | ||
return (np.maximum.accumulate(array) <= array).all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters