So, I am writing a crypto trading bot. I can work out how much of ETH I can buy with the BTC I have, but you can only buy ETH in incremental values. The increments would range from 1000 to 0.001 depending on coin.
Question is how do I round 123.456789 down to 123.456 if the increment is 0.001 and 120 if the increment is 10.
Edit-The other question suggested was with a fixed number of DP while this was variable.