//-------------------------------------------------------------------------
        public virtual void test_of_single()
        {
            IborCapFloorMarketDataLookup test = IborCapFloorMarketDataLookup.of(USD_LIBOR_3M, VOL_ID1);

            assertEquals(test.queryType(), typeof(IborCapFloorMarketDataLookup));
            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)));
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(IborCapFloorTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            IborCapFloor    product    = trade.Product;
            ISet <Currency> currencies = product.allPaymentCurrencies();
            ISet <Index>    indices    = product.allIndices();

            // use lookup to build requirements
            RatesMarketDataLookup        ratesLookup    = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements         ratesReqs      = ratesLookup.requirements(currencies, indices);
            IborCapFloorMarketDataLookup capFloorLookup = parameters.getParameter(typeof(IborCapFloorMarketDataLookup));
            FunctionRequirements         capFloorReqs   = capFloorLookup.requirements(product.CapFloorLeg.Index);

            return(ratesReqs.combinedWith(capFloorReqs));
        }
        //-------------------------------------------------------------------------
        public virtual void test_marketDataView()
        {
            IborCapFloorMarketDataLookup test            = IborCapFloorMarketDataLookup.of(USD_LIBOR_3M, VOL_ID1);
            LocalDate                      valDate       = date(2015, 6, 30);
            ScenarioMarketData             md            = new TestMarketDataMap(valDate, ImmutableMap.of(), ImmutableMap.of());
            IborCapFloorScenarioMarketData multiScenario = test.marketDataView(md);

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

            assertEquals(scenario.Lookup, test);
            assertEquals(scenario.MarketData, md.scenario(0));
            assertEquals(scenario.ValuationDate, valDate);
        }
        public virtual void test_of_map()
        {
            ImmutableMap <IborIndex, IborCapletFloorletVolatilitiesId> ids = ImmutableMap.of(USD_LIBOR_3M, VOL_ID1, USD_LIBOR_6M, VOL_ID1);
            IborCapFloorMarketDataLookup test = IborCapFloorMarketDataLookup.of(ids);

            assertEquals(test.queryType(), typeof(IborCapFloorMarketDataLookup));
            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));
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------------
//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.capfloor.IborCapFloorTrade 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(IborCapFloorTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
        {
            // expand the trade once for all measures and all scenarios
            ResolvedIborCapFloorTrade      resolved           = trade.resolve(refData);
            RatesMarketDataLookup          ratesLookup        = parameters.getParameter(typeof(RatesMarketDataLookup));
            RatesScenarioMarketData        ratesMarketData    = ratesLookup.marketDataView(scenarioMarketData);
            IborCapFloorMarketDataLookup   capFloorLookup     = parameters.getParameter(typeof(IborCapFloorMarketDataLookup));
            IborCapFloorScenarioMarketData capFloorMarketData = capFloorLookup.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, capFloorMarketData);
            }
            return(results);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private DefaultIborCapFloorMarketData(IborCapFloorMarketDataLookup lookup, com.opengamma.strata.data.MarketData marketData)
        private DefaultIborCapFloorMarketData(IborCapFloorMarketDataLookup 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 DefaultIborCapFloorMarketData of(IborCapFloorMarketDataLookup lookup, MarketData marketData)
 {
     return(new DefaultIborCapFloorMarketData(lookup, marketData));
 }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private DefaultIborCapFloorScenarioMarketData(IborCapFloorMarketDataLookup lookup, com.opengamma.strata.data.scenario.ScenarioMarketData marketData)
        private DefaultIborCapFloorScenarioMarketData(IborCapFloorMarketDataLookup lookup, ScenarioMarketData marketData)
        {
            this.lookup     = ArgChecker.notNull(lookup, "lookup");
            this.marketData = ArgChecker.notNull(marketData, "marketData");
            this.cache      = new AtomicReferenceArray <IborCapFloorMarketData>(marketData.ScenarioCount);
        }
Exemplo n.º 9
0
 //-------------------------------------------------------------------------
 /// <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 calibrated 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="capFloorLookup">  the lookup used to query the cap/floor market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value sensitivity, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray pv01RatesCalibratedSum(ResolvedIborCapFloorTrade trade, RatesMarketDataLookup ratesLookup, IborCapFloorMarketDataLookup capFloorLookup, ScenarioMarketData marketData)
 {
     return(calc.pv01RatesCalibratedSum(trade, ratesLookup.marketDataView(marketData), capFloorLookup.marketDataView(marketData)));
 }
Exemplo n.º 10
0
 //-------------------------------------------------------------------------
 /// <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="capFloorLookup">  the lookup used to query the cap/floor market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the currency exposure, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray currencyExposure(ResolvedIborCapFloorTrade trade, RatesMarketDataLookup ratesLookup, IborCapFloorMarketDataLookup capFloorLookup, ScenarioMarketData marketData)
 {
     return(calc.currencyExposure(trade, ratesLookup.marketDataView(marketData), capFloorLookup.marketDataView(marketData)));
 }
Exemplo n.º 11
0
 //-------------------------------------------------------------------------
 /// <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="capFloorLookup">  the lookup used to query the cap/floor market data </param>
 /// <returns> the present value sensitivity, one entry per scenario </returns>
 public virtual ScenarioArray <CurrencyParameterSensitivities> pv01RatesMarketQuoteBucketed(ResolvedIborCapFloorTrade trade, RatesMarketDataLookup ratesLookup, IborCapFloorMarketDataLookup capFloorLookup, ScenarioMarketData marketData)
 {
     return(calc.pv01RatesMarketQuoteBucketed(trade, ratesLookup.marketDataView(marketData), capFloorLookup.marketDataView(marketData)));
 }