/* Ascending expiration month, strike price, and exchange. */ public int compare(object o1, object o2) { MamdaOptionContract contract1 = (MamdaOptionContract)o1; MamdaOptionContract contract2 = (MamdaOptionContract)o2; // Expiration month DateTime expiration1 = contract1.getExpireDate(); DateTime expiration2 = contract2.getExpireDate(); int comp = expiration1.CompareTo(expiration2); if (comp == 0) { // Strike price double strike1 = contract1.getStrikePrice(); double strike2 = contract2.getStrikePrice(); comp = strike1.CompareTo(strike2); } if (comp == 0) { // Exchange string exchange1 = contract1.getExchange(); string exchange2 = contract2.getExchange(); comp = exchange1.CompareTo(exchange2); } return(comp); }
private void dump(MamdaOptionContract contract) { Console.Write("{0} {1} {2} {3}", contract.getSymbol(), contract.getExchange(), contract.getExpireDate(), contract.getStrikePrice()); }
/// <summary> /// Return whether an option contract falls within this view's /// parameters. /// </summary> /// <param name="contract"></param> /// <returns></returns> public bool isVisible(MamdaOptionContract contract) { double strikePrice = contract.getStrikePrice(); DateTime expireDate = contract.getExpireDate(); return((mLowExpireDate <= expireDate) && (mHighExpireDate >= expireDate) && (mLowStrike <= strikePrice) && (strikePrice <= mHighStrike)); }
/// <summary> /// 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. /// </summary> /// <param name="contractSymbol">The option instrument symbol.</param> /// <param name="contract">The Mamda option contract representation.</param> public void addContract( string contractSymbol, MamdaOptionContract contract) { DateTime expireDate = contract.getExpireDate(); double strikePrice = contract.getStrikePrice(); string exchange = contract.getExchange(); MamdaOptionContract.PutOrCall putCall = contract.getPutCall(); mOptions.put(contractSymbol, contract); if (putCall == MamdaOptionContract.PutOrCall.Call) { mCallOptions.add(contract); } else { mPutOptions.add(contract); } // Add the contract to the expiration-by-strike set. MamdaOptionExpirationStrikes expireStrikes = (MamdaOptionExpirationStrikes)mExpirationSet.valueOf(expireDate); if (expireStrikes == null) { expireStrikes = new MamdaOptionExpirationStrikes(); mExpirationSet.put(expireDate, expireStrikes); } MamdaOptionStrikeSet strikeSet = (MamdaOptionStrikeSet)expireStrikes.valueOf(strikePrice); if (strikeSet == null) { strikeSet = new MamdaOptionStrikeSet(expireDate, strikePrice); expireStrikes.put(strikePrice, strikeSet); } MamdaOptionContractSet contractSet = (putCall == MamdaOptionContract.PutOrCall.Call) ? strikeSet.getCallSet() : strikeSet.getPutSet(); if (MamdaOptionExchangeUtils.isBbo(exchange)) { contractSet.setBboContract(contract); } else if (MamdaOptionExchangeUtils.isWombatBbo(exchange)) { contractSet.setWombatBboContract(contract); } else { contractSet.setExchangeContract(exchange, contract); mExchanges.add(exchange); } mStrikePrices.add(strikePrice); }
/// <summary> /// Return whether an option contract falls within this view's /// parameters. /// </summary> /// <param name="contract"></param> /// <returns></returns> public bool isVisible(MamdaOptionContract contract) { double strikePrice = contract.getStrikePrice(); DateTime expireDate = contract.getExpireDate(); return ((mLowExpireDate <= expireDate) && (mHighExpireDate >= expireDate) && (mLowStrike <= strikePrice) && (strikePrice <= mHighStrike)); }