Package com.opengamma.strata.product
Class SecurityTrade
- java.lang.Object
-
- com.opengamma.strata.product.SecurityTrade
-
- All Implemented Interfaces:
CalculationTarget
,ResolvableCalculationTarget
,PortfolioItem
,ResolvableSecurityTrade
,SecurityQuantity
,SecurityQuantityTrade
,Trade
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class SecurityTrade extends Object implements ResolvableSecurityTrade, org.joda.beans.ImmutableBean, Serializable
A trade representing the purchase or sale of a security, where the security is referenced by identifier.This trade represents a trade in a security, defined by a quantity and price. The security is referenced using
SecurityId
. The identifier may be looked up inReferenceData
.The reference may be to any kind of security, including equities, bonds and exchange traded derivatives (ETD).
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SecurityTrade.Builder
The bean-builder forSecurityTrade
.static class
SecurityTrade.Meta
The meta-bean forSecurityTrade
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SecurityTrade.Builder
builder()
Returns a builder used to create an instance of the bean.boolean
equals(Object obj)
TradeInfo
getInfo()
Gets the additional trade information, defaulted to an empty instance.double
getPrice()
Gets the price agreed when the trade occurred.double
getQuantity()
Gets the quantity that was traded.SecurityId
getSecurityId()
Gets the identifier of the security that was traded.int
hashCode()
static SecurityTrade.Meta
meta()
The meta-bean forSecurityTrade
.SecurityTrade.Meta
metaBean()
static SecurityTrade
of(TradeInfo tradeInfo, SecurityId securityId, double quantity, double price)
Obtains an instance from trade information, identifier, quantity and price.PortfolioItemSummary
summarize()
Summarizes the portfolio item.SecurityTrade.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
SecurityTrade
withInfo(PortfolioItemInfo info)
Returns an instance with the specified info.SecurityTrade
withPrice(double price)
Returns an instance with the specified price.SecurityTrade
withQuantity(double quantity)
Returns an instance with the specified quantity.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.product.PortfolioItem
getId
-
Methods inherited from interface com.opengamma.strata.product.ResolvableSecurityTrade
resolveTarget
-
-
-
-
Method Detail
-
of
public static SecurityTrade of(TradeInfo tradeInfo, SecurityId securityId, double quantity, double price)
Obtains an instance from trade information, identifier, quantity and price.- Parameters:
tradeInfo
- the trade informationsecurityId
- the identifier of the underlying securityquantity
- the quantity that was tradedprice
- the price that was traded- Returns:
- the trade
-
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 interfaceTrade
- Returns:
- the summary of the item
-
withInfo
public SecurityTrade withInfo(PortfolioItemInfo info)
Description copied from interface:ResolvableSecurityTrade
Returns an instance with the specified info.- Specified by:
withInfo
in interfacePortfolioItem
- Specified by:
withInfo
in interfaceResolvableSecurityTrade
- Specified by:
withInfo
in interfaceSecurityQuantityTrade
- Specified by:
withInfo
in interfaceTrade
- Parameters:
info
- the new info- Returns:
- the instance with the specified info
-
withQuantity
public SecurityTrade withQuantity(double quantity)
Description copied from interface:ResolvableSecurityTrade
Returns an instance with the specified quantity.- Specified by:
withQuantity
in interfaceResolvableSecurityTrade
- Specified by:
withQuantity
in interfaceSecurityQuantityTrade
- Parameters:
quantity
- the new quantity- Returns:
- the instance with the specified quantity
-
withPrice
public SecurityTrade withPrice(double price)
Description copied from interface:ResolvableSecurityTrade
Returns an instance with the specified price.- Specified by:
withPrice
in interfaceResolvableSecurityTrade
- Specified by:
withPrice
in interfaceSecurityQuantityTrade
- Parameters:
price
- the new price- Returns:
- the instance with the specified price
-
meta
public static SecurityTrade.Meta meta()
The meta-bean forSecurityTrade
.- Returns:
- the meta-bean, not null
-
builder
public static SecurityTrade.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public SecurityTrade.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getInfo
public TradeInfo getInfo()
Gets the additional trade information, defaulted to an empty instance.This allows additional information to be attached to the trade.
- Specified by:
getInfo
in interfacePortfolioItem
- Specified by:
getInfo
in interfaceTrade
- Returns:
- the value of the property, not null
-
getSecurityId
public SecurityId getSecurityId()
Gets the identifier of the security that was traded.This identifier uniquely identifies the security within the system.
- Specified by:
getSecurityId
in interfaceSecurityQuantity
- Returns:
- the value of the property, not null
-
getQuantity
public double getQuantity()
Gets the quantity that was traded.This will be positive if buying and negative if selling.
- Specified by:
getQuantity
in interfaceSecurityQuantity
- Returns:
- the value of the property
-
getPrice
public double getPrice()
Gets the price agreed when the trade occurred.This is the price agreed when the trade occurred.
- Specified by:
getPrice
in interfaceSecurityQuantityTrade
- Returns:
- the value of the property
-
toBuilder
public SecurityTrade.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-