|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.marketcetera.strategy.util.OptionChain
@ThreadSafe public final class OptionChain
Represents the option chain of a given underlying instrument.
This object maintains an in-memory representation of the option chain
of an underlying instrument and its market data. To use OptionChain,
create a new OptionChain (may use any instrument as the underlying instrument
of the option chain):
Equity theEquity = new Equity("GOOG");
OptionChain theChain = new OptionChain(theEquity);
Set up market data for the underlying instrument as normal. As market data events arrive,
pass the appropriate ones to the OptionChain:
public void onAsk(AskEvent ask)
{
theChain.process(ask);
}
Note that if the AskEvent is not relevant to the OptionChain, it
will be discarded. To take full advantage of the OptionChain object, add
similar code to onBid, onTrade, onMarketstat, and
onDividend.
The data stored in the OptionChain object can be retrieved as follows:
List<OptionContractPair> optionChain = theChain.getOptionChain();
for(OptionContractPair contractPair : optionChain) {
OptionContract putSide = contractPair.getPut();
// do something with the put contract
OptionContract callSide = contractPair.getCall();
// do something with the call contract
}
As new market data events come in, the option chain view is updated as the
events are added to the OptionChain object with process(Event).
Dividends for the underlying instrument of the OptionChain object are available in
a similar fashion:
List<DividendEvent> dividends = theChain.getDividends();The
OptionChain also tracks market data for the underlying instrument and each
OptionContract.
// the latest ask for the option chain underlying instrument
AskEvent ask = theChain.getLatestUnderlyingAsk();
for(OptionContractPair contractPair : optionChain) {
// the latest ask for the put side of one of the entries in the option chain
ask = contractPair.getPut().getLatestAsk();
}
| Constructor Summary | |
|---|---|
OptionChain(Instrument inUnderlyingInstrument)
Create a new OptionChain instance. |
|
| Method Summary | |
|---|---|
List<DividendEvent> |
getDividends()
Gets a live, unmodifiable view of the dividends for the underlying instrument. |
AskEvent |
getLatestUnderlyingAsk()
Gets the latest Ask for the underlying instrument. |
BidEvent |
getLatestUnderlyingBid()
Gets the latest Bid for the underlying instrument. |
MarketstatEvent |
getLatestUnderlyingMarketstat()
Gets the latest Marketstat for the underlying instrument. |
TradeEvent |
getLatestUnderlyingTrade()
Gets the latest Trade for the underlying instrument. |
Collection<OptionContractPair> |
getOptionChain()
Gets a live, unmodifiable view of the option chain. |
Instrument |
getUnderlyingInstrument()
Gets the underlying instrument for this OptionChain. |
boolean |
process(Event inEvent)
Attempts to apply the given event to this OptionChain. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public OptionChain(Instrument inUnderlyingInstrument)
inUnderlyingInstrument - an Instrument value indicating the Instrument for which
to create the OptionChain
NullPointerException - if inUnderlyingInstrument is null| Method Detail |
|---|
public Collection<OptionContractPair> getOptionChain()
Updates to the option chain will be visible in this view. The
elements in the option chain will be sorted according to the
OptionContractPair natural order.
This view is populated when Event objects are passed
to process(Event).
Collection<OptionContractPair> valuepublic List<DividendEvent> getDividends()
Updates to the dividend data for the underlying instrument will be
visible in this view. The elements in the list are sorted in the order
that the corresponding DividendEvent objects are received.
This view is populated when DividendEvent objects are passed
to process(Event).
List<DividendEvent> valuepublic Instrument getUnderlyingInstrument()
OptionChain.
Instrument valuepublic AskEvent getLatestUnderlyingAsk()
Ask for the underlying instrument.
This data is populated when AskEvent objects are passed
to process(Event).
AskEvent or nullpublic BidEvent getLatestUnderlyingBid()
Bid for the underlying instrument.
This data is populated when BidEvent objects are passed
to process(Event).
BidEvent or nullpublic TradeEvent getLatestUnderlyingTrade()
Trade for the underlying instrument.
This data is populated when TradeEvent objects are passed
to process(Event).
TradeEvent or nullpublic MarketstatEvent getLatestUnderlyingMarketstat()
Marketstat for the underlying instrument.
This data is populated when MarketstatEvent objects are passed
to process(Event).
BidEvent or nullpublic boolean process(Event inEvent)
OptionChain.
inEvent - an Event value
boolean value which, if true, indicates that the given event was successfully applied
to the option chain. If false, the event was not applicable.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||