Package com.wombat.mamda.options
Class MamdaOptionChainView
- java.lang.Object
-
- com.wombat.mamda.options.MamdaOptionChainView
-
- All Implemented Interfaces:
MamdaOptionChainHandler
public class MamdaOptionChainView extends java.lang.Object implements MamdaOptionChainHandler
A class that represents a "view" of a subset of an option chain. The view can be restricted to a percentage or number of strike prices around "the money" as well as to a maximum number of days into the future. The view will be adjusted to include strike prices within the range as the underlying price moves. This means that the range of strike prices will change over time. In order to avoid a "jitter" in the range of strike prices when the underlying price hovers right on the edge of a range boundary, the class also provides a "jitter margin" as some percentage of the underlying price (default is 0.5%).
-
-
Constructor Summary
Constructors Constructor Description MamdaOptionChainView(MamdaOptionChain chain)
Create a view on the given option chain.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Iterator
expirationIterator()
Return an Iterator over the set of expiration dates within the view.java.lang.String
getSymbol()
Return the symbol for the option chain.boolean
isVisible(MamdaOptionContract contract)
Return whether an option contract falls within this view's parameters.void
onOptionChainRecap(MamdaSubscription subscription, MamdaOptionChainListener listener, com.wombat.mama.MamaMsg msg, MamdaOptionChain chain)
Handler option chain recaps and initial values.void
onOptionContractCreate(MamdaSubscription subscription, MamdaOptionChainListener listener, com.wombat.mama.MamaMsg msg, MamdaOptionContract contract, MamdaOptionChain chain)
Handler for option chain structural updates.void
onOptionSeriesUpdate(MamdaSubscription subscription, MamdaOptionChainListener listener, com.wombat.mama.MamaMsg msg, MamdaOptionSeriesUpdate event, MamdaOptionChain chain)
Handler for option chain structural updates.void
setAtTheMoneyType(short atTheMoneyType)
Set how the underlying price ("at the money") is determined (@see MamdaOptionAtTheMoneyCompareType).void
setExpirationRangeDays(int expirationDays)
Set the range of expiration dates to be included in the view by the maximum number of days until expiration.void
setJitterMargin(double percentMargin)
Set a "jitter margin" to avoid having the range jump between different strike prices when the underlying price hovers right on the edge of a range boundary.void
setNumberOfExpirations(int numExpirations)
Set the number of expiration dates to be included in the view.void
setStrikeRangeNumber(int number)
Set the number of strike prices to be included in the view.void
setStrikeRangePercent(double percentMargin)
Set the range of strike prices to be included in the view by percentage variation from the underlying price.
-
-
-
Constructor Detail
-
MamdaOptionChainView
public MamdaOptionChainView(MamdaOptionChain chain)
Create a view on the given option chain. Multiple views are supported on any given option chain.
-
-
Method Detail
-
getSymbol
public java.lang.String getSymbol()
Return the symbol for the option chain.
-
setAtTheMoneyType
public void setAtTheMoneyType(short atTheMoneyType)
Set how the underlying price ("at the money") is determined (@see MamdaOptionAtTheMoneyCompareType).
-
setStrikeRangePercent
public void setStrikeRangePercent(double percentMargin)
Set the range of strike prices to be included in the view by percentage variation from the underlying price. The range of strike prices in the view will vary as the underlying varies. The "jitter margin" avoids switching between ranges too often.
-
setStrikeRangeNumber
public void setStrikeRangeNumber(int number)
Set the number of strike prices to be included in the view. The "jitter margin" avoids switching between ranges too often.
-
setExpirationRangeDays
public void setExpirationRangeDays(int expirationDays)
Set the range of expiration dates to be included in the view by the maximum number of days until expiration. Note: a non-zero range overrides a specific number of expirations set by setNumberOfExpirations().
-
setNumberOfExpirations
public void setNumberOfExpirations(int numExpirations)
Set the number of expiration dates to be included in the view. Note: a non-zero range (set by setExpirationRangeDays()) overrides a specific number of expirations.
-
setJitterMargin
public void setJitterMargin(double percentMargin)
Set a "jitter margin" to avoid having the range jump between different strike prices when the underlying price hovers right on the edge of a range boundary. The underlying is allowed to fluctuate within the jitter margin without the range being reset. When the underlying moves beyond the jitter margin, the range is reset.
-
isVisible
public boolean isVisible(MamdaOptionContract contract)
Return whether an option contract falls within this view's parameters.
-
expirationIterator
public java.util.Iterator expirationIterator()
Return an Iterator over the set of expiration dates within the view. Each Iterator represents a MamdaOptionExpirationStrikes object.
-
onOptionChainRecap
public void onOptionChainRecap(MamdaSubscription subscription, MamdaOptionChainListener listener, com.wombat.mama.MamaMsg msg, MamdaOptionChain chain)
Handler option chain recaps and initial values.- Specified by:
onOptionChainRecap
in interfaceMamdaOptionChainHandler
- Parameters:
subscription
- The subscription which received the udpate.listener
- The listener which invoked the callback.msg
- The MamaMsg that triggered this invocation.chain
- The full option chain.
-
onOptionContractCreate
public void onOptionContractCreate(MamdaSubscription subscription, MamdaOptionChainListener listener, com.wombat.mama.MamaMsg msg, MamdaOptionContract contract, MamdaOptionChain chain)
Handler for option chain structural updates.- Specified by:
onOptionContractCreate
in interfaceMamdaOptionChainHandler
- Parameters:
subscription
- The subscription which received the update.listener
- The listener which invoked the callback.msg
- The MamaMsg that triggered this invocation.contract
- The newly created option contract.chain
- The full option chain.
-
onOptionSeriesUpdate
public void onOptionSeriesUpdate(MamdaSubscription subscription, MamdaOptionChainListener listener, com.wombat.mama.MamaMsg msg, MamdaOptionSeriesUpdate event, MamdaOptionChain chain)
Handler for option chain structural updates.- Specified by:
onOptionSeriesUpdate
in interfaceMamdaOptionChainHandler
- Parameters:
subscription
- The subscription which received the update.listener
- The listener which invoked the callback.msg
- The MamaMsg that triggered this invocation.event
- Access to details from the option series update event.chain
- The full option chain.- See Also:
MamdaOptionChainHandler.onOptionContractCreate(com.wombat.mamda.MamdaSubscription, com.wombat.mamda.options.MamdaOptionChainListener, com.wombat.mama.MamaMsg, com.wombat.mamda.options.MamdaOptionContract, com.wombat.mamda.options.MamdaOptionChain)
-
-