Class EtdFuturePosition

    • Method Detail

      • ofNet

        public static EtdFuturePosition ofNet​(EtdFutureSecurity security,
                                              double netQuantity)
        Obtains an instance from the security 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:
        security - the underlying security
        netQuantity - the net quantity of the underlying security
        Returns:
        the position
      • ofNet

        public static EtdFuturePosition ofNet​(PositionInfo positionInfo,
                                              EtdFutureSecurity security,
                                              double netQuantity)
        Obtains an instance from position information, security 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
        security - the underlying security
        netQuantity - the net quantity of the underlying security
        Returns:
        the position
      • ofLongShort

        public static EtdFuturePosition ofLongShort​(EtdFutureSecurity security,
                                                    double longQuantity,
                                                    double shortQuantity)
        Obtains an instance from the security, 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:
        security - the underlying security
        longQuantity - the long quantity of the underlying security
        shortQuantity - the short quantity of the underlying security
        Returns:
        the position
      • ofLongShort

        public static EtdFuturePosition ofLongShort​(PositionInfo positionInfo,
                                                    EtdFutureSecurity security,
                                                    double longQuantity,
                                                    double shortQuantity)
        Obtains an instance from position information, security, 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
        security - the underlying security
        longQuantity - the long quantity of the underlying security
        shortQuantity - the short quantity of the underlying security
        Returns:
        the position
      • getQuantity

        public double getQuantity()
        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.

        This is calculated by subtracting the short quantity from the long quantity.

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

        public SecuritizedProductPosition<?> resolveTarget​(ReferenceData refData)
        Description copied from interface: ResolvableSecurityPosition
        Resolves the security identifier using the specified reference data.

        This takes the security identifier of this position, looks it up in reference data, and returns the equivalent position with full security information. If the security has underlying securities, they will also have been resolved in the result.

        The resulting position is bound to data from reference data. If the data changes, the resulting position form will not be updated. Care must be taken when placing the resolved form in a cache or persistence layer.

        Specified by:
        resolveTarget in interface ResolvableCalculationTarget
        Specified by:
        resolveTarget in interface ResolvableSecurityPosition
        Parameters:
        refData - the reference data to use when resolving
        Returns:
        the resolved position
      • meta

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

        public static EtdFuturePosition.Builder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • 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
      • 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.

        Specified by:
        getLongQuantity in interface EtdPosition
        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.

        Specified by:
        getShortQuantity in interface EtdPosition
        Returns:
        the value of the property
      • toBuilder

        public EtdFuturePosition.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