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 Details

  • Method Details

    • amountUnderMinimum

      public boolean amountUnderMinimum(BigDecimal amount)
      Returns:
      true if the minimum amount is specified in the currency pair and if the amount is under it
    • adjustAmount

      public BigDecimal adjustAmount(BigDecimal amount)
      Adjusts the given amount to the restrictions dictated by InstrumentMetaData.

      This mainly does rounding based on

      invalid @link
      InstrumentMetaData#getVolumeScale()
      and
      invalid @link
      InstrumentMetaData#getAmountStepSize()
      if they are present in the metadata. It will also return the maximum allowed amount if
      invalid @link
      ()
      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

      public BigDecimal adjustPrice(BigDecimal price, Order.OrderType orderType)
      Adjusts the given price to the restrictions dictated by InstrumentMetaData.

      Convenience method that chooses the adequate rounding mode for you order type. See adjustPrice(java.math.BigDecimal, java.math.RoundingMode) for more information.

      See Also:
    • adjustPrice

      public BigDecimal adjustPrice(BigDecimal price, RoundingMode roundingMode)
      Adjusts the given price to the restrictions dictated by InstrumentMetaData.

      This mainly does rounding based on

      invalid @link
      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