Class EtdContractSpec

  • All Implemented Interfaces:
    Attributes, java.io.Serializable, Bean, ImmutableBean

    public final class EtdContractSpec
    extends java.lang.Object
    implements Attributes, ImmutableBean, java.io.Serializable
    The contract specification defining an Exchange Traded Derivative (ETD) product.

    This can represent a future or an option. Instances of EtdOptionSecurity or EtdFutureSecurity can be created using the createFuture and createOption methods and providing the information required to fully define the contract such as the expiry, strike price and put / call.

    See Also:
    Serialized Form
    • Method Detail

      • builder

        public static EtdContractSpecBuilder builder()
        Returns a builder for building instances of EtdContractSpec.

        The builder will create an identifier using EtdIdUtils if it is not set.

        Returns:
        a builder for building instances of EtdContractSpec
      • findAttribute

        public <T> java.util.Optional<T> findAttribute​(AttributeType<T> type)
        Finds the attribute associated with the specified type.

        This method obtains the specified attribute. This allows an attribute about a security to be obtained if available.

        If the attribute is not found, optional empty is returned.

        Specified by:
        findAttribute in interface Attributes
        Type Parameters:
        T - the type of the result
        Parameters:
        type - the type to find
        Returns:
        the attribute value
      • withAttribute

        public <T> EtdContractSpec withAttribute​(AttributeType<T> type,
                                                 T value)
        Description copied from interface: Attributes
        Returns a copy of this instance with the attribute added.

        This returns a new instance with the specified attribute added. The attribute is added using Map.put(type, value) semantics.

        Specified by:
        withAttribute in interface Attributes
        Type Parameters:
        T - the type of the attribute value
        Parameters:
        type - the type providing meaning to the value
        value - the value
        Returns:
        a new instance based on this one with the attribute added
      • createFuture

        public EtdFutureSecurity createFuture​(java.time.YearMonth expiryMonth,
                                              EtdVariant variant)
        Creates a future security based on this contract specification.

        The security identifier will be automatically created using EtdIdUtils. The type must be EtdType.FUTURE otherwise an exception will be thrown.

        Parameters:
        expiryMonth - the expiry month of the future
        variant - the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex'
        Returns:
        a future security based on this contract specification
        Throws:
        java.lang.IllegalStateException - if the product type of the contract specification is not FUTURE
      • createOption

        public EtdOptionSecurity createOption​(java.time.YearMonth expiryMonth,
                                              EtdVariant variant,
                                              int version,
                                              PutCall putCall,
                                              double strikePrice)
        Creates an option security based on this contract specification.

        The security identifier will be automatically created using EtdIdUtils. The type must be EtdType.OPTION otherwise an exception will be thrown.

        Parameters:
        expiryMonth - the expiry month of the option
        variant - the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex'
        version - the non-negative version, zero by default
        putCall - whether the option is a put or call
        strikePrice - the strike price of the option
        Returns:
        an option security based on this contract specification
        Throws:
        java.lang.IllegalStateException - if the product type of the contract specification is not OPTION
      • createOption

        public EtdOptionSecurity createOption​(java.time.YearMonth expiryMonth,
                                              EtdVariant variant,
                                              int version,
                                              PutCall putCall,
                                              double strikePrice,
                                              java.time.YearMonth underlyingExpiryMonth)
        Creates an option security based on this contract specification.

        The security identifier will be automatically created using EtdIdUtils. The type must be EtdType.OPTION otherwise an exception will be thrown.

        Parameters:
        expiryMonth - the expiry month of the option
        variant - the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex'
        version - the non-negative version, zero by default
        putCall - whether the option is a put or call
        strikePrice - the strike price of the option
        underlyingExpiryMonth - the expiry of the underlying instrument, such as a future
        Returns:
        an option security based on this contract specification
        Throws:
        java.lang.IllegalStateException - if the product type of the contract specification is not OPTION
      • meta

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

        public EtdContractSpecId getId()
        Gets the ID of this contract specification.

        When building, this will be defaulted using EtdIdUtils.

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

        public EtdType getType()
        Gets the type of the contract - future or option.
        Returns:
        the value of the property, not null
      • getExchangeId

        public ExchangeId getExchangeId()
        Gets the ID of the exchange where the instruments derived from the product are traded.
        Returns:
        the value of the property, not null
      • getContractCode

        public EtdContractCode getContractCode()
        Gets the code supplied by the exchange for use in clearing and margining, such as in SPAN.
        Returns:
        the value of the property, not null
      • getDescription

        public java.lang.String getDescription()
        Gets the human readable description of the product.
        Returns:
        the value of the property, not empty
      • getPriceInfo

        public SecurityPriceInfo getPriceInfo()
        Gets the information about the security price. This includes details of the currency, tick size, tick value, contract size.
        Returns:
        the value of the property, not null
      • getAttributes

        public com.google.common.collect.ImmutableMap<AttributeType<?>,​java.lang.Object> getAttributes()
        Gets the attributes.

        Attributes provide the ability to associate arbitrary information with a security contract specification in a key-value map.

        Returns:
        the value of the property, 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