hugues31 / coinnect

Coinnect is a Rust library aiming to provide a complete access to main crypto currencies exchanges via REST API.
MIT License
148 stars 43 forks source link

Prices in decimal instead of f64 #37

Closed vegai closed 7 years ago

vegai commented 7 years ago

Looks like the main Price type is an alias for f64. As we know, using floats for currency is a bad idea due to precision issues.

It seems like this crate is the upcoming standard: https://crates.io/crates/bigdecimal -- based on some discussion I've seen and the fact that Diesel is using it. It's been oddly quiet for a while though.

ainestal commented 7 years ago

The precision is indeed a problem. I'm researching how to implement this.

hugues31 commented 7 years ago

This could be a good idea but I will not implement it. Though I'll be happy to review a PR related to this issue. :)

vegai commented 7 years ago

I'll probably take a whack at it too, unless somebody else beats me :) Replacing f64 with bigdecimal::Bigdecimal made rustc cough up 22 errors in total -- seems like a sweeping change but possibly not a huge one.

ainestal commented 7 years ago

I've done it already. I didn't send the PR because I found an error with Poloniex and I don't know yet how to solve it.

I can send the PR but it will break the orderbook test from poloniex

ainestal commented 7 years ago

The PR is #39

vegai commented 7 years ago

Ah, cool! Thanks for the update.

ainestal commented 7 years ago

PR #39 is now closed. @hugues31 could you bump the version and close this issue? Thanks!

hugues31 commented 7 years ago

Yes, we can always open an other later for the f64 problem from Poloniex