-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currency Improvements #2609
Merged
Merged
Currency Improvements #2609
Conversation
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
- Fixes a bug where we only returned the correct currency codes when loading all sids stored in an hdf5 file. - Adds a failing test for the bug.
Don't crash on queries for currency codes of possibly-unknown sids on calls to `SessionBarReader.currency_codes`. When a currency code is requested for an unknown sid, we return zipline.currency.MISSING_CURRENCY_CODE for that sid.
These are good sanity checks/documentation, and they don't meaningfully impact performance.
peterhbromley
approved these changes
Jan 9, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all LGTM, I like that you found the wikipedia reference that 'XXX' denotes missing currency. That makes me feel good about choosing that as the display value to the users.
This causes the stored currencies to get out of sync with cls.FX_RATES_CURRENCIES.
Pipeline column objects override __lt__ to raise an error, which means using the default sorted() implementation doesn't work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains several improvements to the currency conversion support that was added in #2586 and #2597.
zipline.currency.MISSING_CURRENCY_CODE
(value'XXX'
, which denotes no currency according to wikipedia). This currency is returned byCurrencyAwareDailyBarReader
for unknown sids, or sids for which currency is unknown. I'm using this rather thanNone
or'\0\0\0'
because we're currently returning codes in numpy arrays of dtypeS3
, which can't hold None, and these values might get displayed to users, which makes\0\0\0
an awkward choice. Another option would be to useNone
, and switch to using object arrays, but that makes things like sorting annoying (None
can't be compared with strings in python 3). Object array with None is probably what we'd want to expose to users if we allow querying for currencies though (it's what we do elsewhere for string-typed data, at least), so that might be preferable.np.nan
.