Comments (11)
Thank you, you are 100% correct, I had noticed this behavior a few months back and opened a support ticket with polo to try and figure out where the rounding was coming from (thinking it might have to do with something on their end), I had never really figured it out and the bug 'disappeared.' Seems this was the initial problem to begin with.
TBH I had no idea the json module could convert values while decoding.
I'll make the commit directly to master PR and publish a release sometime today.
from python-poloniex.
Poloniex data sets are not consistent across api commands, some return numbers others return strings when you would expect numbers.
{u'bids': [[u'0.00062074', Decimal('2.41647066')],,,],}
This PR shouldn't hurt anything, but if poloniex decides to switch its unicode numbers to floats/decimals, things might get a little buggy/inconsistent if users are doing high precision math from these raw data sets.
from python-poloniex.
thinking it might have to do with something on their end
Actually, you're right here. As you've noticed, they're encoding number-likes as both json strings and number in the same message - exchange rate is a string, amount is a float.
I'm not sure whether that means that the original amount is stored as a float on their backend, or that they botched the REST code - in either case, it seems some shoddy coding on their end.
With that being said, we (library developers) should strive to give as much precision as we possibly can with what the service gives us.
if poloniex decides to switch its unicode numbers to floats/decimals, things might get a little buggy/inconsistent
That's a good point. Maybe we can parse_float=str
, and let the user deal with it?
from python-poloniex.
I agree, parse them as strings and let the user choose how they want to convert is probably best. Not sure if just str
will do it for both python 2 and 3 (maybe unicode or a futures class) but I will push the commit to #32 and test asap
from python-poloniex.
str
should work as intended in python3. In fact, unicode
doesn't exist anymore
from python-poloniex.
Here is my test using str
Python 2.7.12
>>> import poloniex
>>> polo = poloniex.Poloniex()
>>> polo.returnOrderBook('BTC_CGA')
{u'bids': [[u'0.00062355', '2.40558095'],,,
Python 3.5.2
>>> import poloniex
>>> polo = poloniex.Poloniex()
>>> polo.returnOrderBook('BTC_CGA')
{'asks': [['0.00066485', '116.26734022']
from python-poloniex.
OK... so #33 should fix the string inconsistency between python 2 and 3 (using unicode
and str
):
Python 3.5.2
>>> from poloniex import Poloniex
>>> Poloniex().returnOrderBook('BTC_CGA')
{'bids': [['0.00062461', '4.00256164'],
Python 2.7.12
>>> from poloniex import Poloniex
>>> Poloniex().returnOrderBook('BTC_CGA')
{u'bids': [[u'0.00062461', u'4.00256164'],
I think we are good for a release.
Just a small change then I think it will be ready for release, the nonce increment needs to be moved...
from python-poloniex.
I noticed you released 0.2.1
Thank you for your efforts, it's great to be able to have proper decimal precision!
In case it interests you, I'm pulling this into the experimental branch of mexbtcapi
from python-poloniex.
No problem, thanks for the help!
from python-poloniex.
I am starting not to like what we did 🙄 I'm probably going to make this all optional and allow the user to define what datatype they want to use for numbers. Probably should have been done in the first place... :P
from python-poloniex.
see #68
from python-poloniex.
Related Issues (20)
- Invalid JSON response HOT 12
- additional trading parameters? HOT 1
- Retry delays: I don't know what I'm doing and it shows
- How to bypass recaptcha screen HOT 1
- Connection Timeout HOT 1
- Coach2 class HOT 1
- amount of lowest ask and highest bid HOT 2
- Error: Cannot import name 'Poloniex'
- self.coach=Coach() object is not callable
- New PoloniexSocketed Class HOT 1
- Invalid Json Returned: Poloniex in "Maintenance Mode"
- Data requested is too large. `resolution=auto` HOT 1
- Websocket Market Messages HOT 2
- websocket example not working HOT 2
- Websocket channel 1000 (account) give a empty message HOT 1
- 'Poloniex' object has no attribute 'api'
- returnCurrencies need includeMultiChainCurrencies = true flag HOT 2
- websocket not working as expeced for the latest version: _on_close() takes 2 positional arguments but 4 were given HOT 2
- Websocket ticker on_message exposes 2 arguments but receives 3 HOT 1
- withdrawal fee HOT 2
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 python-poloniex.