Class EtdFuturePosition
- java.lang.Object
-
- com.opengamma.strata.product.etd.EtdFuturePosition
-
- All Implemented Interfaces:
CalculationTarget
,ResolvableCalculationTarget
,EtdPosition
,PortfolioItem
,Position
,ResolvableSecurityPosition
,SecuritizedProductPortfolioItem<EtdFutureSecurity>
,SecuritizedProductPosition<EtdFutureSecurity>
,SecurityQuantity
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class EtdFuturePosition extends Object implements EtdPosition, SecuritizedProductPosition<EtdFutureSecurity>, ResolvableSecurityPosition, org.joda.beans.ImmutableBean, Serializable
A position in an ETD future, where the security is embedded ready for mark-to-market pricing.This represents a position in a future, defined by long and short quantity. The future security is embedded directly, however the underlying product model is not available.
The net quantity of the position is stored using two fields -
longQuantity
andshortQuantity
. 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 viagetQuantity()
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EtdFuturePosition.Builder
The bean-builder forEtdFuturePosition
.static class
EtdFuturePosition.Meta
The meta-bean forEtdFuturePosition
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EtdFuturePosition.Builder
builder()
Returns a builder used to create an instance of the bean.boolean
equals(Object obj)
Currency
getCurrency()
Gets the currency of the position.PositionInfo
getInfo()
Gets the additional position information, defaulted to an empty instance.double
getLongQuantity()
Gets the long quantity of the security.EtdFutureSecurity
getProduct()
Gets the product of the security that was traded.double
getQuantity()
Gets the net quantity of the security.EtdFutureSecurity
getSecurity()
Gets the underlying security.SecurityId
getSecurityId()
Gets the security identifier.double
getShortQuantity()
Gets the short quantity of the security.int
hashCode()
static EtdFuturePosition.Meta
meta()
The meta-bean forEtdFuturePosition
.EtdFuturePosition.Meta
metaBean()
static EtdFuturePosition
ofLongShort(EtdFutureSecurity security, double longQuantity, double shortQuantity)
Obtains an instance from the security, long quantity and short quantity.static EtdFuturePosition
ofLongShort(PositionInfo positionInfo, EtdFutureSecurity security, double longQuantity, double shortQuantity)
Obtains an instance from position information, security, long quantity and short quantity.static EtdFuturePosition
ofNet(EtdFutureSecurity security, double netQuantity)
Obtains an instance from the security and net quantity.static EtdFuturePosition
ofNet(PositionInfo positionInfo, EtdFutureSecurity security, double netQuantity)
Obtains an instance from position information, security and net quantity.SecuritizedProductPosition<?>
resolveTarget(ReferenceData refData)
Resolves the security identifier using the specified reference data.PortfolioItemSummary
summarize()
Summarizes the portfolio item.EtdFuturePosition.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
EtdFuturePosition
withInfo(PortfolioItemInfo info)
Returns an instance with the specified info.EtdFuturePosition
withQuantities(double longQuantity, double shortQuantity)
Returns an instance with the specified quantities.EtdFuturePosition
withQuantity(double quantity)
Returns an instance with the specified net quantity.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.product.etd.EtdPosition
getType
-
Methods inherited from interface com.opengamma.strata.product.PortfolioItem
getId
-
-
-
-
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 securitynetQuantity
- 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 informationsecurity
- the underlying securitynetQuantity
- 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 securitylongQuantity
- the long quantity of the underlying securityshortQuantity
- 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 informationsecurity
- the underlying securitylongQuantity
- the long quantity of the underlying securityshortQuantity
- the short quantity of the underlying security- Returns:
- the position
-
getProduct
public EtdFutureSecurity getProduct()
Description copied from interface:SecuritizedProductPortfolioItem
Gets the product of the security that was traded.- Specified by:
getProduct
in interfaceSecuritizedProductPortfolioItem<EtdFutureSecurity>
- Returns:
- the product
-
withInfo
public EtdFuturePosition withInfo(PortfolioItemInfo info)
Description copied from interface:EtdPosition
Returns an instance with the specified info.- Specified by:
withInfo
in interfaceEtdPosition
- Specified by:
withInfo
in interfacePortfolioItem
- Specified by:
withInfo
in interfacePosition
- Specified by:
withInfo
in interfaceResolvableSecurityPosition
- Specified by:
withInfo
in interfaceSecuritizedProductPosition<EtdFutureSecurity>
- Parameters:
info
- the new info- Returns:
- the instance with the specified info
-
withQuantity
public EtdFuturePosition withQuantity(double quantity)
Description copied from interface:EtdPosition
Returns an instance with the specified net quantity.- Specified by:
withQuantity
in interfaceEtdPosition
- Specified by:
withQuantity
in interfacePosition
- Specified by:
withQuantity
in interfaceResolvableSecurityPosition
- Specified by:
withQuantity
in interfaceSecuritizedProductPortfolioItem<EtdFutureSecurity>
- Specified by:
withQuantity
in interfaceSecuritizedProductPosition<EtdFutureSecurity>
- Parameters:
quantity
- the new net quantity- Returns:
- the instance with the specified net quantity
-
withQuantities
public EtdFuturePosition withQuantities(double longQuantity, double shortQuantity)
Description copied from interface:EtdPosition
Returns an instance with the specified quantities.- Specified by:
withQuantities
in interfaceEtdPosition
- Parameters:
longQuantity
- the new long quantityshortQuantity
- the new short quantity- Returns:
- the instance with the specified quantities
-
summarize
public PortfolioItemSummary summarize()
Description copied from interface:PortfolioItem
Summarizes the portfolio item.This provides a summary, including a human readable description.
- Specified by:
summarize
in interfacePortfolioItem
- Specified by:
summarize
in interfacePosition
- Returns:
- the summary of the item
-
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 interfaceEtdPosition
- Specified by:
getQuantity
in interfacePosition
- Specified by:
getQuantity
in interfaceSecurityQuantity
- Returns:
- the net quantity of the underlying security
-
getCurrency
public Currency getCurrency()
Description copied from interface:EtdPosition
Gets the currency of the position.This is the currency of the security.
- Specified by:
getCurrency
in interfaceEtdPosition
- Specified by:
getCurrency
in interfaceSecuritizedProductPortfolioItem<EtdFutureSecurity>
- Returns:
- the trading currency
-
getSecurityId
public SecurityId getSecurityId()
Description copied from interface:EtdPosition
Gets the security identifier.This identifier uniquely identifies the security within the system.
- Specified by:
getSecurityId
in interfaceEtdPosition
- Specified by:
getSecurityId
in interfacePosition
- Specified by:
getSecurityId
in interfaceSecuritizedProductPortfolioItem<EtdFutureSecurity>
- Specified by:
getSecurityId
in interfaceSecuritizedProductPosition<EtdFutureSecurity>
- Specified by:
getSecurityId
in interfaceSecurityQuantity
- Returns:
- the security identifier
-
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 interfaceResolvableCalculationTarget
- Specified by:
resolveTarget
in interfaceResolvableSecurityPosition
- Parameters:
refData
- the reference data to use when resolving- Returns:
- the resolved position
-
meta
public static EtdFuturePosition.Meta meta()
The meta-bean forEtdFuturePosition
.- 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
-
metaBean
public EtdFuturePosition.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.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 interfacePortfolioItem
- Specified by:
getInfo
in interfacePosition
- Returns:
- the value of the property, not null
-
getSecurity
public EtdFutureSecurity getSecurity()
Gets the underlying security.- Specified by:
getSecurity
in interfaceEtdPosition
- 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 interfaceEtdPosition
- 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 interfaceEtdPosition
- 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
-
-