//-------------------------------------------------------------------------
//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.fxopt.FxVanillaOptionTrade 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(FxVanillaOptionTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
        {
            // expand the trade once for all measures and all scenarios
            ResolvedFxVanillaOptionTrade resolved         = trade.resolve(refData);
            RatesMarketDataLookup        ratesLookup      = parameters.getParameter(typeof(RatesMarketDataLookup));
            RatesScenarioMarketData      ratesMarketData  = ratesLookup.marketDataView(scenarioMarketData);
            FxOptionMarketDataLookup     optionLookup     = parameters.getParameter(typeof(FxOptionMarketDataLookup));
            FxOptionScenarioMarketData   optionMarketData = optionLookup.marketDataView(scenarioMarketData);
            FxVanillaOptionMethod        method           = parameters.findParameter(typeof(FxVanillaOptionMethod)).orElse(FxVanillaOptionMethod.BLACK);

            // 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, optionMarketData, method);
            }
            return(results);
        }
 //-------------------------------------------------------------------------
 // calculates current cash for all scenarios
 internal CurrencyScenarioArray currentCash(ResolvedFxVanillaOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxVanillaOptionMethod method)
 {
     return(CurrencyScenarioArray.of(ratesMarketData.ScenarioCount, i => currentCash(trade, ratesMarketData.scenario(i).ValuationDate, method)));
 }
        // point sensitivity
        private CurrencyParameterSensitivities pointSensitivity(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
        {
            PointSensitivities pointSens;

            if (method == FxVanillaOptionMethod.VANNA_VOLGA)
            {
                pointSens = vannaVolgaPricer.presentValueSensitivityRatesStickyStrike(trade, ratesProvider, checkVannaVolgaVolatilities(volatilities));
            }
            else
            {
                pointSens = blackPricer.presentValueSensitivityRatesStickyStrike(trade, ratesProvider, checkBlackVolatilities(volatilities));
            }
            return(ratesProvider.parameterSensitivity(pointSens));
        }
        // market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01RatesMarketQuoteBucketed(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
        {
            CurrencyParameterSensitivities paramSens = pointSensitivity(trade, ratesProvider, volatilities, method);

            return(MARKET_QUOTE_SENS.sensitivity(paramSens, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
        //-------------------------------------------------------------------------
        // calculates market quote bucketed PV01 for all scenarios
        internal ScenarioArray <CurrencyParameterSensitivities> pv01RatesMarketQuoteBucketed(ResolvedFxVanillaOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxVanillaOptionMethod method)
        {
            CurrencyPair currencyPair = trade.Product.CurrencyPair;

            return(ScenarioArray.of(ratesMarketData.ScenarioCount, i => pv01RatesMarketQuoteBucketed(trade, ratesMarketData.scenario(i).ratesProvider(), optionMarketData.scenario(i).volatilities(currencyPair), method)));
        }
 /// <summary>
 /// Calculates present value for a single set of market data.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the market data </param>
 /// <param name="volatilities">  the option volatilities </param>
 /// <param name="method">  the pricing method </param>
 /// <returns> the present value </returns>
 public virtual MultiCurrencyAmount presentValue(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
 {
     return(calc.presentValue(trade, ratesProvider, volatilities, method));
 }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_of_lookup(FxVanillaOptionMethod convention, String name)
        public virtual void test_of_lookup(FxVanillaOptionMethod convention, string name)
        {
            assertEquals(FxVanillaOptionMethod.of(name), convention);
        }
        //-------------------------------------------------------------------------
        // calculates calibrated sum PV01 for all scenarios
        internal MultiCurrencyScenarioArray pv01RatesCalibratedSum(ResolvedFxVanillaOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxVanillaOptionMethod method)
        {
            CurrencyPair currencyPair = trade.Product.CurrencyPair;

            return(MultiCurrencyScenarioArray.of(ratesMarketData.ScenarioCount, i => pv01RatesCalibratedSum(trade, ratesMarketData.scenario(i).ratesProvider(), optionMarketData.scenario(i).volatilities(currencyPair), method)));
        }
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <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="ratesProvider">  the market data </param>
 /// <param name="volatilities">  the option volatilities </param>
 /// <param name="method">  the pricing method </param>
 /// <returns> the present value sensitivity </returns>
 public virtual CurrencyParameterSensitivities pv01RatesMarketQuoteBucketed(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
 {
     return(calc.pv01RatesMarketQuoteBucketed(trade, ratesProvider, volatilities, method));
 }
 //-------------------------------------------------------------------------
 /// <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="fxLookup">  the lookup used to query the option market data </param>
 /// <param name="method">  the pricing method </param>
 /// <returns> the present value sensitivity, one entry per scenario </returns>
 public virtual ScenarioArray <CurrencyParameterSensitivities> pv01RatesMarketQuoteBucketed(ResolvedFxVanillaOptionTrade trade, RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData, FxVanillaOptionMethod method)
 {
     return(calc.pv01RatesMarketQuoteBucketed(trade, ratesLookup.marketDataView(marketData), fxLookup.marketDataView(marketData), method));
 }
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <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="ratesProvider">  the market data </param>
 /// <param name="volatilities">  the option volatilities </param>
 /// <param name="method">  the pricing method </param>
 /// <returns> the present value sensitivity </returns>
 public virtual MultiCurrencyAmount pv01RatesMarketQuoteSum(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
 {
     return(calc.pv01RatesMarketQuoteSum(trade, ratesProvider, volatilities, method));
 }
        // calculate one measure
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: private com.opengamma.strata.collect.result.Result<?> calculate(com.opengamma.strata.calc.Measure measure, com.opengamma.strata.product.fxopt.ResolvedFxVanillaOptionTrade trade, com.opengamma.strata.measure.rate.RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxVanillaOptionMethod method)
        private Result <object> calculate(Measure measure, ResolvedFxVanillaOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxVanillaOptionMethod method)
        {
            SingleMeasureCalculation calculator = CALCULATORS.get(measure);

            if (calculator == null)
            {
                return(Result.failure(FailureReason.UNSUPPORTED, "Unsupported measure for FxVanillaOptionTrade: {}", measure));
            }
            return(Result.of(() => calculator(trade, ratesMarketData, optionMarketData, method)));
        }
コード例 #13
0
 public virtual void test_of_lookup_null()
 {
     assertThrows(() => FxVanillaOptionMethod.of(null), typeof(System.ArgumentException));
 }
コード例 #14
0
 public virtual void test_of_lookup_notFound()
 {
     assertThrows(() => FxVanillaOptionMethod.of("Rubbish"), typeof(System.ArgumentException));
 }
 // current cash for one scenario
 internal CurrencyAmount currentCash(ResolvedFxVanillaOptionTrade trade, LocalDate valuationDate, FxVanillaOptionMethod method)
 {
     if (method == FxVanillaOptionMethod.VANNA_VOLGA)
     {
         return(vannaVolgaPricer.currentCash(trade, valuationDate));
     }
     else
     {
         return(blackPricer.currentCash(trade, valuationDate));
     }
 }
 /// <summary>
 /// Calculates current cash for a single set of market data.
 /// <para>
 /// The sum of all cash flows paid on the valuation date.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the market data </param>
 /// <param name="volatilities">  the option volatilities </param>
 /// <param name="method">  the pricing method </param>
 /// <returns> the current cash </returns>
 public virtual CurrencyAmount currentCash(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
 {
     return(calc.currentCash(trade, ratesProvider.ValuationDate, method));
 }
 // present value for one scenario
 internal MultiCurrencyAmount presentValue(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
 {
     if (method == FxVanillaOptionMethod.VANNA_VOLGA)
     {
         return(vannaVolgaPricer.presentValue(trade, ratesProvider, checkVannaVolgaVolatilities(volatilities)));
     }
     else
     {
         return(blackPricer.presentValue(trade, ratesProvider, checkBlackVolatilities(volatilities)));
     }
 }
 //-------------------------------------------------------------------------
 /// <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="fxLookup">  the lookup used to query the option market data </param>
 /// <param name="marketData">  the market data </param>
 /// <param name="method">  the pricing method </param>
 /// <returns> the present value, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray presentValue(ResolvedFxVanillaOptionTrade trade, RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData, FxVanillaOptionMethod method)
 {
     return(calc.presentValue(trade, ratesLookup.marketDataView(marketData), fxLookup.marketDataView(marketData), method));
 }
        // calibrated sum PV01 for one scenario
        internal MultiCurrencyAmount pv01RatesCalibratedSum(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
        {
            CurrencyParameterSensitivities paramSens = pointSensitivity(trade, ratesProvider, volatilities, method);

            return(paramSens.total().multipliedBy(ONE_BASIS_POINT));
        }
コード例 #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_toString(FxVanillaOptionMethod convention, String name)
        public virtual void test_toString(FxVanillaOptionMethod convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }