Class EtdContractSpec

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

    public final class EtdContractSpec
    extends Object
    implements Attributes, Described, org.joda.beans.ImmutableBean, 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> Optional<T> findAttribute​(AttributeType<T> type)
        Description copied from interface: Attributes
        Finds the attribute associated with the specified type.

        This method obtains the specified attribute. This allows an attribute 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
      • withAttributes

        public EtdContractSpec withAttributes​(Attributes other)
        Description copied from interface: Attributes
        Returns a copy of this instance with the attributes added.

        This returns a new instance with the specified attributes added. The attributes are added using Map.putAll(type, value) semantics.

        Specified by:
        withAttributes in interface Attributes
        Parameters:
        other - the other instance to copy from
        Returns:
        an instance based on this one with the attributes from the other instance
      • createFuture

        public EtdFutureSecurity createFuture​(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:
        IllegalStateException - if the product type of the contract specification is not FUTURE
      • createOption

        public EtdOptionSecurity createOption​(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:
        IllegalStateException - if the product type of the contract specification is not OPTION
      • createOption

        public EtdOptionSecurity createOption​(YearMonth expiryMonth,
                                              EtdVariant variant,
                                              int version,
                                              PutCall putCall,
                                              double strikePrice,
                                              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:
        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
      • metaBean

        public EtdContractSpec.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • 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 String getDescription()
        Gets the human readable description of the product.
        Specified by:
        getDescription in interface Described
        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 ImmutableMap<AttributeType<?>,​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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object