Class SecurityPriceInfo

  • All Implemented Interfaces:
    Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class SecurityPriceInfo
    extends Object
    implements org.joda.beans.ImmutableBean, Serializable
    Defines the meaning of the security price.

    A value of a security is measured in terms of a price which is not typically a monetary amount. Instead the price is an arbitrary number that can be converted to a monetary amount. The price will move up and down in ticks. This class provides the size and monetary value of each tick, allowing changes in the price to be converted to a monetary amount.

    Three properties define the necessary information: Tick size is the minimum movement in the price of the security (the tick). Tick value is the monetary value gained or lost when the price changes by one tick. Contract size is the quantity of the underlying present in each derivative contract, which acts as a multiplier.

    For example, the price of an ICE Brent Crude future is based on the price of a barrel of crude oil in USD. The tick size of this contract is 0.01 (equivalent to 1 cent). The contract size is 1,000 barrels. Therefore the tick value is 0.01 * 1,000 = 10 USD.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static SecurityPriceInfo of​(double tickSize,
                                           CurrencyAmount tickValue)
        Obtains an instance from the tick size and tick value.

        The contract size will be set to 1.

        Parameters:
        tickSize - the size of each tick, not negative or zero
        tickValue - the value of each tick
        Returns:
        the security price information
      • of

        public static SecurityPriceInfo of​(double tickSize,
                                           CurrencyAmount tickValue,
                                           double contractSize)
        Obtains an instance from the tick size, tick value and contract size.
        Parameters:
        tickSize - the size of each tick, not negative or zero
        tickValue - the value of each tick
        contractSize - the contract size
        Returns:
        the security price information
      • of

        public static SecurityPriceInfo of​(Currency currency,
                                           double tradeUnitValue)
        Obtains an instance from the currency and the value of a single tradeable unit.
        Parameters:
        currency - the currency in which the security is traded
        tradeUnitValue - the value of a single tradeable unit of the security
        Returns:
        the security price information
      • ofCurrencyMinorUnit

        public static SecurityPriceInfo ofCurrencyMinorUnit​(Currency currency)
        Obtains an instance from the currency.

        This sets the tick size and tick value to the minor unit of the currency. For example, for USD this will set the tick size to 0.01 and the tick value to $0.01. This typically matches the conventions of equities and bonds.

        Parameters:
        currency - the currency to derive the price information from
        Returns:
        the security price information
      • getCurrency

        public Currency getCurrency()
        Gets the currency that the security is traded in.

        The currency is derived from the tick value.

        Returns:
        the currency
      • calculateMonetaryAmount

        public CurrencyAmount calculateMonetaryAmount​(double quantity,
                                                      double price)
        Calculates the monetary value of the specified quantity and price.

        This calculates a monetary value using the stored price information. For equities, this is the premium that will be paid. For bonds, this will be the premium if the price specified is the dirty price. For margined ETDs, the profit or loss per day is the monetary difference between two calls to this method with the price on each day.

        This returns calculateMonetaryValue(double, double) as a CurrencyAmount.

        Parameters:
        quantity - the quantity, such as the number of shares or number of future contracts
        price - the price, typically from the market
        Returns:
        the monetary value combining the tick size, tick value, contract size, quantity and price.
      • calculateMonetaryValue

        public double calculateMonetaryValue​(double quantity,
                                             double price)
        Calculates the monetary value of the specified quantity and price.

        This calculates a monetary value using the stored price information. For equities, this is the premium that will be paid. For bonds, this will be the premium if the price specified is the dirty price. For margined ETDs, the profit or loss per day is the monetary difference between two calls to this method with the price on each day.

        Parameters:
        quantity - the quantity, such as the number of shares or number of future contracts
        price - the price, typically from the market
        Returns:
        the monetary value combining the tick size, tick value, contract size, quantity and price.
      • getTradeUnitValue

        public double getTradeUnitValue()
        Returns the value of a single tradeable unit of the security.

        The monetary value of a position in a security is

        tradeUnitValue * price * quantity

        This value is normally derived from the tick size, tick value and contract size:

        tradeUnitValue = tickValue * contractSize / tickSize
        Returns:
        the value of a single tradeable unit of the security
      • meta

        public static SecurityPriceInfo.Meta meta()
        The meta-bean for SecurityPriceInfo.
        Returns:
        the meta-bean, not null
      • metaBean

        public SecurityPriceInfo.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getTickSize

        public double getTickSize()
        Gets the size of each tick.

        Tick size is the minimum movement in the price of the security. For example, the price might move up or down in units of 0.01 It must be a positive decimal number.

        Returns:
        the value of the property
      • getTickValue

        public CurrencyAmount getTickValue()
        Gets the monetary value of one tick.

        Tick value is the monetary value of the minimum movement in the price of the security. When the price changes by one tick, this amount is gained or lost.

        Returns:
        the value of the property, not null
      • getContractSize

        public double getContractSize()
        Gets the size of each contract.

        Contract size is the quantity of the underlying present in each derivative contract. For example, an equity option typically consists of 100 shares.

        Returns:
        the value of the property
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object