public enum BuySell extends Enum<BuySell> implements NamedEnum
Specifies whether the financial instrument is buy-side or sell-side. For example, in a Forward Rate Agreement the buyer receives the floating rate of interest in exchange for a fixed rate, whereas the seller pays the floating rate. This flag is stored on the instrument to indicate whether it was bought or sold.
| Modifier and Type | Method and Description |
|---|---|
boolean |
isBuy()
Checks if the type is 'Buy'.
|
boolean |
isSell()
Checks if the type is 'Sell'.
|
BigMoney |
normalize(BigMoney amount)
Normalizes the specified
BigMoney amount using this buy/sell rule. |
CurrencyAmount |
normalize(CurrencyAmount amount)
Normalizes the specified amount using this buy/sell rule.
|
Decimal |
normalize(Decimal amount)
Normalizes the specified
Decimal amount using this buy/sell rule. |
double |
normalize(double amount)
Normalizes the specified notional amount using this buy/sell rule.
|
static BuySell |
of(String name)
Obtains an instance from the specified name.
|
static BuySell |
ofBuy(boolean isBuy)
Converts a boolean "is buy" flag to the enum value.
|
BuySell |
opposite()
Supplies the opposite of this value.
|
String |
toString()
Returns the formatted name of the type.
|
static BuySell |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static BuySell[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final BuySell BUY
public static final BuySell SELL
public static BuySell[] values()
for (BuySell c : BuySell.values()) System.out.println(c);
public static BuySell valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static BuySell of(String name)
Parsing handles the mixed case form produced by toString() and
the upper and lower case variants of the enum constant name.
name - the name to parseIllegalArgumentException - if the name is not knownpublic static BuySell ofBuy(boolean isBuy)
isBuy - the buy flag, true for buy, false for sellpublic double normalize(double amount)
This returns a positive signed amount if this is 'buy', and a negative signed amount if this is 'sell'. This effectively normalizes the input notional to the buy/sell sign conventions of this library. The negative form of zero will never be returned.
amount - the amount to adjustpublic Decimal normalize(Decimal amount)
Decimal amount using this buy/sell rule.
This returns a positive signed amount if this is 'buy', and a negative signed amount if this is 'sell'. This effectively normalizes the input amount to the buy/sell sign conventions of this library.
amount - the amount to adjustpublic CurrencyAmount normalize(CurrencyAmount amount)
This returns a positive signed amount if this is 'buy', and a negative signed amount if this is 'sell'. This effectively normalizes the input notional to the buy/sell sign conventions of this library. The negative form of zero will never be returned.
amount - the amount to adjustpublic BigMoney normalize(BigMoney amount)
BigMoney amount using this buy/sell rule.
This returns a positive signed amount if this is 'buy', and a negative signed amount if this is 'sell'. This effectively normalizes the input notional to the buy/sell sign conventions of this library.
amount - the amount to adjustpublic boolean isBuy()
public boolean isSell()
public BuySell opposite()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.