コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxOptionVolatilitiesNode test1 = FxOptionVolatilitiesNode.of(EUR_GBP, SPOT_DATE_OFFSET, BDA, ValueType.BLACK_VOLATILITY, QUOTE_ID, Tenor.TENOR_3M, STRIKE);

            coverImmutableBean(test1);
            FxOptionVolatilitiesNode test2 = FxOptionVolatilitiesNode.of(CurrencyPair.of(GBP, USD), DaysAdjustment.NONE, BusinessDayAdjustment.NONE, ValueType.RISK_REVERSAL, QuoteId.of(StandardId.of("OG", "foo")), Tenor.TENOR_6M, DeltaStrike.of(0.1));

            coverBeanEquals(test1, test2);
        }
コード例 #2
0
        public virtual void test_expiry()
        {
            FxOptionVolatilitiesNode test     = FxOptionVolatilitiesNode.of(EUR_GBP, SPOT_DATE_OFFSET, BDA, ValueType.BLACK_VOLATILITY, QUOTE_ID, Tenor.TENOR_3M, STRIKE);
            ZonedDateTime            dateTime = LocalDate.of(2016, 1, 23).atStartOfDay(ZoneId.of("Europe/London"));
            DaysAdjustment           expAdj   = DaysAdjustment.ofBusinessDays(-2, LO_TA);
            double computed = test.timeToExpiry(dateTime, ACT_365F, REF_DATA);
            double expected = ACT_365F.relativeYearFraction(dateTime.toLocalDate(), expAdj.adjust(BDA.adjust(SPOT_DATE_OFFSET.adjust(dateTime.toLocalDate(), REF_DATA).plus(Tenor.TENOR_3M), REF_DATA), REF_DATA));

            assertEquals(computed, expected);
        }
コード例 #3
0
 static FxOptionVolatilitiesDefinitionTest()
 {
     ImmutableList.Builder <FxOptionVolatilitiesNode> builder = ImmutableList.builder();
     ImmutableList.Builder <QuoteId> quoteBuilder             = 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(EUR_GBP, SPOT_OFFSET, BUS_ADJ, QUOTE_TYPE.get(i), id, TENORS.get(i), DeltaStrike.of(DELTAS.get(i))));
         quoteBuilder.add(id);
     }
     NODES     = builder.build();
     QUOTE_IDS = quoteBuilder.build();
 }
コード例 #4
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FxOptionVolatilitiesNode other = (FxOptionVolatilitiesNode)obj;
         return(JodaBeanUtils.equal(currencyPair, other.currencyPair) && JodaBeanUtils.equal(label, other.label) && JodaBeanUtils.equal(spotDateOffset, other.spotDateOffset) && JodaBeanUtils.equal(businessDayAdjustment, other.businessDayAdjustment) && JodaBeanUtils.equal(expiryDateOffset_Renamed, other.expiryDateOffset_Renamed) && JodaBeanUtils.equal(quoteValueType, other.quoteValueType) && JodaBeanUtils.equal(quoteId, other.quoteId) && JodaBeanUtils.equal(tenor, other.tenor) && JodaBeanUtils.equal(strike, other.strike));
     }
     return(false);
 }
コード例 #5
0
        public virtual void test_of()
        {
            FxOptionVolatilitiesNode test = FxOptionVolatilitiesNode.of(EUR_GBP, SPOT_DATE_OFFSET, BDA, ValueType.BLACK_VOLATILITY, QUOTE_ID, Tenor.TENOR_3M, STRIKE);

            assertEquals(test.BusinessDayAdjustment, BDA);
            assertEquals(test.CurrencyPair, EUR_GBP);
            assertEquals(test.Label, QUOTE_ID.ToString());
            assertEquals(test.QuoteValueType, ValueType.BLACK_VOLATILITY);
            assertEquals(test.SpotDateOffset, SPOT_DATE_OFFSET);
            assertEquals(test.ExpiryDateOffset, DaysAdjustment.ofBusinessDays(-2, LO_TA));
            assertEquals(test.Strike, STRIKE);
            assertEquals(test.Tenor, Tenor.TENOR_3M);
        }
コード例 #6
0
        public virtual void test_builder_noExp()
        {
            FxOptionVolatilitiesNode test = FxOptionVolatilitiesNode.builder().currencyPair(EUR_GBP).label(LABEL).spotDateOffset(SPOT_DATE_OFFSET).businessDayAdjustment(BDA).quoteValueType(ValueType.BLACK_VOLATILITY).quoteId(QUOTE_ID).tenor(Tenor.TENOR_3M).strike(STRIKE).build();

            assertEquals(test.BusinessDayAdjustment, BDA);
            assertEquals(test.CurrencyPair, EUR_GBP);
            assertEquals(test.Label, LABEL);
            assertEquals(test.QuoteValueType, ValueType.BLACK_VOLATILITY);
            assertEquals(test.SpotDateOffset, SPOT_DATE_OFFSET);
            assertEquals(test.ExpiryDateOffset, DaysAdjustment.ofBusinessDays(-2, LO_TA));
            assertEquals(test.Strike, STRIKE);
            assertEquals(test.Tenor, Tenor.TENOR_3M);
        }
