-
Notifications
You must be signed in to change notification settings - Fork 153
Return Decimals instead of floats? #136
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
Comments
Decimal
s instead of floats
?Sadly, `plaid-python` parses these numbers as `float` plaid/plaid-python#136
Hi @euresti, long time no see! Closing this as it's about the legacy clibs, which we aren't updating any more and we really need to fix this in the API, not the libraries. I'm going to try to get this out in the next api release (which may not be any time super soon). |
@phoenixy1 sorry for the necrobump, but I'd be curious to understand this a little more. It looks like Plaid released a new "sync" api since your message, but as far as I can tell, it says it returns a double. I'm honestly not clear on what that means in the context of JSON, which does not have a double type, just a number type. AFAICT, it's actually perfectly safe for JSON to use JSON numbers as the API does (we're just sending characters over the wire, not floating point numbers), so it feels to me like maybe it's just wrong that the docs say "double" when they should instead say something like "this is a JSON number, be careful about how you parse it to avoid floating point issues". |
@jfly ok so the deal is that the docs are generated from the OpenAPI file, which defines Plaid API. Within OpenAPI, You're right about this being kind of weird when considered in the context of JSON, and we definitely could modify the docs to override displaying the |
Thanks for the explanation @phoenixy1. I have 0 experience with OpenAPI, but after reading through their issue tracker, it sounds like an arbitrary precision "decimal" format is something that people keep asking for, and I believe does not exist:
It looks like some people have implemented various workarounds (I think maybe OpenAPI gives you a hook to extend the available formats? I don't know...), but either way, I can understand you not wanted to deal with something nonstandard.
That is surprising to me. I'd expect anyone who has dealt with floating point imprecision in the past to freak out a little if they find floating point numbers anywhere near currency. I certainly did! Would you be open to a PR to get this Python library to actually return |
Hi. I was playing with the SDK and noticed I was getting float values back from the calls.
This means that if you try to use these numbers you might hit weird floating point math issues.
A quick solution is to add
parse_float=Decimal
tojson.loads
would that be possible, or at least configurable?The text was updated successfully, but these errors were encountered: