Class EtdContractSpec
- java.lang.Object
-
- com.opengamma.strata.product.etd.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
orEtdFutureSecurity
can be created using thecreateFuture
andcreateOption
methods and providing the information required to fully define the contract such as the expiry, strike price and put / call.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EtdContractSpec.Meta
The meta-bean forEtdContractSpec
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EtdContractSpecBuilder
builder()
Returns a builder for building instances ofEtdContractSpec
.EtdFutureSecurity
createFuture(YearMonth expiryMonth, EtdVariant variant)
Creates a future security based on this contract specification.EtdOptionSecurity
createOption(YearMonth expiryMonth, EtdVariant variant, int version, PutCall putCall, double strikePrice)
Creates an option security based on this contract specification.EtdOptionSecurity
createOption(YearMonth expiryMonth, EtdVariant variant, int version, PutCall putCall, double strikePrice, YearMonth underlyingExpiryMonth)
Creates an option security based on this contract specification.boolean
equals(Object obj)
<T> Optional<T>
findAttribute(AttributeType<T> type)
Finds the attribute associated with the specified type.ImmutableMap<AttributeType<?>,Object>
getAttributes()
Gets the attributes.ImmutableSet<AttributeType<?>>
getAttributeTypes()
Gets the attribute types that are available.EtdContractCode
getContractCode()
Gets the code supplied by the exchange for use in clearing and margining, such as in SPAN.String
getDescription()
Gets the human readable description of the product.ExchangeId
getExchangeId()
Gets the ID of the exchange where the instruments derived from the product are traded.EtdContractSpecId
getId()
Gets the ID of this contract specification.SecurityPriceInfo
getPriceInfo()
Gets the information about the security price.EtdType
getType()
Gets the type of the contract - future or option.int
hashCode()
static EtdContractSpec.Meta
meta()
The meta-bean forEtdContractSpec
.EtdContractSpec.Meta
metaBean()
String
toString()
<T> EtdContractSpec
withAttribute(AttributeType<T> type, T value)
Returns a copy of this instance with the attribute added.EtdContractSpec
withAttributes(Attributes other)
Returns a copy of this instance with the attributes added.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.product.Attributes
containsAttribute, containsAttribute, getAttribute
-
-
-
-
Method Detail
-
builder
public static EtdContractSpecBuilder builder()
Returns a builder for building instances ofEtdContractSpec
.The builder will create an identifier using
EtdIdUtils
if it is not set.- Returns:
- a builder for building instances of
EtdContractSpec
-
getAttributeTypes
public ImmutableSet<AttributeType<?>> getAttributeTypes()
Description copied from interface:Attributes
Gets the attribute types that are available.See
AttributeType.captureWildcard()
for a way to capture the wildcard type.The default implementation returns an empty set (backwards compatibility prevents an abstract method for now).
- Specified by:
getAttributeTypes
in interfaceAttributes
- Returns:
- the attribute types
-
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 interfaceAttributes
- 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 interfaceAttributes
- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type providing meaning to the valuevalue
- 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 interfaceAttributes
- 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
. Thetype
must beEtdType.FUTURE
otherwise an exception will be thrown.- Parameters:
expiryMonth
- the expiry month of the futurevariant
- 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 notFUTURE
-
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
. Thetype
must beEtdType.OPTION
otherwise an exception will be thrown.- Parameters:
expiryMonth
- the expiry month of the optionvariant
- the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex'version
- the non-negative version, zero by defaultputCall
- whether the option is a put or callstrikePrice
- 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 notOPTION
-
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
. Thetype
must beEtdType.OPTION
otherwise an exception will be thrown.- Parameters:
expiryMonth
- the expiry month of the optionvariant
- the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex'version
- the non-negative version, zero by defaultputCall
- whether the option is a put or callstrikePrice
- the strike price of the optionunderlyingExpiryMonth
- 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 notOPTION
-
meta
public static EtdContractSpec.Meta meta()
The meta-bean forEtdContractSpec
.- Returns:
- the meta-bean, not null
-
metaBean
public EtdContractSpec.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.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 interfaceDescribed
- 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
-
-