コード例 #7
0
        public virtual void test_expiry_standard()
        {
            DaysAdjustment        spotLag = DaysAdjustment.ofBusinessDays(2, LO_NY);
            BusinessDayAdjustment bda     = BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, LO_NY);

            FxOptionVolatilitiesNode[] nodes    = new FxOptionVolatilitiesNode[] { FxOptionVolatilitiesNode.of(GBP_USD, spotLag, bda, ValueType.BLACK_VOLATILITY, QUOTE_ID, Tenor.TENOR_2M, STRIKE), FxOptionVolatilitiesNode.of(GBP_USD, spotLag, bda, ValueType.BLACK_VOLATILITY, QUOTE_ID, Tenor.TENOR_10M, STRIKE), FxOptionVolatilitiesNode.of(GBP_USD, spotLag, bda, ValueType.BLACK_VOLATILITY, QUOTE_ID, Tenor.TENOR_4M, STRIKE) };
            ZonedDateTime[]            valDates = new ZonedDateTime[] { LocalDate.of(2017, 10, 25).atStartOfDay(ZoneId.of("Europe/London")), LocalDate.of(2017, 10, 25).atStartOfDay(ZoneId.of("Europe/London")), LocalDate.of(2017, 10, 27).atStartOfDay(ZoneId.of("Europe/London")) };
            LocalDate[] expDates = new LocalDate[] { LocalDate.of(2017, 12, 21), LocalDate.of(2018, 8, 23), LocalDate.of(2018, 2, 26) };
            for (int i = 0; i < expDates.Length; ++i)
            {
                double computed = nodes[i].timeToExpiry(valDates[i], ACT_365F, REF_DATA);
                double expected = ACT_365F.relativeYearFraction(valDates[i].toLocalDate(), expDates[i]);
                assertEquals(computed, expected);
            }
        }
 static BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecificationTest()
 {
     ImmutableList.Builder <FxOptionVolatilitiesNode> nodeBuilder = ImmutableList.builder();
     ImmutableList.Builder <QuoteId> quoteIdBuilder = ImmutableList.builder();
     for (int i = 0; i < TENORS.Count; ++i)
     {
         for (int j = 0; j < STRIKES.Count; ++j)
         {
             QuoteId quoteId = QuoteId.of(StandardId.of("OG", GBP_USD.ToString() + "_" + TENORS[i].ToString() + "_" + STRIKES[j]));
             nodeBuilder.add(FxOptionVolatilitiesNode.of(GBP_USD, SPOT_OFFSET, BDA, ValueType.BLACK_VOLATILITY, quoteId, TENORS[i], SimpleStrike.of(STRIKES[j])));
             quoteIdBuilder.add(quoteId);
         }
     }
     NODES     = nodeBuilder.build();
     QUOTE_IDS = quoteIdBuilder.build();
 }
コード例 #9
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);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification test1 = BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(GBP_USD).dayCount(ACT_365F).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> nodeBuilder = ImmutableList.builder();
            for (int i = 0; i < TENORS.Count; ++i)
            {
                for (int j = 0; j < STRIKES.Count; ++j)
                {
                    QuoteId quoteId = QuoteId.of(StandardId.of("OG", eurUsd.ToString() + "_" + TENORS[i].ToString() + "_" + STRIKES[j]));
                    nodeBuilder.add(FxOptionVolatilitiesNode.of(eurUsd, SPOT_OFFSET, BDA, ValueType.BLACK_VOLATILITY, quoteId, TENORS[i], SimpleStrike.of(STRIKES[j])));
                }
            }
            BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification test2 = BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification.builder().name(FxOptionVolatilitiesName.of("other")).currencyPair(eurUsd).dayCount(ACT_360).nodes(nodeBuilder.build()).timeInterpolator(DOUBLE_QUADRATIC).strikeInterpolator(DOUBLE_QUADRATIC).build();

            coverBeanEquals(test1, test2);
        }
