Package org.knowm.xchange.utils
Class OrderValuesHelper
java.lang.Object
org.knowm.xchange.utils.OrderValuesHelper
public class OrderValuesHelper extends Object
Helps you to validate and / or adjust order values like price and amount to the restrictions
dictated by
InstrumentMetaData
- Author:
- walec51
-
Constructor Summary
Constructors Constructor Description OrderValuesHelper(InstrumentMetaData metaData)
-
Method Summary
Modifier and Type Method Description BigDecimal
adjustAmount(BigDecimal amount)
Adjusts the given amount to the restrictions dictated byInstrumentMetaData
.BigDecimal
adjustPrice(BigDecimal price, RoundingMode roundingMode)
Adjusts the given price to the restrictions dictated byInstrumentMetaData
.BigDecimal
adjustPrice(BigDecimal price, Order.OrderType orderType)
Adjusts the given price to the restrictions dictated byInstrumentMetaData
.boolean
amountUnderMinimum(BigDecimal amount)
-
Constructor Details
-
OrderValuesHelper
-
-
Method Details
-
amountUnderMinimum
- Returns:
- true if the minimum amount is specified in the currency pair and if the amount is under it
-
adjustAmount
Adjusts the given amount to the restrictions dictated byInstrumentMetaData
.This mainly does rounding based on
InstrumentMetaData#getVolumeScale()
andInstrumentMetaData#getAmountStepSize()
if they are present in the metadata. It will also return the maximum allowed amount if()
is set and your amount is greater.- Parameters:
amount
- the amount your derived from your users input or your calculations- Returns:
- amount adjusted to the restrictions dictated by
InstrumentMetaData
-
adjustPrice
Adjusts the given price to the restrictions dictated byInstrumentMetaData
.Convenience method that chooses the adequate rounding mode for you order type. See
adjustPrice(java.math.BigDecimal, java.math.RoundingMode)
for more information. -
adjustPrice
Adjusts the given price to the restrictions dictated byInstrumentMetaData
.This mainly does rounding based on
InstrumentMetaData#getPriceScale()
if it is present in the metadata.- Parameters:
price
- the price your derived from your users input or your calculations- Returns:
- price adjusted to the restrictions dictated by
InstrumentMetaData
-