Class GenericSecurity
- java.lang.Object
-
- com.opengamma.strata.product.GenericSecurity
-
- All Implemented Interfaces:
Product
,SecuritizedProduct
,Security
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class GenericSecurity extends Object implements Security, SecuritizedProduct, org.joda.beans.ImmutableBean, Serializable
A generic security, defined in terms of the value of each tick.In most cases, applications will choose to represent information about securities using the relevant type, such as
FixedCouponBondSecurity
,BondFutureOptionSecurity
orIborFutureSecurity
. Sometimes however, it can be useful to store minimal information about the security, expressing just the tick size and tick value.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GenericSecurity.Meta
The meta-bean forGenericSecurity
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GenericSecurityPosition
createPosition(PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData)
Creates a position based on this security from a long and short quantity.GenericSecurityPosition
createPosition(PositionInfo tradeInfo, double quantity, ReferenceData refData)
Creates a position based on this security from a net quantity.GenericSecurity
createProduct(ReferenceData refData)
Creates the associated product, which simply returnsthis
.GenericSecurityTrade
createTrade(TradeInfo info, double quantity, double tradePrice, ReferenceData refData)
Creates a trade based on this security.boolean
equals(Object obj)
Currency
getCurrency()
Gets the currency that the security is traded in.SecurityInfo
getInfo()
Gets the standard security information.SecurityId
getSecurityId()
Gets the security identifier.ImmutableSet<SecurityId>
getUnderlyingIds()
Gets the set of underlying security identifiers.int
hashCode()
static GenericSecurity.Meta
meta()
The meta-bean forGenericSecurity
.GenericSecurity.Meta
metaBean()
static GenericSecurity
of(SecurityInfo securityInfo)
Obtains an instance from security information, tick size and tick value.String
toString()
GenericSecurity
withInfo(SecurityInfo info)
Returns an instance with the specified info.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.product.Product
allPaymentCurrencies, isCrossCurrency
-
Methods inherited from interface com.opengamma.strata.product.SecuritizedProduct
allCurrencies
-
-
-
-
Method Detail
-
of
public static GenericSecurity of(SecurityInfo securityInfo)
Obtains an instance from security information, tick size and tick value.- Parameters:
securityInfo
- the security information- Returns:
- the security
-
getSecurityId
public SecurityId getSecurityId()
Description copied from interface:Security
Gets the security identifier.This identifier uniquely identifies the security within the system.
- Specified by:
getSecurityId
in interfaceSecuritizedProduct
- Specified by:
getSecurityId
in interfaceSecurity
- Returns:
- the security identifier
-
getCurrency
public Currency getCurrency()
Description copied from interface:Security
Gets the currency that the security is traded in.- Specified by:
getCurrency
in interfaceSecuritizedProduct
- Specified by:
getCurrency
in interfaceSecurity
- Returns:
- the trading currency
-
getUnderlyingIds
public ImmutableSet<SecurityId> getUnderlyingIds()
Description copied from interface:Security
Gets the set of underlying security identifiers.The set must contain all the security identifiers that this security directly refers to. For example, a bond future will return the identifiers of the underlying basket of bonds, but a bond future option will only return the identifier of the underlying future, not the basket.
- Specified by:
getUnderlyingIds
in interfaceSecurity
- Returns:
- the underlying security identifiers
-
withInfo
public GenericSecurity withInfo(SecurityInfo info)
Description copied from interface:Security
Returns an instance with the specified info.
-
createProduct
public GenericSecurity createProduct(ReferenceData refData)
Creates the associated product, which simply returnsthis
.The product associated with a security normally returns the financial model used for pricing. In the case of a
GenericSecurity
, no underlying financial model is available. As such, theGenericSecurity
is the product.- Specified by:
createProduct
in interfaceSecurity
- Parameters:
refData
- the reference data to use- Returns:
- this security
-
createTrade
public GenericSecurityTrade createTrade(TradeInfo info, double quantity, double tradePrice, ReferenceData refData)
Description copied from interface:Security
Creates a trade based on this security.This creates a trade of a suitable type for this security.
- Specified by:
createTrade
in interfaceSecurity
- Parameters:
info
- the trade informationquantity
- the number of contracts in the tradetradePrice
- the price agreed when the trade occurredrefData
- the reference data used to find underlying securities- Returns:
- the trade
-
createPosition
public GenericSecurityPosition createPosition(PositionInfo tradeInfo, double quantity, ReferenceData refData)
Description copied from interface:Security
Creates a position based on this security from a net quantity.This creates a position of a suitable type for this security.
- Specified by:
createPosition
in interfaceSecurity
- Parameters:
tradeInfo
- the position informationquantity
- the number of contracts in the positionrefData
- the reference data used to find underlying securities- Returns:
- the position
-
createPosition
public GenericSecurityPosition createPosition(PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData)
Description copied from interface:Security
Creates a position based on this security from a long and short quantity.This creates a position of a suitable type for this security.
The long quantity and short quantity must be zero or positive, not negative.
- Specified by:
createPosition
in interfaceSecurity
- Parameters:
positionInfo
- the position informationlongQuantity
- the long quantity in the positionshortQuantity
- the short quantity in the positionrefData
- the reference data used to find underlying securities- Returns:
- the position
-
meta
public static GenericSecurity.Meta meta()
The meta-bean forGenericSecurity
.- Returns:
- the meta-bean, not null
-
metaBean
public GenericSecurity.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getInfo
public SecurityInfo getInfo()
Gets the standard security information.This includes the security identifier.
-
-