public final class EtdOptionPosition extends Object implements EtdPosition, SecuritizedProductPosition<EtdOptionSecurity>, ResolvableSecurityPosition, org.joda.beans.ImmutableBean, Serializable
This represents a position in a option, defined by long and short quantity. The option security is embedded directly, however the underlying product model is not available.
The net quantity of the position is stored using two fields - longQuantity and shortQuantity.
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 via getQuantity().
| Modifier and Type | Class and Description |
|---|---|
static class |
EtdOptionPosition.Builder
The bean-builder for
EtdOptionPosition. |
static class |
EtdOptionPosition.Meta
The meta-bean for
EtdOptionPosition. |
| Modifier and Type | Method and Description |
|---|---|
static EtdOptionPosition.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.
|
EtdOptionSecurity |
getProduct()
Gets the product of the security that was traded.
|
double |
getQuantity()
Gets the net quantity of the security.
|
EtdOptionSecurity |
getSecurity()
Gets the underlying security.
|
SecurityId |
getSecurityId()
Gets the security identifier.
|
double |
getShortQuantity()
Gets the short quantity of the security.
|
int |
hashCode() |
static EtdOptionPosition.Meta |
meta()
The meta-bean for
EtdOptionPosition. |
EtdOptionPosition.Meta |
metaBean() |
static EtdOptionPosition |
ofLongShort(EtdOptionSecurity security,
double longQuantity,
double shortQuantity)
Obtains an instance from the security, long quantity and short quantity.
|
static EtdOptionPosition |
ofLongShort(PositionInfo positionInfo,
EtdOptionSecurity security,
double longQuantity,
double shortQuantity)
Obtains an instance from position information, security, long quantity and short quantity.
|
static EtdOptionPosition |
ofNet(EtdOptionSecurity security,
double netQuantity)
Obtains an instance from the security and net quantity.
|
static EtdOptionPosition |
ofNet(PositionInfo positionInfo,
EtdOptionSecurity 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.
|
EtdOptionPosition.Builder |
toBuilder()
Returns a builder that allows this bean to be mutated.
|
String |
toString() |
EtdOptionPosition |
withInfo(PortfolioItemInfo info)
Returns an instance with the specified info.
|
EtdOptionPosition |
withQuantities(double longQuantity,
double shortQuantity)
Returns an instance with the specified quantities.
|
EtdOptionPosition |
withQuantity(double quantity)
Returns an instance with the specified net quantity.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetTypegetIdpublic static EtdOptionPosition ofNet(EtdOptionSecurity security, double netQuantity)
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.
security - the underlying securitynetQuantity - the net quantity of the underlying securitypublic static EtdOptionPosition ofNet(PositionInfo positionInfo, EtdOptionSecurity security, double netQuantity)
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.
positionInfo - the position informationsecurity - the underlying securitynetQuantity - the net quantity of the underlying securitypublic static EtdOptionPosition ofLongShort(EtdOptionSecurity security, double longQuantity, double shortQuantity)
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.
security - the underlying securitylongQuantity - the long quantity of the underlying securityshortQuantity - the short quantity of the underlying securitypublic static EtdOptionPosition ofLongShort(PositionInfo positionInfo, EtdOptionSecurity security, double longQuantity, double shortQuantity)
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.
positionInfo - the position informationsecurity - the underlying securitylongQuantity - the long quantity of the underlying securityshortQuantity - the short quantity of the underlying securitypublic EtdOptionSecurity getProduct()
SecuritizedProductPortfolioItemgetProduct in interface SecuritizedProductPortfolioItem<EtdOptionSecurity>public EtdOptionPosition withInfo(PortfolioItemInfo info)
EtdPositionwithInfo in interface EtdPositionwithInfo in interface PortfolioItemwithInfo in interface PositionwithInfo in interface ResolvableSecurityPositionwithInfo in interface SecuritizedProductPosition<EtdOptionSecurity>info - the new infopublic EtdOptionPosition withQuantity(double quantity)
EtdPositionwithQuantity in interface EtdPositionwithQuantity in interface PositionwithQuantity in interface ResolvableSecurityPositionwithQuantity in interface SecuritizedProductPortfolioItem<EtdOptionSecurity>withQuantity in interface SecuritizedProductPosition<EtdOptionSecurity>quantity - the new net quantitypublic EtdOptionPosition withQuantities(double longQuantity, double shortQuantity)
EtdPositionwithQuantities in interface EtdPositionlongQuantity - the new long quantityshortQuantity - the new short quantitypublic PortfolioItemSummary summarize()
PortfolioItemThis provides a summary, including a human readable description.
summarize in interface PortfolioItemsummarize in interface Positionpublic double getQuantity()
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.
getQuantity in interface EtdPositiongetQuantity in interface PositiongetQuantity in interface SecurityQuantitypublic Currency getCurrency()
EtdPositionThis is the currency of the security.
getCurrency in interface EtdPositiongetCurrency in interface SecuritizedProductPortfolioItem<EtdOptionSecurity>public SecurityId getSecurityId()
EtdPositionThis identifier uniquely identifies the security within the system.
getSecurityId in interface EtdPositiongetSecurityId in interface PositiongetSecurityId in interface SecuritizedProductPortfolioItem<EtdOptionSecurity>getSecurityId in interface SecuritizedProductPosition<EtdOptionSecurity>getSecurityId in interface SecurityQuantitypublic SecuritizedProductPosition<?> resolveTarget(ReferenceData refData)
ResolvableSecurityPositionThis 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.
resolveTarget in interface ResolvableCalculationTargetresolveTarget in interface ResolvableSecurityPositionrefData - the reference data to use when resolvingpublic static EtdOptionPosition.Meta meta()
EtdOptionPosition.public static EtdOptionPosition.Builder builder()
public EtdOptionPosition.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic PositionInfo getInfo()
This allows additional information to be attached to the position.
getInfo in interface PortfolioItemgetInfo in interface Positionpublic EtdOptionSecurity getSecurity()
getSecurity in interface EtdPositionpublic double getLongQuantity()
This is the quantity of the underlying security that is held. The quantity cannot be negative, as that would imply short selling.
getLongQuantity in interface EtdPositionpublic double getShortQuantity()
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.
getShortQuantity in interface EtdPositionpublic EtdOptionPosition.Builder toBuilder()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.