From 79192493a143d9a4b5a7246f371a7132c960e713 Mon Sep 17 00:00:00 2001 From: Dmitri Karpovich Date: Fri, 13 Dec 2024 16:14:31 +0100 Subject: [PATCH] [core] Add adapting of price to step size --- .../main/java/org/knowm/xchange/utils/OrderValuesHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xchange-core/src/main/java/org/knowm/xchange/utils/OrderValuesHelper.java b/xchange-core/src/main/java/org/knowm/xchange/utils/OrderValuesHelper.java index d6d87390b0b..3631f1222d8 100644 --- a/xchange-core/src/main/java/org/knowm/xchange/utils/OrderValuesHelper.java +++ b/xchange-core/src/main/java/org/knowm/xchange/utils/OrderValuesHelper.java @@ -90,6 +90,11 @@ public BigDecimal adjustPrice(BigDecimal price, RoundingMode roundingMode) { if (scale != null) { result = result.setScale(scale, roundingMode); } + + BigDecimal stepSize = metaData.getPriceStepSize(); + if (stepSize != null && stepSize.signum() != 0) { + result = BigDecimalUtils.roundToStepSize(result, stepSize, roundingMode); + } return result; } }