Rounding issues - when will we finally be precise?
See original GitHub issueDear fellows, I am more and more desperate with rounding issues in ccxt. I even went the hard way of researching exchange.number: String switch because of it, which has been suggested by @frosty00, which caused me even more pain and lost funds. What should I do? Again and again I face rounding errors which can’t be fixed in the current state of your framework.
Shouldn’t PRECISE MATH be priority n1 when dealing with money??
- OS: linux
- Programming Language version: nodejs
- CCXT version: 2.4.47
//okex
let balance = exchange.fetchBalance({type: 'funding'});
//{"availBal":"828810596.00089356","bal":"828810596.00089356","ccy":"SOS","frozenBal":"0"}
console.log(balance['SOS'])
//{ free: 828810596.0008936, used: 0, total: 828810596.0008936 }
Don’t tell me to use ‘number’: String switch please, unless you are ready to assist with problems using it (not just laugh in the eyes by closing it like #15238)
Thanks!
Issue Analytics
- State:
- Created 9 months ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Bound to Round: 8 Tips for Dealing with Hanging Pennies
The Rounding Dilemma · 1. Notify Stakeholders · 2. Use Banker's Rounding · 3. Use Data Types That Hold the Most Precision ·...
Read more >Rounding Error
Rounding can produce highly inaccurate results as errors get propagated through repeated operations using inaccurate numbers. Proper handling of rounding error ...
Read more >Accuracy and Precision
Rounding to control error is the use of significant digits.. We can round to any digit. We can round up, down, or simply...
Read more >The deadly consequences of rounding errors.
In politics, stock markets, space, and the battlefield, software rounding errors have had enormous consequences.
Read more >Unexpected results when computing numbers or rounding - IBM
I'm using SPSS Statistics and have noticed that it sometimes doesn't produce correct results when rounding numbers using the RND function, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is something that you and I both want. Thank you for you patience with it. I have a project with all the string math PRs that I have opened https://github.com/orgs/ccxt/projects/52/views/1
Those PRs use string math for all the calculations involving money, but recently I’ve found out that there are some bugs related to math involving any value returned from the exchange if
'number': String
is used, so once all those PRs are merged, I’ll need to do a final scan through the library for any arithmetic and take care of those bugs.The updates are already written, but they need to be reviewed and merged, but there’s a lot of PRs for this library, and only few people that can review and merge them, so resources are limited. I’m pretty sure that one of the lead developers plans to go through all of them soon though. If you would like, you can go to the ccxt discord server, and try to talk to one of the members with the role lead. Those members are the ones who are able to review and merge PRs.
Sorry for the wait, and once again thank you for your patience.
@krychla1 please copy your message from https://github.com/ccxt/ccxt/issues/15238#issue-1402396605 and integrate into the top-post of this issue, so we can close that as duplicate, and leave this topic open.