コード例 #11
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Creates an instance.
        /// <para>
        /// The label is created from {@code quoteId}.
        ///
        /// </para>
        /// </summary>
        /// <param name="currencyPair">  the currency pair </param>
        /// <param name="spotDateOffset">  the spot date offset </param>
        /// <param name="businessDayAdjustment">  the business day adjustment </param>
        /// <param name="quoteValueType">  the quote value type </param>
        /// <param name="quoteId">  the quote ID </param>
        /// <param name="tenor">  the tenor </param>
        /// <param name="strike">  the strike </param>
        /// <returns> the instance </returns>
        public static FxOptionVolatilitiesNode of(CurrencyPair currencyPair, DaysAdjustment spotDateOffset, BusinessDayAdjustment businessDayAdjustment, ValueType quoteValueType, QuoteId quoteId, Tenor tenor, Strike strike)
        {
            DaysAdjustment expiryDateOffset = FxOptionVolatilitiesNode.expiryDateOffset(spotDateOffset);

            return(new FxOptionVolatilitiesNode(currencyPair, quoteId.ToString(), spotDateOffset, businessDayAdjustment, expiryDateOffset, quoteValueType, quoteId, tenor, strike));
        }
コード例 #12
0
        static FxOptionVolatilitiesMarketDataFunctionTest()
        {
            ImmutableList.Builder <FxOptionVolatilitiesNode>        volNodeBuilder             = ImmutableList.builder();
            ImmutableMap.Builder <QuoteId, double>                  marketQuoteBuilder         = ImmutableMap.builder();
            ImmutableMap.Builder <QuoteId, MarketDataBox <double> > scenarioMarketQuoteBuilder = ImmutableMap.builder();
            ImmutableList.Builder <FixedOvernightSwapCurveNode>     usdNodeBuilder             = ImmutableList.builder();
            ImmutableList.Builder <FxSwapCurveNode>                 gbpNodeBuilder             = ImmutableList.builder();
            for (int i = 0; i < VOL_TENORS.Count; ++i)
            {
                for (int j = 0; j < STRIKES.Count; ++j)
                {
                    QuoteId quoteId = QuoteId.of(StandardId.of("OG", VOL_TENORS[i].ToString() + "_" + STRIKES[j].Label + "_" + VALUE_TYPES[j].ToString()));
                    volNodeBuilder.add(FxOptionVolatilitiesNode.of(GBP_USD, SPOT_OFFSET, BDA, VALUE_TYPES[j], quoteId, VOL_TENORS[i], STRIKES[j]));
                    marketQuoteBuilder.put(quoteId, VOL_QUOTES[i][j]);
                    scenarioMarketQuoteBuilder.put(quoteId, MarketDataBox.ofScenarioValues(VOL_QUOTES[i][j], VOL_QUOTES_1[i][j]));
                }
            }
            for (int i = 0; i < USD_QUOTES.Count; ++i)
            {
                QuoteId quoteId = QuoteId.of(StandardId.of("OG", USD.ToString() + "-OIS-" + USD_TENORS[i].ToString()));
                usdNodeBuilder.add(FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(USD_TENORS[i], FixedOvernightSwapConventions.USD_FIXED_TERM_FED_FUND_OIS), quoteId));
                marketQuoteBuilder.put(quoteId, USD_QUOTES[i]);
                scenarioMarketQuoteBuilder.put(quoteId, MarketDataBox.ofScenarioValues(USD_QUOTES[i], USD_QUOTES_1[i]));
            }
            for (int i = 0; i < GBP_QUOTES.Count; ++i)
            {
                QuoteId quoteId = QuoteId.of(StandardId.of("OG", GBP_USD.ToString() + "-FX-" + GBP_PERIODS[i].ToString()));
                gbpNodeBuilder.add(FxSwapCurveNode.of(FxSwapTemplate.of(GBP_PERIODS[i], FxSwapConventions.GBP_USD), quoteId));
                marketQuoteBuilder.put(quoteId, GBP_QUOTES[i]);
                scenarioMarketQuoteBuilder.put(quoteId, MarketDataBox.ofScenarioValues(GBP_QUOTES[i], GBP_QUOTES_1[i]));
            }
            VOL_NODES              = volNodeBuilder.build();
            USD_NODES              = usdNodeBuilder.build();
            GBP_NODES              = gbpNodeBuilder.build();
            MARKET_QUOTES          = marketQuoteBuilder.build();
            SCENARIO_MARKET_QUOTES = scenarioMarketQuoteBuilder.build();
            IList <double> expiry  = VOL_TENORS.Select(t => ACT_365F.relativeYearFraction(VALUATION_DATE, BDA.adjust(SPOT_OFFSET.adjust(VALUATION_DATE, REF_DATA).plus(t), REF_DATA))).ToList();
            int            nSmiles = expiry.Count;

            double[] atm = new double[nSmiles];
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: double[][] rr = new double[nSmiles][2];
            double[][] rr = RectangularArrays.ReturnRectangularDoubleArray(nSmiles, 2);
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: double[][] str = new double[nSmiles][2];
            double[][] str = RectangularArrays.ReturnRectangularDoubleArray(nSmiles, 2);
            for (int i = 0; i < nSmiles; ++i)
            {
                atm[i]    = VOL_QUOTES[i][0];
                rr[i][0]  = VOL_QUOTES[i][1];
                rr[i][1]  = VOL_QUOTES[i][3];
                str[i][0] = VOL_QUOTES[i][2];
                str[i][1] = VOL_QUOTES[i][4];
            }
            InterpolatedStrikeSmileDeltaTermStructure term = InterpolatedStrikeSmileDeltaTermStructure.of(DoubleArray.copyOf(expiry), DoubleArray.of(0.1, 0.25), DoubleArray.copyOf(atm), DoubleMatrix.copyOf(rr), DoubleMatrix.copyOf(str), ACT_365F, LINEAR, FLAT, FLAT, PCHIP, FLAT, FLAT);

            EXP_VOLS = BlackFxOptionSmileVolatilities.of(VOL_NAME, GBP_USD, VALUATION_DATE.atTime(VALUATION_TIME).atZone(ZONE), term);
            for (int i = 0; i < nSmiles; ++i)
            {
                atm[i]    = VOL_QUOTES_1[i][0];
                rr[i][0]  = VOL_QUOTES_1[i][1];
                rr[i][1]  = VOL_QUOTES_1[i][3];
                str[i][0] = VOL_QUOTES_1[i][2];
                str[i][1] = VOL_QUOTES_1[i][4];
            }
            InterpolatedStrikeSmileDeltaTermStructure term1 = InterpolatedStrikeSmileDeltaTermStructure.of(DoubleArray.copyOf(expiry), DoubleArray.of(0.1, 0.25), DoubleArray.copyOf(atm), DoubleMatrix.copyOf(rr), DoubleMatrix.copyOf(str), ACT_365F, LINEAR, FLAT, FLAT, PCHIP, FLAT, FLAT);

            EXP_VOLS_1 = BlackFxOptionSmileVolatilities.of(VOL_NAME, GBP_USD, VALUATION_DATE_1.atTime(VALUATION_TIME_1).atZone(ZONE), term1);
            ImmutableList.Builder <FxOptionVolatilitiesNode> nodeBuilder  = ImmutableList.builder();
            ImmutableMap.Builder <QuoteId, double>           quoteBuilder = ImmutableMap.builder();
            for (int i = 0; i < SURFACE_TENORS.Count; ++i)
            {
                for (int j = 0; j < SURFACE_STRIKES.Count; ++j)
                {
                    QuoteId quoteId = QuoteId.of(StandardId.of("OG", GBP_USD.ToString() + "_" + SURFACE_TENORS[i].ToString() + "_" + SURFACE_STRIKES[j]));
                    quoteBuilder.put(quoteId, SURFACE_VOL_QUOTES[i][j]);
                    nodeBuilder.add(FxOptionVolatilitiesNode.of(GBP_USD, SPOT_OFFSET, BDA, ValueType.BLACK_VOLATILITY, quoteId, SURFACE_TENORS[i], SimpleStrike.of(SURFACE_STRIKES[j])));
                }
            }
            SURFACE_NODES  = nodeBuilder.build();
            SURFACE_QUOTES = quoteBuilder.build();
            IList <double> expiry = new List <double>();
            IList <double> strike = new List <double>();
            IList <double> vols   = new List <double>();

            for (int i = 0; i < SURFACE_TENORS.Count; ++i)
            {
                for (int j = 0; j < SURFACE_STRIKES.Count; ++j)
                {
                    double yearFraction = ACT_365F.relativeYearFraction(VALUATION_DATE, BDA.adjust(SPOT_OFFSET.adjust(VALUATION_DATE, REF_DATA).plus(SURFACE_TENORS[i]), REF_DATA));
                    expiry.Add(yearFraction);
                    strike.Add(SURFACE_STRIKES[j]);
                    vols.Add(SURFACE_VOL_QUOTES[i][j]);
                }
            }
            SurfaceInterpolator      interp  = GridSurfaceInterpolator.of(LINEAR, PCHIP);
            InterpolatedNodalSurface surface = InterpolatedNodalSurface.ofUnsorted(Surfaces.blackVolatilityByExpiryStrike(VOL_NAME.Name, ACT_365F), DoubleArray.copyOf(expiry), DoubleArray.copyOf(strike), DoubleArray.copyOf(vols), interp);

            SURFACE_EXP_VOLS = BlackFxOptionSurfaceVolatilities.of(VOL_NAME, GBP_USD, VALUATION_DATE.atTime(VALUATION_TIME).atZone(ZONE), surface);
        }
コード例 #13
0
        public virtual void serialization()
        {
            FxOptionVolatilitiesNode test = FxOptionVolatilitiesNode.of(EUR_GBP, SPOT_DATE_OFFSET, BDA, ValueType.BLACK_VOLATILITY, QUOTE_ID, Tenor.TENOR_3M, STRIKE);

            assertSerialization(test);
        }