public virtual void test_volatility_inverse() { for (int i = 0; i < NB_EXPIRY; i++) { double expiryTime = VOLS.relativeTime(TEST_EXPIRY[i]); for (int j = 0; j < NB_STRIKE; ++j) { double volExpected = SURFACE.zValue(expiryTime, TEST_STRIKE[j]); double volComputed = VOLS.volatility(CURRENCY_PAIR.inverse(), TEST_EXPIRY[i], 1d / TEST_STRIKE[j], 1d / FORWARD[i]); assertEquals(volComputed, volExpected, TOLERANCE); } } }
public virtual void requirementsInverse() { FxRateMarketDataFunction function = new FxRateMarketDataFunction(); MarketDataRequirements requirements = function.requirements(FxRateId.of(CURRENCY_PAIR.inverse()), config()); assertThat(requirements).isEqualTo(MarketDataRequirements.of(QUOTE_ID)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance from currency pair, reference currency, reference date and sensitivity value. /// <para> /// The sensitivity currency is defaulted to be a currency of the currency pair that is not the reference currency. /// /// </para> /// </summary> /// <param name="currencyPair"> the currency pair </param> /// <param name="referenceCurrency"> the reference currency </param> /// <param name="referenceDate"> the reference date </param> /// <param name="sensitivity"> the value of the sensitivity </param> /// <returns> the point sensitivity object </returns> public static FxForwardSensitivity of(CurrencyPair currencyPair, Currency referenceCurrency, LocalDate referenceDate, double sensitivity) { bool inverse = referenceCurrency.Equals(currencyPair.Counter); CurrencyPair pair = inverse ? currencyPair.inverse() : currencyPair; Currency sensitivityCurrency = pair.Counter; return(new FxForwardSensitivity(currencyPair, referenceCurrency, referenceDate, sensitivityCurrency, sensitivity)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance from the observation, reference currency and sensitivity value. /// <para> /// The sensitivity currency is defaulted to be the counter currency of queried currency pair. /// /// </para> /// </summary> /// <param name="observation"> the rate observation, including the fixing date </param> /// <param name="referenceCurrency"> the reference currency </param> /// <param name="sensitivity"> the value of the sensitivity </param> /// <returns> the point sensitivity object </returns> public static FxIndexSensitivity of(FxIndexObservation observation, Currency referenceCurrency, double sensitivity) { CurrencyPair obsPair = observation.CurrencyPair; bool inverse = referenceCurrency.Equals(obsPair.Counter); CurrencyPair queriedPair = inverse ? obsPair.inverse() : obsPair; Currency sensiCurrency = queriedPair.Counter; return(new FxIndexSensitivity(observation, referenceCurrency, sensiCurrency, sensitivity)); }
public virtual void containsInversePair() { assertThat(config().getObservableRateKey(CURRENCY_PAIR.inverse())).hasValue(QUOTE_KEY); }