Comments (8)
You are right on this point...
I'll fix it ASAP
from pyoanda.
Please check this pull request
#9
from pyoanda.
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.
Let me see your pull request
Honestly I prefer to add the parser inside the Client.__call instead of adding custom parser.
from pyoanda.
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.
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.
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.
Pending to generate new pypi version (0.7)
from pyoanda.
Related Issues (14)
- Map Order handling HOT 1
- Client: "The account ID provided is invalid" HOT 4
- Request exception handling HOT 1
- Map Trade handling HOT 1
- Generate documentation to be store in gh pages HOT 4
- Documentation for 'get_prices()' HOT 3
- Fix the tests HOT 2
- Map Position handling HOT 1
- UnboundLocalError: local variable 'response' referenced before assignment
- get_instrument_history missing 'includeFirst' param
- Oanda v10 or v20? HOT 1
- Map Transaction handling
- example fetch.ipynb not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyoanda.