Class DsfPosition

  • All Implemented Interfaces:
    CalculationTarget, Resolvable<ResolvedDsfTrade>, PortfolioItem, Position, SecuritizedProductPortfolioItem<Dsf>, SecuritizedProductPosition<Dsf>, SecurityQuantity, java.io.Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class DsfPosition
    extends java.lang.Object
    implements SecuritizedProductPosition<Dsf>, Resolvable<ResolvedDsfTrade>, org.joda.beans.ImmutableBean, java.io.Serializable
    A position in a DSF.

    A position in an underlying Dsf.

    The net quantity of the position is stored using two fields - longQuantity and shortQuantity. These two fields must not be negative. In many cases, only a long quantity or short quantity will be present with the other set to zero. However it is also possible for both to be non-zero, allowing long and short positions to be treated separately. The net quantity is available via getQuantity().

    Price

    Strata uses decimal prices for DSFs in the trade model, pricers and market data. The decimal price is based on the decimal multiplier equivalent to the implied percentage. Thus the market price of 100.182 is represented in Strata by 1.00182.
    See Also:
    Serialized Form
    • Method Detail

      • ofNet

        public static DsfPosition ofNet​(PositionInfo positionInfo,
                                        Dsf product,
                                        double netQuantity)
        Obtains an instance from position information, product and net quantity.

        The net quantity is the long quantity minus the short quantity, which may be negative. If the quantity is positive it is treated as a long quantity. Otherwise it is treated as a short quantity.

        Parameters:
        positionInfo - the position information
        product - the underlying product
        netQuantity - the net quantity of the underlying security
        Returns:
        the position
      • ofLongShort

        public static DsfPosition ofLongShort​(PositionInfo positionInfo,
                                              Dsf product,
                                              double longQuantity,
                                              double shortQuantity)
        Obtains an instance from position information, product, long quantity and short quantity.

        The long quantity and short quantity must be zero or positive, not negative. In many cases, only a long quantity or short quantity will be present with the other set to zero. However it is also possible for both to be non-zero, allowing long and short positions to be treated separately.

        Parameters:
        positionInfo - the position information
        product - the underlying product
        longQuantity - the long quantity of the underlying security
        shortQuantity - the short quantity of the underlying security
        Returns:
        the position
      • getQuantity

        public double getQuantity()
        Description copied from interface: Position
        Gets the net quantity of the security.

        This returns the net quantity of the underlying security. The result is positive if the net position is long and negative if the net position is short.

        Specified by:
        getQuantity in interface Position
        Specified by:
        getQuantity in interface SecurityQuantity
        Returns:
        the net quantity of the underlying security
      • resolve

        public ResolvedDsfTrade resolve​(ReferenceData refData)
        Description copied from interface: Resolvable
        Resolves this object using the specified reference data.

        This converts the object implementing this interface to the equivalent resolved form. All ReferenceDataId identifiers in this instance will be resolved. The resolved form will typically be a type that is optimized for pricing.

        Resolved objects may be bound to data that changes over time, such as holiday calendars. If the data changes, such as the addition of a new holiday, the resolved form will not be updated. Care must be taken when placing the resolved form in a cache or persistence layer.

        Specified by:
        resolve in interface Resolvable<ResolvedDsfTrade>
        Parameters:
        refData - the reference data to use when resolving
        Returns:
        the resolved instance
      • meta

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

        public static DsfPosition.Builder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • metaBean

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

        public PositionInfo getInfo()
        Gets the additional position information, defaulted to an empty instance.

        This allows additional information to be attached to the position.

        Specified by:
        getInfo in interface PortfolioItem
        Specified by:
        getInfo in interface Position
        Returns:
        the value of the property, not null
      • getProduct

        public Dsf getProduct()
        Gets the DSF that was traded.

        The product captures the contracted financial details.

        Specified by:
        getProduct in interface SecuritizedProductPortfolioItem<Dsf>
        Returns:
        the value of the property, not null
      • getLongQuantity

        public double getLongQuantity()
        Gets the long quantity of the security.

        This is the quantity of the underlying security that is held. The quantity cannot be negative, as that would imply short selling.

        Returns:
        the value of the property
      • getShortQuantity

        public double getShortQuantity()
        Gets the short quantity of the security.

        This is the quantity of the underlying security that has been short sold. The quantity cannot be negative, as that would imply the position is long.

        Returns:
        the value of the property
      • toBuilder

        public DsfPosition.Builder toBuilder()
        Returns a builder that allows this bean to be mutated.
        Returns:
        the mutable builder, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object