CodeReclaimers / btce-api

Python wrapper around the public and trading APIs of BTC-e.com
MIT License
191 stars 123 forks source link

decimal_places shouldn't be applied to amount #50

Open akovalenko opened 7 years ago

akovalenko commented 7 years ago

Pair's decimal_places are really about rate. Amount, as long as it's greater than the minimum, can have up to 8 decimal places regardless the pair and currency (at least in Trade method parameter and result set, but I suspect it applies everywhere). Enforcing 8 decimal places in parameter values ARE important, 9 or more places are rejected.

I failed to find a reference to 8-digit amount precision in the documentation -- maybe some other libraries have it, as there are obviously many bots buying and selling amounts like 0.01003882 BTC.

Looking at the code, I'd suggest that format_currency should be split in format_rate and format_amount (the latter doesn't really need pair information, so it's unclear in what class should in be defined). For existing code calling format_currency, it should probably be treated like format_rate to be on the safe side. Maybe I'll have some time to prepare a complete patch.

CodeReclaimers commented 7 years ago

Thank you for reporting this, if you don't get time to write up a patch soon I'll see if I can address it. Sorry for taking so long to respond--free time has been scarce lately!