public final class GenericSecurityPosition extends Object implements SecuritizedProductPosition<GenericSecurity>, org.joda.beans.ImmutableBean, Serializable
This represents a position in a security, defined by long and short quantity. The security is embedded directly, however the underlying product model is not available. The security may be of any kind, including equities, bonds and exchange traded derivatives (ETD).
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 |
GenericSecurityPosition.Builder
The bean-builder for
GenericSecurityPosition. |
static class |
GenericSecurityPosition.Meta
The meta-bean for
GenericSecurityPosition. |
| Modifier and Type | Method and Description |
|---|---|
static GenericSecurityPosition.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.
|
GenericSecurity |
getProduct()
Gets the product of the security that was traded.
|
double |
getQuantity()
Gets the net quantity of the security.
|
GenericSecurity |
getSecurity()
Gets the underlying security.
|
SecurityId |
getSecurityId()
Gets the identifier of the underlying security.
|
double |
getShortQuantity()
Gets the short quantity of the security.
|
int |
hashCode() |
static GenericSecurityPosition.Meta |
meta()
The meta-bean for
GenericSecurityPosition. |
GenericSecurityPosition.Meta |
metaBean() |
static GenericSecurityPosition |
ofLongShort(GenericSecurity security,
double longQuantity,
double shortQuantity)
Obtains an instance from the security, long quantity and short quantity.
|
static GenericSecurityPosition |
ofLongShort(PositionInfo positionInfo,
GenericSecurity security,
double longQuantity,
double shortQuantity)
Obtains an instance from position information, security, long quantity and short quantity.
|
static GenericSecurityPosition |
ofNet(GenericSecurity security,
double netQuantity)
Obtains an instance from the security and net quantity.
|
static GenericSecurityPosition |
ofNet(PositionInfo positionInfo,
GenericSecurity security,
double netQuantity)
Obtains an instance from position information, security and net quantity.
|
PortfolioItemSummary |
summarize()
Summarizes the portfolio item.
|
GenericSecurityPosition.Builder |
toBuilder()
Returns a builder that allows this bean to be mutated.
|
String |
toString() |
GenericSecurityPosition |
withInfo(PortfolioItemInfo info)
Returns an instance with the specified info.
|
GenericSecurityPosition |
withQuantity(double quantity)
Returns an instance with the specified quantity.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetIdpublic static GenericSecurityPosition ofNet(GenericSecurity 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 GenericSecurityPosition ofNet(PositionInfo positionInfo, GenericSecurity 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 GenericSecurityPosition ofLongShort(GenericSecurity 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 GenericSecurityPosition ofLongShort(PositionInfo positionInfo, GenericSecurity 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 SecurityId getSecurityId()
PositionThis identifier uniquely identifies the security within the system.
getSecurityId in interface PositiongetSecurityId in interface SecuritizedProductPortfolioItem<GenericSecurity>getSecurityId in interface SecuritizedProductPosition<GenericSecurity>getSecurityId in interface SecurityQuantitypublic GenericSecurity getProduct()
SecuritizedProductPortfolioItemgetProduct in interface SecuritizedProductPortfolioItem<GenericSecurity>public Currency getCurrency()
SecuritizedProductPortfolioItemThis is typically the same as the currency of the product.
getCurrency in interface SecuritizedProductPortfolioItem<GenericSecurity>public double getQuantity()
PositionThis 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.
getQuantity in interface PositiongetQuantity in interface SecurityQuantitypublic GenericSecurityPosition withInfo(PortfolioItemInfo info)
SecuritizedProductPositionwithInfo in interface PortfolioItemwithInfo in interface PositionwithInfo in interface SecuritizedProductPosition<GenericSecurity>info - the new infopublic GenericSecurityPosition withQuantity(double quantity)
SecuritizedProductPositionwithQuantity in interface PositionwithQuantity in interface SecuritizedProductPortfolioItem<GenericSecurity>withQuantity in interface SecuritizedProductPosition<GenericSecurity>quantity - the new quantitypublic PortfolioItemSummary summarize()
PortfolioItemThis provides a summary, including a human readable description.
summarize in interface PortfolioItemsummarize in interface Positionpublic static GenericSecurityPosition.Meta meta()
GenericSecurityPosition.public static GenericSecurityPosition.Builder builder()
public GenericSecurityPosition.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 GenericSecurity getSecurity()
public double getLongQuantity()
This is the quantity of the underlying security that is held. The quantity cannot be negative, as that would imply short selling.
public 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.
public GenericSecurityPosition.Builder toBuilder()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.