예제 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_of_single()
        {
            SwaptionMarketDataLookup test = SwaptionMarketDataLookup.of(USD_LIBOR_3M, VOL_ID1);

            assertEquals(test.queryType(), typeof(SwaptionMarketDataLookup));
            assertEquals(test.VolatilityIndices, ImmutableSet.of(USD_LIBOR_3M));
            assertEquals(test.getVolatilityIds(USD_LIBOR_3M), ImmutableSet.of(VOL_ID1));
            assertThrowsIllegalArg(() => test.getVolatilityIds(GBP_LIBOR_3M));

            assertEquals(test.requirements(USD_LIBOR_3M), FunctionRequirements.builder().valueRequirements(VOL_ID1).build());
            assertEquals(test.requirements(ImmutableSet.of(USD_LIBOR_3M)), FunctionRequirements.builder().valueRequirements(VOL_ID1).build());
            assertThrowsIllegalArg(() => test.requirements(ImmutableSet.of(GBP_LIBOR_3M)));
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(SwaptionTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            Swaption  product  = trade.Product;
            Currency  currency = product.Currency;
            IborIndex index    = product.Index;

            // use lookup to build requirements
            RatesMarketDataLookup    ratesLookup    = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements     ratesReqs      = ratesLookup.requirements(currency, index);
            SwaptionMarketDataLookup swaptionLookup = parameters.getParameter(typeof(SwaptionMarketDataLookup));
            FunctionRequirements     swaptionReqs   = swaptionLookup.requirements(index);

            return(ratesReqs.combinedWith(swaptionReqs));
        }
예제 #3
0
        //-------------------------------------------------------------------------
        public virtual void test_marketDataView()
        {
            SwaptionMarketDataLookup test            = SwaptionMarketDataLookup.of(USD_LIBOR_3M, VOL_ID1);
            LocalDate                  valDate       = date(2015, 6, 30);
            ScenarioMarketData         md            = new TestMarketDataMap(valDate, ImmutableMap.of(), ImmutableMap.of());
            SwaptionScenarioMarketData multiScenario = test.marketDataView(md);

            assertEquals(multiScenario.Lookup, test);
            assertEquals(multiScenario.MarketData, md);
            assertEquals(multiScenario.ScenarioCount, 1);
            SwaptionMarketData scenario = multiScenario.scenario(0);

            assertEquals(scenario.Lookup, test);
            assertEquals(scenario.MarketData, md.scenario(0));
            assertEquals(scenario.ValuationDate, valDate);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(CmsTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            Cms             product    = trade.Product;
            ISet <Currency> currencies = product.allPaymentCurrencies();
            IborIndex       cmsIndex   = trade.Product.CmsLeg.UnderlyingIndex;
            ISet <Index>    payIndices = trade.Product.allRateIndices();
            ISet <Index>    indices    = ImmutableSet.builder <Index>().add(cmsIndex).addAll(payIndices).build();

            // use lookup to build requirements
            RatesMarketDataLookup    ratesLookup    = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements     ratesReqs      = ratesLookup.requirements(currencies, indices);
            SwaptionMarketDataLookup swaptionLookup = parameters.getParameter(typeof(SwaptionMarketDataLookup));
            FunctionRequirements     swaptionReqs   = swaptionLookup.requirements(cmsIndex);

            return(ratesReqs.combinedWith(swaptionReqs));
        }
예제 #5
0
        public virtual void test_of_map()
        {
            ImmutableMap <IborIndex, SwaptionVolatilitiesId> ids = ImmutableMap.of(USD_LIBOR_3M, VOL_ID1, USD_LIBOR_6M, VOL_ID1);
            SwaptionMarketDataLookup test = SwaptionMarketDataLookup.of(ids);

            assertEquals(test.queryType(), typeof(SwaptionMarketDataLookup));
            assertEquals(test.VolatilityIndices, ImmutableSet.of(USD_LIBOR_3M, USD_LIBOR_6M));
            assertEquals(test.getVolatilityIds(USD_LIBOR_3M), ImmutableSet.of(VOL_ID1));
            assertThrowsIllegalArg(() => test.getVolatilityIds(GBP_LIBOR_3M));

            assertEquals(test.requirements(USD_LIBOR_3M), FunctionRequirements.builder().valueRequirements(VOL_ID1).build());
            assertEquals(test.requirements(ImmutableSet.of(USD_LIBOR_3M)), FunctionRequirements.builder().valueRequirements(VOL_ID1).build());
            assertThrowsIllegalArg(() => test.requirements(ImmutableSet.of(GBP_LIBOR_3M)));

            assertEquals(test.volatilities(USD_LIBOR_3M, MOCK_MARKET_DATA), MOCK_VOLS);
            assertThrowsIllegalArg(() => test.volatilities(GBP_LIBOR_3M, MOCK_MARKET_DATA));
        }
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(com.opengamma.strata.product.swaption.SwaptionTrade trade, java.util.Set<com.opengamma.strata.calc.Measure> measures, com.opengamma.strata.calc.runner.CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData scenarioMarketData, com.opengamma.strata.basics.ReferenceData refData)
        public virtual IDictionary <Measure, Result <object> > calculate(SwaptionTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
        {
            // expand the trade once for all measures and all scenarios
            ResolvedSwaptionTrade      resolved           = trade.resolve(refData);
            RatesMarketDataLookup      ratesLookup        = parameters.getParameter(typeof(RatesMarketDataLookup));
            RatesScenarioMarketData    ratesMarketData    = ratesLookup.marketDataView(scenarioMarketData);
            SwaptionMarketDataLookup   swaptionLookup     = parameters.getParameter(typeof(SwaptionMarketDataLookup));
            SwaptionScenarioMarketData swaptionMarketData = swaptionLookup.marketDataView(scenarioMarketData);

            // loop around measures, calculating all scenarios for one measure
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = new java.util.HashMap<>();
            IDictionary <Measure, Result <object> > results = new Dictionary <Measure, Result <object> >();

            foreach (Measure measure in measures)
            {
                results[measure] = calculate(measure, resolved, ratesMarketData, swaptionMarketData);
            }
            return(results);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private DefaultSwaptionMarketData(SwaptionMarketDataLookup lookup, com.opengamma.strata.data.MarketData marketData)
        private DefaultSwaptionMarketData(SwaptionMarketDataLookup lookup, MarketData marketData)
        {
            this.lookup     = ArgChecker.notNull(lookup, "lookup");
            this.marketData = ArgChecker.notNull(marketData, "marketData");
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance based on a lookup and market data.
 /// <para>
 /// The lookup knows how to obtain the volatilities from the market data.
 /// This might involve accessing a surface or a cube.
 ///
 /// </para>
 /// </summary>
 /// <param name="lookup">  the lookup </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the rates market view </returns>
 public static DefaultSwaptionMarketData of(SwaptionMarketDataLookup lookup, MarketData marketData)
 {
     return(new DefaultSwaptionMarketData(lookup, marketData));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value across one or more scenarios.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesLookup">  the lookup used to query the market data </param>
 /// <param name="swaptionLookup">  the lookup used to query the swaption market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value, one entry per scenario </returns>
 public virtual CurrencyScenarioArray presentValue(ResolvedSwaptionTrade trade, RatesMarketDataLookup ratesLookup, SwaptionMarketDataLookup swaptionLookup, ScenarioMarketData marketData)
 {
     return(calc.presentValue(trade, ratesLookup.marketDataView(marketData), swaptionLookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates currency exposure across one or more scenarios.
 /// <para>
 /// The currency risk, expressed as the equivalent amount in each currency.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesLookup">  the lookup used to query the market data </param>
 /// <param name="swaptionLookup">  the lookup used to query the swaption market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the currency exposure, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray currencyExposure(ResolvedSwaptionTrade trade, RatesMarketDataLookup ratesLookup, SwaptionMarketDataLookup swaptionLookup, ScenarioMarketData marketData)
 {
     return(calc.currencyExposure(trade, ratesLookup.marketDataView(marketData), swaptionLookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of present value to a one basis point shift in
 /// the market quotes used to calibrate the curves.
 /// The result is provided for each affected curve and currency, bucketed by curve node.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesLookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <param name="swaptionLookup">  the lookup used to query the swaption market data </param>
 /// <returns> the present value sensitivity, one entry per scenario </returns>
 public virtual ScenarioArray <CurrencyParameterSensitivities> pv01RatesMarketQuoteBucketed(ResolvedSwaptionTrade trade, RatesMarketDataLookup ratesLookup, SwaptionMarketDataLookup swaptionLookup, ScenarioMarketData marketData)
 {
     return(calc.pv01RatesMarketQuoteBucketed(trade, ratesLookup.marketDataView(marketData), swaptionLookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of present value to a one basis point shift in
 /// the market quotes used to calibrate the curves.
 /// The result is the sum of the sensitivities of all affected curves.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesLookup">  the lookup used to query the market data </param>
 /// <param name="swaptionLookup">  the lookup used to query the swaption market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value sensitivity, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray pv01RatesMarketQuoteSum(ResolvedSwaptionTrade trade, RatesMarketDataLookup ratesLookup, SwaptionMarketDataLookup swaptionLookup, ScenarioMarketData marketData)
 {
     return(calc.pv01RatesMarketQuoteSum(trade, ratesLookup.marketDataView(marketData), swaptionLookup.marketDataView(marketData)));
 }
예제 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private DefaultSwaptionScenarioMarketData(SwaptionMarketDataLookup lookup, com.opengamma.strata.data.scenario.ScenarioMarketData marketData)
        private DefaultSwaptionScenarioMarketData(SwaptionMarketDataLookup lookup, ScenarioMarketData marketData)
        {
            this.lookup     = ArgChecker.notNull(lookup, "lookup");
            this.marketData = ArgChecker.notNull(marketData, "marketData");
            this.cache      = new AtomicReferenceArray <SwaptionMarketData>(marketData.ScenarioCount);
        }