Package com.wombat.mamda.options
Class MamdaOptionChain
- java.lang.Object
-
- com.wombat.mamda.options.MamdaOptionChain
-
public class MamdaOptionChain extends java.lang.Object
MamdaOptionChain is a specialized class to represent market data option chains. The class has capabilities to store the current state of an entire option chain, or a subset of the chain.
-
-
Constructor Summary
Constructors Constructor Description MamdaOptionChain(java.lang.String symbol)
MamdaOptionChain Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addContract(java.lang.String contractSymbol, MamdaOptionContract contract)
Add an option contract.java.util.Iterator
callIterator()
Return an iterator over all call option contracts.void
dump()
Print the contents of the chain to standard out.MamdaOptionExpirationDateSet
getAllExpirations()
Return a set of MamdaOptionExpirationDateSet.double
getAtTheMoney(short compareType)
Get the price of the option underlying.MamdaOptionContract
getContract(java.lang.String contractSymbol)
Find an option contract by OPRA symbol.java.util.SortedSet
getExchanges()
Return the superset of regional exchange identifiers for any option in this chain.boolean
getIsPriceWithinPercentOfMoney(double price, double percentage, short compareType)
Return whether the price within a % of the money.java.util.SortedSet
getStrikePrices()
Return the superset of strike prices for this chain.java.util.SortedSet
getStrikesWithinPercent(double percentage, short compareType)
Determine the set of strike prices that are included in a given percentage range of the underlying price.java.util.SortedSet
getStrikesWithinRangeSize(int rangeLength, short compareType)
Determine the set of strike prices that are included in a given fixed size range of strikes surrounding the underlying price.java.lang.String
getSymbol()
Get the underlying symbol for the option chain.MamdaQuoteListener
getUnderlyingQuoteListener()
Make the underlying quote listener available externally.MamdaTradeListener
getUnderlyingTradeListener()
Make the underlying trade listener available externally.java.util.Iterator
putIterator()
Return an iterator over all put option contracts.void
removeContract(java.lang.String contractSymbol)
Remove an option contract.void
setSymbol(java.lang.String symbol)
Set the underlying symbol for the option chain.void
setUnderlyingQuoteListener(MamdaQuoteListener quoteListener)
Set the underlying quote listener information.void
setUnderlyingTradeListener(MamdaTradeListener tradeListener)
Set the underlying trade listener information.
-
-
-
Method Detail
-
setSymbol
public void setSymbol(java.lang.String symbol)
Set the underlying symbol for the option chain.- Parameters:
symbol
- The underlying symbol.
-
getSymbol
public java.lang.String getSymbol()
Get the underlying symbol for the option chain.- Returns:
- String The underlying symbol for the option chain.
-
setUnderlyingQuoteListener
public void setUnderlyingQuoteListener(MamdaQuoteListener quoteListener)
Set the underlying quote listener information. MamdaOptionChain does not use this class itself, but related classes might (e.g., MamdaOptionChainView).- Parameters:
quoteListener
- The quote listener for the chain.
-
setUnderlyingTradeListener
public void setUnderlyingTradeListener(MamdaTradeListener tradeListener)
Set the underlying trade listener information. MamdaOptionChain uses this class to implement the atTheMoney() method. Related classes might (e.g., MamdaOptionChainView) use it for other reasons.- Parameters:
tradeListener
- The trade listener for the chain.
-
getUnderlyingQuoteListener
public MamdaQuoteListener getUnderlyingQuoteListener()
Make the underlying quote listener available externally.- Returns:
- MamdaQuoteListener The quote listener for the chain.
-
getUnderlyingTradeListener
public MamdaTradeListener getUnderlyingTradeListener()
Make the underlying trade listener available externally.- Returns:
- MamdaTradeListener The trade listener for the chain.
-
getContract
public MamdaOptionContract getContract(java.lang.String contractSymbol)
Find an option contract by OPRA symbol.- Parameters:
contractSymbol
- The option symbol.- Returns:
- MamdaOptionContract The contract object representing the option.
-
getExchanges
public java.util.SortedSet getExchanges()
Return the superset of regional exchange identifiers for any option in this chain. Each element in the set is a String object.- Returns:
- SortedSet Set of regional exchange identifiers.
-
getStrikePrices
public java.util.SortedSet getStrikePrices()
Return the superset of strike prices for this chain. Each element in the set is a Double object.- Returns:
- SortedSet Set of strike prices for the chain.
-
addContract
public void addContract(java.lang.String contractSymbol, MamdaOptionContract contract)
Add an option contract. This method would not normally be invoked by a user application. Rather, MamdaOptionChainListener would be most likely to call this method.- Parameters:
contractSymbol
- The option instrument symbol.contract
- The Mamda option contract representation.
-
removeContract
public void removeContract(java.lang.String contractSymbol)
Remove an option contract. This method would not normally be invoked by a user application. Rather, MamdaOptionChainListener would be most likely to call this method.
-
getAtTheMoney
public double getAtTheMoney(short compareType)
Get the price of the option underlying. Determine the underlying price ("at the money"), based on the mode of calculation.- Parameters:
compareType
- The mode of calculation (MamdaOptionAtTheMoneyCompareType
)- Returns:
- double The price of the underlying.
- See Also:
MamdaOptionAtTheMoneyCompareType
-
getIsPriceWithinPercentOfMoney
public boolean getIsPriceWithinPercentOfMoney(double price, double percentage, short compareType)
Return whether the price within a % of the money. Determine whether some price (e.g. a strike price) is within a given percentage range of the underlying (at the money) price.- Parameters:
price
- The strike price to check.percentage
- What % to check the strike price against.compareType
- What price we are checking against (seeMamdaOptionAtTheMoneyCompareType
)- Returns:
- boolean Whether the proce is within % of the money.
- See Also:
MamdaOptionAtTheMoneyCompareType
-
getStrikesWithinPercent
public java.util.SortedSet getStrikesWithinPercent(double percentage, short compareType)
Determine the set of strike prices that are included in a given percentage range of the underlying price. If there are no strikes within the percentage range, then both strike prices are set to zero.- Parameters:
percentage
- The percentage range of the underlying price.compareType
- Which underlying price to compare to.- Returns:
- SortedSet Set of strike prices.
- See Also:
MamdaOptionAtTheMoneyCompareType
-
getStrikesWithinRangeSize
public java.util.SortedSet getStrikesWithinRangeSize(int rangeLength, short compareType)
Determine the set of strike prices that are included in a given fixed size range of strikes surrounding the underlying price. If rangeLen is odd, then the strike price nearest to the underlying price is treated as a higher strike price. If rangeLen is even and the underlying price is exactly equal to a strike price, then that strike price is treated as a higher strike price.- Parameters:
rangeLength
- Number of strike prices to include in result.compareType
- What underlying price to use as a comparator.- Returns:
- SortedSet Resulting set of strike prices.
- See Also:
MamdaOptionAtTheMoneyCompareType
-
callIterator
public java.util.Iterator callIterator()
Return an iterator over all call option contracts. The type of object that Iterator.next() returns isMamdaOptionContract
.- Returns:
- Iterator The iterator of call options.
-
putIterator
public java.util.Iterator putIterator()
Return an iterator over all put option contracts. The type of object that Iterator.next() returns is MamdaOptionContract.- Returns:
- Iterator The iterator of put options.
-
getAllExpirations
public MamdaOptionExpirationDateSet getAllExpirations()
Return a set of MamdaOptionExpirationDateSet.- Returns:
- MamdaOptionExpirationDateSet Set of expiration dates.
-
dump
public void dump()
Print the contents of the chain to standard out.
-
-