Commit graph

14 commits

Author SHA1 Message Date
Scott Sanderson
2546708d0e MAINT: Forward-fill fx rates past file end.
If an FX rate query requests a date that's greater than the last date in the fx
rate file, forward-fill from the last value in the file rather than raising an
error.

We do this for a few reasons:

1. We'd like to gracefully handle the possibility of an FX rates file that's
   older than another input file.

2. Relative to other non-erroring behaviors, forward-filling is the simplest
   thing to implement. Specifically, it's what the implementation prior to this
   change would do naturally if there weren't an explicit check to prevent it.

3. For an FX rates file containing prices on a 24/5 calendar, some amount of
   forward-filling is required to handle any market with a non-weekday date.
2020-02-04 18:23:53 -05:00
Scott Sanderson
3841944fae BUG: Use value from loop. 2020-01-30 11:05:10 -05:00
Scott Sanderson
7f4baa6bd5 TEST: Add test coverage for loading fx rates of None.
We should always return NaN on a request to load None as an FX rate.
2020-01-30 11:03:33 -05:00
Scott Sanderson
a7e089809e MAINT: Clarify handling of edge cases in fx readers.
- When reading before the start of data, return NaN. We do this because it's
  hard to reliably apply a lower bound to the queried dates in core-loader
  style pipeline loaders.

- When reading an unknown base currency, return NaN. We might get data from
  third parties with unknown currencies. Doing so should not be an error.

- When reading after the end of data, emit an error rather than forward-filling
  forever. We may want to revisit this in the future.
2020-01-30 10:10:40 -05:00
Scott Sanderson
c6bb9768b6 ENH: Add get_rates_columnar method to FXRatesReader. 2020-01-15 11:09:03 -05:00
Scott Sanderson
b842b87e8e TEST: Add test coverage for get_rate_scalar. 2020-01-14 16:05:44 -05:00
Scott Sanderson
13777f9fdf MAINT: Use object arrays with None for currency codes.
Rather than trying to use S3s everywhere, which is annoying in Python 3 and
makes it harder to represent missing data, just use object arrays with None as
the missing value. This is the representation we want anyway for loading
currency data in pipelines, and the main downsides are performance (which
doesn't appear to be meaningfully affected) and difficulty with sorting, which
we don't need to do (at least right now).
2020-01-11 12:23:13 -05:00
Scott Sanderson
d41914284d MAINT: Move expected rate lookup functions into fixture for reuse. 2020-01-10 12:55:25 -05:00
Scott Sanderson
4eb7641708 ENH: Move reader construction into shared fixture. 2020-01-08 15:34:27 -05:00
Scott Sanderson
66b83e2b5a MAINT: Replace usages of 'default' with named sentinel.
This makes it easier to distinguish different usages of 'default', and makes it
easier in the future to change how we handle defaults.
2020-01-02 10:53:37 -05:00
Scott Sanderson
7a6c2ae585 BUG: Clarify bases type for currency queries.
- Rather than using numpy's S3 and U3 types, which behave differently in py2
  and py3, just expect object arrays of `str` everywhere.

  This makes it slightly more expensive for us to read the currency index from
  the file in py3, but that array is on the order of a hundred or so elements
  total, so that's not a major concern, and it simplifies the handling
  elsewhere.
2019-12-19 11:52:23 -05:00
Scott Sanderson
6b90f98a0c ENH: More complete support for defaults in fx readers.
Explicitly require that pipeline-compatible readers support 'default' as a
key. I'm currently just using the string 'default' for this. We should probably
move that value to a shared location, but it's not clear to me that value
should live since it's defining an interface boundary between pipeline and fx
data.
2019-12-17 16:25:50 -05:00
Scott Sanderson
b85ad28f2a MAINT: Updates to fx reader/writer.
- Add test coverage for non-scalar lookups.
- Performance optimizations for InMemoryFXRateReader and HDF5FXRateReader. We
  no longer construct a DataFrame on each call to get_rates, since doing so is
  surprisingly expensive and caused test_lookup_scalar to take more time than
  was reasonable.
2019-12-17 14:34:16 -05:00
Scott Sanderson
bcbda706a0 ENH: HDF5-based FX Reader/Writer. 2019-12-16 19:18:00 -05:00