|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.dxfeed.glossary.PriceIncrements
public class PriceIncrements
Represents rules for valid price quantization for a given instrument on a certain exchange. These rules are defined as a set of price ranges with associated price increments. Each price increment defines what price values are valid for corresponding price range - valid prices shall be divisible by corresponding price increment.
All price ranges shall be mutually exclusive and they shall cover entire space from 0 to infinity. Therefore all ranges can be represented as a sequence of numbers where increments are interleaved with range limits, with extreme limits (0 and infinity) omitted for short. Negative space (from negative infinity to 0) uses symmetrical price ranges.
There is a special value EMPTY
which is used to represent unknown or undefined rules.
This value has empty textual representation and is considered to have sole increment with value 0.
See getText()
and getPriceIncrements()
for details about used formats and representations.
NOTE:This class produces precise results for decimal numbers with at most 14 significant digits and at most 14 digits after decimal point.
Field Summary | |
---|---|
static PriceIncrements |
EMPTY
Empty price increments - it has empty text and sole increment with value 0. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
|
double |
getPriceIncrement()
Returns first price increment (for price range adjacent to 0), usually the smallest one. |
double |
getPriceIncrement(double price)
Returns price increment which shall be applied to the specified price. |
double |
getPriceIncrement(double price,
int direction)
Returns price increment which shall be applied to the specified price in the specified direction. |
double[] |
getPriceIncrements()
Returns internal representation of price increments as a single array of double values. |
int |
getPricePrecision()
Returns first price precision (for price range adjacent to 0), usually the largest one. |
int |
getPricePrecision(double price)
Returns price precision for the price range which contains specified price. |
java.lang.String |
getText()
Returns textual representation of price increments in the format: TEXT ::= "" | LIST LIST ::= INCREMENT | RANGE "; " LIST RANGE ::= INCREMENT " " UPPER_LIMIT Where INCREMENT is a price increment in the given price range and UPPER_LIMIT is the upper bound of that range. |
int |
hashCode()
|
double |
incrementPrice(double price,
int direction)
Returns specified price incremented in the specified direction by appropriate increment and then rounded to nearest valid value. |
double |
incrementPrice(double price,
int direction,
double step)
Returns specified price incremented in the specified direction by the maximum of specified step and appropriate increment, and then rounded to nearest valid value. |
double |
roundPrice(double price)
Returns specified price rounded to nearest valid value. |
double |
roundPrice(double price,
int direction)
Returns specified price rounded in the specified direction to nearest value that is valid according to price increment rules. |
java.lang.String |
toString()
|
static PriceIncrements |
valueOf(double increment)
Returns an instance of price increments for specified single increment. |
static PriceIncrements |
valueOf(double[] increments)
Returns an instance of price increments for specified internal representation. |
static PriceIncrements |
valueOf(java.lang.String text)
Returns an instance of price increments for specified textual representation. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final PriceIncrements EMPTY
Method Detail |
---|
public static PriceIncrements valueOf(java.lang.String text)
getText()
for format specification.
java.lang.IllegalArgumentException
- if text uses wrong format or contains invalid valuespublic static PriceIncrements valueOf(double increment)
java.lang.IllegalArgumentException
- if increment uses invalid valuepublic static PriceIncrements valueOf(double[] increments)
getPriceIncrements()
for details about internal representation.
java.lang.IllegalArgumentException
- if data contains invalid valuespublic java.lang.String getText()
TEXT ::= "" | LIST LIST ::= INCREMENT | RANGE "; " LIST RANGE ::= INCREMENT " " UPPER_LIMITWhere INCREMENT is a price increment in the given price range and UPPER_LIMIT is the upper bound of that range. All ranges are listed in the ascending order of upper limits and the last range is considered to extend toward infinity and is therefore specified without upper limit. All increments and limits are finite positive numbers. The case with empty text is a special stub used for
EMPTY
value, it uses sole increment with value 0.
public double[] getPriceIncrements()
getText()
) in the same order.
Therefore numbers at even positions are increments and numbers at odd positions are upper limits.
The array always has odd length - the infinite upper limit of last range is always omitted and
the first increment (for price range adjacent to 0) is always included even for EMPTY
value.
public double getPriceIncrement()
EMPTY
price increments.
public double getPriceIncrement(double price)
getPriceIncrement(price, 0)
.
public double getPriceIncrement(double price, int direction)
public int getPricePrecision()
EMPTY
price increments.
public int getPricePrecision(double price)
public double roundPrice(double price)
roundPrice(price, 0)
.
public double roundPrice(double price, int direction)
public double incrementPrice(double price, int direction)
incrementPrice(price, direction, 0)
.
java.lang.IllegalArgumentException
- if direction is 0public double incrementPrice(double price, int direction, double step)
java.lang.IllegalArgumentException
- if direction is 0 or step uses invalid valuepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |