public final class SecurityPriceInfo extends Object implements org.joda.beans.ImmutableBean, Serializable
A value of a security is measured in terms of a price which is not typically a monetary amount. Instead the price is an arbitrary number that can be converted to a monetary amount. The price will move up and down in ticks. This class provides the size and monetary value of each tick, allowing changes in the price to be converted to a monetary amount.
Three properties define the necessary information: Tick size is the minimum movement in the price of the security (the tick). Tick value is the monetary value gained or lost when the price changes by one tick. Contract size is the quantity of the underlying present in each derivative contract, which acts as a multiplier.
For example, the price of an ICE Brent Crude future is based on the price of a barrel of crude oil in USD. The tick size of this contract is 0.01 (equivalent to 1 cent). The contract size is 1,000 barrels. Therefore the tick value is 0.01 * 1,000 = 10 USD.
| Modifier and Type | Class and Description |
|---|---|
static class |
SecurityPriceInfo.Meta
The meta-bean for
SecurityPriceInfo. |
| Modifier and Type | Method and Description |
|---|---|
CurrencyAmount |
calculateMonetaryAmount(double quantity,
double price)
Calculates the monetary value of the specified quantity and price.
|
double |
calculateMonetaryValue(double quantity,
double price)
Calculates the monetary value of the specified quantity and price.
|
boolean |
equals(Object obj) |
double |
getContractSize()
Gets the size of each contract.
|
Currency |
getCurrency()
Gets the currency that the security is traded in.
|
double |
getTickSize()
Gets the size of each tick.
|
CurrencyAmount |
getTickValue()
Gets the monetary value of one tick.
|
double |
getTradeUnitValue()
Returns the value of a single tradeable unit of the security.
|
int |
hashCode() |
static SecurityPriceInfo.Meta |
meta()
The meta-bean for
SecurityPriceInfo. |
SecurityPriceInfo.Meta |
metaBean() |
static SecurityPriceInfo |
of(Currency currency,
double tradeUnitValue)
Obtains an instance from the currency and the value of a single tradeable unit.
|
static SecurityPriceInfo |
of(double tickSize,
CurrencyAmount tickValue)
Obtains an instance from the tick size and tick value.
|
static SecurityPriceInfo |
of(double tickSize,
CurrencyAmount tickValue,
double contractSize)
Obtains an instance from the tick size, tick value and contract size.
|
static SecurityPriceInfo |
ofCurrencyMinorUnit(Currency currency)
Obtains an instance from the currency.
|
String |
toString() |
public static SecurityPriceInfo of(double tickSize, CurrencyAmount tickValue)
The contract size will be set to 1.
tickSize - the size of each tick, not negative or zerotickValue - the value of each tickpublic static SecurityPriceInfo of(double tickSize, CurrencyAmount tickValue, double contractSize)
tickSize - the size of each tick, not negative or zerotickValue - the value of each tickcontractSize - the contract sizepublic static SecurityPriceInfo of(Currency currency, double tradeUnitValue)
currency - the currency in which the security is tradedtradeUnitValue - the value of a single tradeable unit of the securitypublic static SecurityPriceInfo ofCurrencyMinorUnit(Currency currency)
This sets the tick size and tick value to the minor unit of the currency. For example, for USD this will set the tick size to 0.01 and the tick value to $0.01. This typically matches the conventions of equities and bonds.
currency - the currency to derive the price information frompublic Currency getCurrency()
The currency is derived from the tick value.
public CurrencyAmount calculateMonetaryAmount(double quantity, double price)
This calculates a monetary value using the stored price information. For equities, this is the premium that will be paid. For bonds, this will be the premium if the price specified is the dirty price. For margined ETDs, the profit or loss per day is the monetary difference between two calls to this method with the price on each day.
This returns calculateMonetaryValue(double, double) as a CurrencyAmount.
quantity - the quantity, such as the number of shares or number of future contractsprice - the price, typically from the marketpublic double calculateMonetaryValue(double quantity,
double price)
This calculates a monetary value using the stored price information. For equities, this is the premium that will be paid. For bonds, this will be the premium if the price specified is the dirty price. For margined ETDs, the profit or loss per day is the monetary difference between two calls to this method with the price on each day.
quantity - the quantity, such as the number of shares or number of future contractsprice - the price, typically from the marketpublic double getTradeUnitValue()
The monetary value of a position in a security is
tradeUnitValue * price * quantity
This value is normally derived from the tick size, tick value and contract size:
tradeUnitValue = tickValue * contractSize / tickSize
public static SecurityPriceInfo.Meta meta()
SecurityPriceInfo.public SecurityPriceInfo.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic double getTickSize()
Tick size is the minimum movement in the price of the security. For example, the price might move up or down in units of 0.01 It must be a positive decimal number.
public CurrencyAmount getTickValue()
Tick value is the monetary value of the minimum movement in the price of the security. When the price changes by one tick, this amount is gained or lost.
public double getContractSize()
Contract size is the quantity of the underlying present in each derivative contract. For example, an equity option typically consists of 100 shares.
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.