python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

chore: update round_step_size to use quantize

Open pcriadoperez opened this issue 1 year ago • 2 comments

Ran tests with old code and new code and gave the same result. There was one exception where old code if step size was 1.0 would round like a step size of 1 while current implementations step size 1.0 rounds like 0.1

Fix #1496

pcriadoperez avatar Dec 09 '24 04:12 pcriadoperez

Coverage Status

coverage: 67.986%. remained the same when pulling 2e27c2af313a9f7588b8bba37c01ce5fb0072801 on pcriadoperez:round-step-size into 10f398688b58fed8fc0e28e9e0c36d0cb01fdd24 on sammchardy:master.

coveralls avatar Dec 11 '24 04:12 coveralls

Please note that accepting float might lead to undesired results:

round_step_size(0.09999999999999999, 0.1)
Out[11]: 0.0

round_step_size(0.09999999999999999999, 0.1)
Out[12]: 0.1

If the type of the argument is float, add an eps (machine precision) prior to rounding.

christophlins avatar Dec 12 '24 15:12 christophlins