/** * Builds an <code>OptionBean</code> based on the values of * the given event. * * @param inOptionEvent an <code>OptionEvent</code> value * @return an <code>OptionBean</code> value */ public static OptionBean getOptionBeanFromEvent(OptionEvent inOptionEvent) { OptionBean option = new OptionBean(); option.setExpirationType(inOptionEvent.getExpirationType()); option.setHasDeliverable(inOptionEvent.hasDeliverable()); option.setInstrument(inOptionEvent.getInstrument()); option.setMultiplier(inOptionEvent.getMultiplier()); option.setUnderlyingInstrument(inOptionEvent.getUnderlyingInstrument()); option.setProviderSymbol(inOptionEvent.getProviderSymbol()); return option; } /**
/** * Create a new OptionContractPair instance. * * @param inOptionEvent an <code>OptionEvent</code> value * @throws IllegalArgumentException if <code>Instrument</code> is <code>null</code> * @throws IllegalArgumentException if <code>UnderlyingInstrument</code> is <code>null</code> * @throws IllegalArgumentException if <code>ExpirationType</code> is <code>null</code> */ OptionContractPair(OptionEvent inOptionEvent) { key = getOptionContractPairKey(inOptionEvent.getInstrument()); process(inOptionEvent); } /**
if(!optionEvent.getUnderlyingInstrument().equals(getUnderlyingInstrument())) { WRONG_UNDERLYING_FOR_OPTION_CHAIN.warn(OptionChain.class, optionEvent.getUnderlyingInstrument(), getUnderlyingInstrument()); return false;
/** * Processes the given <code>OptionEvent</code> to update the option chain. * * @param inOptionEvent an <code>OptionEvent</code> value * @return a <code>boolean</code> value indicating whether the <code>OptionEvent</code> was successfully * applied or not */ private synchronized boolean processEventForOptionChain(OptionEvent inOptionEvent) { // this method is synchronized in order to make put-if-absent atomic // create the object that will identify the correct contract pair in the option chain - the pair // may or may not yet exist in the chain OptionContractPairKey key = OptionContractPair.getOptionContractPairKey(inOptionEvent.getInstrument()); // retrieve the pair if it exists OptionContractPair contractPair = optionChain.get(key); if(contractPair == null) { // the pair does not yet exist, create the put/call contract pair for this event contractPair = new OptionContractPair(inOptionEvent); // add the new contract pair to the chain optionChain.put(key, contractPair); } // the contract pair exists in the pair (is non-null, here, too) - process the option event return contractPair.process(inOptionEvent); } /**
ExchangeRequestBuilder topOfBookRequestBuilder = ExchangeRequestBuilder.newRequest().withInstrument(quoteEvent.getInstrument()); if(quoteEvent instanceof OptionEvent) { topOfBookRequestBuilder.withUnderlyingInstrument(((OptionEvent)quoteEvent).getUnderlyingInstrument());
if(inOptionEvent.getInstrument().getType() == OptionType.Call) { if(call == null) { call = new OptionContract(inOptionEvent.getUnderlyingInstrument(), inOptionEvent.getInstrument(), inOptionEvent.getInstrument().getType(), inOptionEvent.getExpirationType(), inOptionEvent.hasDeliverable(), inOptionEvent.getMultiplier(), inOptionEvent instanceof HasProviderSymbol ? ((HasProviderSymbol)inOptionEvent).getProviderSymbol() : null); if(inOptionEvent.getInstrument().getType() == OptionType.Put) { if(put == null) { put = new OptionContract(inOptionEvent.getUnderlyingInstrument(), inOptionEvent.getInstrument(), inOptionEvent.getInstrument().getType(), inOptionEvent.getExpirationType(), inOptionEvent.hasDeliverable(), inOptionEvent.getMultiplier(), inOptionEvent instanceof HasProviderSymbol ? ((HasProviderSymbol)inOptionEvent).getProviderSymbol() : null);