示例#1
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxOptionVolatilitiesDefinition test1 = FxOptionVolatilitiesDefinition.of(SPEC);

            coverImmutableBean(test1);
            BlackFxOptionSmileVolatilitiesSpecification spec2 = BlackFxOptionSmileVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(EUR_GBP).dayCount(ACT_360).nodes(NODES).timeInterpolator(LINEAR).strikeInterpolator(LINEAR).build();
            FxOptionVolatilitiesDefinition test2 = FxOptionVolatilitiesDefinition.of(spec2);

            coverBeanEquals(test1, test2);
        }
示例#2
0
        public virtual void test_builder()
        {
            BlackFxOptionSmileVolatilitiesSpecification test = BlackFxOptionSmileVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(EUR_GBP).dayCount(ACT_360).nodes(NODES).timeInterpolator(PCHIP).timeExtrapolatorLeft(LINEAR).timeExtrapolatorRight(FLAT).strikeInterpolator(DOUBLE_QUADRATIC).strikeExtrapolatorLeft(FLAT).strikeExtrapolatorRight(LINEAR).build();

            assertEquals(test.CurrencyPair, EUR_GBP);
            assertEquals(test.DayCount, ACT_360);
            assertEquals(test.Name, VOL_NAME);
            assertEquals(test.Nodes, NODES);
            assertEquals(test.ParameterCount, TENORS.size());
            assertEquals(test.StrikeInterpolator, DOUBLE_QUADRATIC);
            assertEquals(test.StrikeExtrapolatorLeft, FLAT);
            assertEquals(test.StrikeExtrapolatorRight, LINEAR);
            assertEquals(test.TimeInterpolator, PCHIP);
            assertEquals(test.TimeExtrapolatorLeft, LINEAR);
            assertEquals(test.TimeExtrapolatorRight, FLAT);
            assertEquals(test.volatilitiesInputs(), QUOTE_IDS);
        }
示例#3
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            BlackFxOptionSmileVolatilitiesSpecification test1 = BlackFxOptionSmileVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(EUR_GBP).dayCount(ACT_360).nodes(NODES).timeInterpolator(PCHIP).timeExtrapolatorLeft(LINEAR).timeExtrapolatorRight(LINEAR).strikeInterpolator(PCHIP).strikeExtrapolatorLeft(LINEAR).strikeExtrapolatorRight(LINEAR).build();

            coverImmutableBean(test1);
            CurrencyPair eurUsd = CurrencyPair.of(EUR, USD);

            ImmutableList.Builder <FxOptionVolatilitiesNode> builder = ImmutableList.builder();
            for (int i = 0; i < TENORS.size(); ++i)
            {
                QuoteId id = QuoteId.of(StandardId.of("OG", TENORS.get(i).ToString() + "_" + DELTAS.get(i).ToString() + "_" + QUOTE_TYPE.get(i).ToString()));
                builder.add(FxOptionVolatilitiesNode.of(eurUsd, DaysAdjustment.NONE, BusinessDayAdjustment.NONE, QUOTE_TYPE.get(i), id, TENORS.get(i), DeltaStrike.of(DELTAS.get(i))));
            }
            BlackFxOptionSmileVolatilitiesSpecification test2 = BlackFxOptionSmileVolatilitiesSpecification.builder().name(FxOptionVolatilitiesName.of("other")).currencyPair(eurUsd).dayCount(ACT_365F).nodes(builder.build()).timeInterpolator(DOUBLE_QUADRATIC).strikeInterpolator(DOUBLE_QUADRATIC).build();

            coverBeanEquals(test1, test2);
        }
示例#4
0
        public virtual void test_volatilities()
        {
            BlackFxOptionSmileVolatilitiesSpecification @base = BlackFxOptionSmileVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(EUR_GBP).dayCount(ACT_360).nodes(NODES).timeInterpolator(PCHIP).strikeInterpolator(PCHIP).build();
            LocalDate     date       = LocalDate.of(2017, 9, 25);
            ZonedDateTime dateTime   = date.atStartOfDay().atZone(ZoneId.of("Europe/London"));
            DoubleArray   parameters = DoubleArray.of(0.05, -0.05, 0.15, 0.25, 0.1, -0.1);
            BlackFxOptionSmileVolatilities computed = @base.volatilities(dateTime, parameters, REF_DATA);
            LocalDate               spotDate        = SPOT_OFFSET.adjust(dateTime.toLocalDate(), REF_DATA);
            DaysAdjustment          expOffset       = DaysAdjustment.ofBusinessDays(-2, TA_LO);
            DoubleArray             expiries        = DoubleArray.of(ACT_360.relativeYearFraction(date, expOffset.adjust(BUS_ADJ.adjust(spotDate.plus(Tenor.TENOR_3M), REF_DATA), REF_DATA)), ACT_360.relativeYearFraction(date, expOffset.adjust(BUS_ADJ.adjust(spotDate.plus(Tenor.TENOR_1Y), REF_DATA), REF_DATA)));
            SmileDeltaTermStructure smiles          = InterpolatedStrikeSmileDeltaTermStructure.of(expiries, DoubleArray.of(0.1), DoubleArray.of(0.25, 0.15), DoubleMatrix.ofUnsafe(new double[][]
            {
                new double[] { -0.1 },
                new double[] { -0.05 }
            }), DoubleMatrix.ofUnsafe(new double[][]
            {
                new double[] { 0.1 },
                new double[] { 0.05 }
            }), ACT_360, PCHIP, FLAT, FLAT, PCHIP, FLAT, FLAT);
            BlackFxOptionSmileVolatilities expected = BlackFxOptionSmileVolatilities.of(VOL_NAME, EUR_GBP, dateTime, smiles);

            assertEquals(computed, expected);
        }
示例#5
0
        public virtual void serialization()
        {
            BlackFxOptionSmileVolatilitiesSpecification test = BlackFxOptionSmileVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(EUR_GBP).dayCount(ACT_360).nodes(NODES).timeInterpolator(PCHIP).timeExtrapolatorLeft(LINEAR).timeExtrapolatorRight(FLAT).strikeInterpolator(DOUBLE_QUADRATIC).strikeExtrapolatorLeft(FLAT).strikeExtrapolatorRight(LINEAR).build();

            assertSerialization(test);
        }