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,BondFutureOptionSecurityorIborFutureSecurity. 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 classGenericSecurity.MetaThe meta-bean forGenericSecurity.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GenericSecurityPositioncreatePosition(PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData)Creates a position based on this security from a long and short quantity.GenericSecurityPositioncreatePosition(PositionInfo tradeInfo, double quantity, ReferenceData refData)Creates a position based on this security from a net quantity.GenericSecuritycreateProduct(ReferenceData refData)Creates the associated product, which simply returnsthis.GenericSecurityTradecreateTrade(TradeInfo info, double quantity, double tradePrice, ReferenceData refData)Creates a trade based on this security.booleanequals(Object obj)CurrencygetCurrency()Gets the currency that the security is traded in.SecurityInfogetInfo()Gets the standard security information.SecurityIdgetSecurityId()Gets the security identifier.ImmutableSet<SecurityId>getUnderlyingIds()Gets the set of underlying security identifiers.inthashCode()static GenericSecurity.Metameta()The meta-bean forGenericSecurity.GenericSecurity.MetametaBean()static GenericSecurityof(SecurityInfo securityInfo)Obtains an instance from security information, tick size and tick value.StringtoString()GenericSecuritywithInfo(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:SecurityGets the security identifier.This identifier uniquely identifies the security within the system.
- Specified by:
getSecurityIdin interfaceSecuritizedProduct- Specified by:
getSecurityIdin interfaceSecurity- Returns:
- the security identifier
-
getCurrency
public Currency getCurrency()
Description copied from interface:SecurityGets the currency that the security is traded in.- Specified by:
getCurrencyin interfaceSecuritizedProduct- Specified by:
getCurrencyin interfaceSecurity- Returns:
- the trading currency
-
getUnderlyingIds
public ImmutableSet<SecurityId> getUnderlyingIds()
Description copied from interface:SecurityGets 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:
getUnderlyingIdsin interfaceSecurity- Returns:
- the underlying security identifiers
-
withInfo
public GenericSecurity withInfo(SecurityInfo info)
Description copied from interface:SecurityReturns 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, theGenericSecurityis the product.- Specified by:
createProductin 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:SecurityCreates a trade based on this security.This creates a trade of a suitable type for this security.
- Specified by:
createTradein 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:SecurityCreates a position based on this security from a net quantity.This creates a position of a suitable type for this security.
- Specified by:
createPositionin 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:SecurityCreates 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:
createPositionin 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:
metaBeanin interfaceorg.joda.beans.Bean
-
getInfo
public SecurityInfo getInfo()
Gets the standard security information.This includes the security identifier.
-
-