Code Monkey home page Code Monkey logo

Comments (8)

toloco avatar toloco commented on September 23, 2024

You are right on this point...

I'll fix it ASAP

from pyoanda.

toloco avatar toloco commented on September 23, 2024

Please check this pull request
#9

from pyoanda.

elyobo avatar elyobo commented on September 23, 2024

On the same note, we need to provide a way to set the options for the json parsing in Client.__call, for exactly the same reason. By default JSON floats will get parsed to python floats, which introduces the same precision errors. When using the streaming API to get prices I pass parse_float=decimal.Decimal to the json.loads() call that I use, which causes the parsing to automatically load the value into a Decimal object and avoiding the inaccuracy.

Perhaps a dict of args to use to load json as a property of the client, so that users can modify this behaviour if they need to? I can provide a pull request if you're OK with the idea.

from pyoanda.

toloco avatar toloco commented on September 23, 2024

Let me see your pull request

Honestly I prefer to add the parser inside the Client.__call instead of adding custom parser.

from pyoanda.

elyobo avatar elyobo commented on September 23, 2024

Added a PR in #11. We could pass the options in to __call() as well, but that would require changing the signature of all methods to include those option arguments and then for users of the client to set that option for every call. For the purpose of controlling float parsing, it's definitely something that you'd want to set globally.

from pyoanda.

toloco avatar toloco commented on September 23, 2024

I like your solution, just a quick one
init(... json_option=None)
self.json_options = json_options or {}
Never use mutable objects as default arguments
http://docs.python-guide.org/en/latest/writing/gotchas/

from pyoanda.

elyobo avatar elyobo commented on September 23, 2024

Ha, excellent, thanks for that. I am new to python and that's a very handy gotcha to know. I'll update the PR.

from pyoanda.

toloco avatar toloco commented on September 23, 2024

Pending to generate new pypi version (0.7)

from pyoanda.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.