com.lmax.api
Class FixedPointNumbers

java.lang.Object
  extended by com.lmax.api.FixedPointNumbers

public class FixedPointNumbers
extends java.lang.Object

A utility class containing conversion methods to/from FixedPointNumber for a variety of formats.


Constructor Summary
FixedPointNumbers()
           
 
Method Summary
static java.math.BigDecimal bigDecimalValue(FixedPointNumber value)
          Convert a FixedPointNumber to a big decimal.
static double doubleValue(FixedPointNumber value)
          Get a double value from a FixedPointNumber.
static FixedPointNumber toFixedPointNumber(java.math.BigDecimal value, FixedPointNumber increment)
          Constructs a FixedPointNumber from a BigDecimal.
static FixedPointNumber toFixedPointNumber(double value, FixedPointNumber increment)
          Constructs a FixedPointNumber from a double.
static FixedPointNumber toFixedPointNumber(long value, FixedPointNumber increment)
          Constructs a FixedPointNumber from a long, where a long represents a number with 6 decimal places.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedPointNumbers

public FixedPointNumbers()
Method Detail

toFixedPointNumber

public static FixedPointNumber toFixedPointNumber(long value,
                                                  FixedPointNumber increment)
Constructs a FixedPointNumber from a long, where a long represents a number with 6 decimal places. This method will also round the number to the specified increment using a half even rounding mode. This is a convenince to help prevent invalid prices/quantities being sent to the server. The increment values for price and quantity can be obtained from the Instrument OrderBook information.

Parameters:
value - A long representing 6 decimal places
increment - The specified increment to use in rounding
Returns:
A new FixedPointNumber
See Also:
FixedPointNumber, RoundingMode.HALF_EVEN, Instrument.getOrderBook()

toFixedPointNumber

public static FixedPointNumber toFixedPointNumber(double value,
                                                  FixedPointNumber increment)
Constructs a FixedPointNumber from a double. This method will also round the number to the specified increment using a half even rounding mode. This is a convenince to help prevent invalid prices/quantities being sent to the server. The increment values for price and quantity can be obtained from the Instrument OrderBook information.

Parameters:
value - Value to be used
increment - The specified increment to use in rounding
Returns:
A new FixedPointNumber
See Also:
FixedPointNumber, RoundingMode.HALF_EVEN, Instrument.getOrderBook()

toFixedPointNumber

public static FixedPointNumber toFixedPointNumber(java.math.BigDecimal value,
                                                  FixedPointNumber increment)
Constructs a FixedPointNumber from a BigDecimal. This method will also round the number to the specified increment using a half even rounding mode. This is a convenince to help prevent invalid prices/quantities being sent to the server. The increment values for price and quantity can be obtained from the Instrument OrderBook information.

Parameters:
value - Value to be used
increment - The specified increment to use in rounding
Returns:
A new FixedPointNumber
See Also:
FixedPointNumber, RoundingMode.HALF_EVEN, Instrument.getOrderBook()

doubleValue

public static double doubleValue(FixedPointNumber value)
Get a double value from a FixedPointNumber.

Parameters:
value - The value to convert
Returns:
The double result

bigDecimalValue

public static java.math.BigDecimal bigDecimalValue(FixedPointNumber value)
Convert a FixedPointNumber to a big decimal.

Parameters:
value - The value to convert
Returns:
The BigDecimal result