@Test /** Tests the class getters. */ public void getter() { assertEquals(OPTION_EDU2, OPTION_TRANSACTION.getUnderlyingOption()); assertEquals(QUANTITY, OPTION_TRANSACTION.getQuantity()); assertEquals(PREMIUM_DATE, OPTION_TRANSACTION.getPremium().getPaymentDate()); assertEquals(TRADE_PRICE, OPTION_TRANSACTION.getTradePrice()); }
@Test /** Tests the toDerivative method when the reference date is before the premium settlement. */ public void toDerivativeBeforeSettlement() { final InterestRateFutureOptionPremiumTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(REFERENCE_DATE); final InterestRateFutureOptionPremiumSecurity security = OPTION_EDU2.toDerivative(REFERENCE_DATE); final double premiumTime = TimeCalculator.getTimeBetween(REFERENCE_DATE, PREMIUM_DATE); final InterestRateFutureOptionPremiumTransaction transaction = new InterestRateFutureOptionPremiumTransaction( security, QUANTITY, premiumTime, TRADE_PRICE); assertEquals("Option on future: to derivative", transaction, transactionConverted); }
@Test /** Tests the toDerivative method when the reference date is after the premium settlement. */ public void toDerivativeAfterSettlement() { final ZonedDateTime referenceDate = PREMIUM_DATE.plusDays(1); final InterestRateFutureOptionPremiumTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(referenceDate); final InterestRateFutureOptionPremiumSecurity security = OPTION_EDU2.toDerivative(referenceDate); final double premiumTime = 0.0; final double price = 0.0; // The payment is in the past and is represented by a 0 payment today. final InterestRateFutureOptionPremiumTransaction transaction = new InterestRateFutureOptionPremiumTransaction(security, QUANTITY, premiumTime, price); assertEquals("Option on future: to derivative", transaction, transactionConverted); }
@Test /** Tests the toDerivative method when the reference date is on the premium settlement. */ public void toDerivativeOnSettlement() { final ZonedDateTime referenceDate = PREMIUM_DATE; final InterestRateFutureOptionPremiumTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(referenceDate); final InterestRateFutureOptionPremiumSecurity security = OPTION_EDU2.toDerivative(referenceDate); final double premiumTime = 0.0; final InterestRateFutureOptionPremiumTransaction transaction = new InterestRateFutureOptionPremiumTransaction( security, QUANTITY, premiumTime, TRADE_PRICE); assertEquals("Option on future: to derivative", transaction, transactionConverted); }
@Test /** Tests the equal and hashCode methods. */ public void equalHash() { final InterestRateFutureOptionPremiumTransactionDefinition other = new InterestRateFutureOptionPremiumTransactionDefinition( OPTION_EDU2, QUANTITY, PREMIUM_DATE, TRADE_PRICE); assertTrue(OPTION_TRANSACTION.equals(other)); assertTrue(OPTION_TRANSACTION.hashCode() == other.hashCode()); InterestRateFutureOptionPremiumTransactionDefinition modifidOption; modifidOption = new InterestRateFutureOptionPremiumTransactionDefinition( OPTION_EDU2, QUANTITY + 1, PREMIUM_DATE, TRADE_PRICE); assertFalse(OPTION_TRANSACTION.equals(modifidOption)); modifidOption = new InterestRateFutureOptionPremiumTransactionDefinition( OPTION_EDU2, QUANTITY, LAST_TRADING_DATE, TRADE_PRICE); assertFalse(OPTION_TRANSACTION.equals(modifidOption)); modifidOption = new InterestRateFutureOptionPremiumTransactionDefinition( OPTION_EDU2, QUANTITY, PREMIUM_DATE, TRADE_PRICE - 0.00001); assertFalse(OPTION_TRANSACTION.equals(modifidOption)); }