//-------------------------------------------------------------------------
//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.FxSingleBarrierOptionTrade 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(FxSingleBarrierOptionTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
        {
            // expand the trade once for all measures and all scenarios
            ResolvedFxSingleBarrierOptionTrade 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);
            FxSingleBarrierOptionMethod method           = parameters.findParameter(typeof(FxSingleBarrierOptionMethod)).orElse(FxSingleBarrierOptionMethod.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);
        }
예제 #2
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(FxSingleBarrierOptionMethod convention, String name)
        public virtual void test_of_lookup(FxSingleBarrierOptionMethod convention, string name)
        {
            assertEquals(FxSingleBarrierOptionMethod.of(name), convention);
        }
예제 #3
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(FxSingleBarrierOptionMethod convention, String name)
        public virtual void test_toString(FxSingleBarrierOptionMethod convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }
        // calibrated sum PV01 for one scenario
        internal MultiCurrencyAmount pv01RatesCalibratedSum(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
        {
            CurrencyParameterSensitivities paramSens = parameterSensitivities(trade, ratesProvider, volatilities, method);

            return(paramSens.total().multipliedBy(ONE_BASIS_POINT));
        }
        //-------------------------------------------------------------------------
        // calculates calibrated sum PV01 for all scenarios
        internal MultiCurrencyScenarioArray pv01RatesCalibratedSum(ResolvedFxSingleBarrierOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxSingleBarrierOptionMethod method)
        {
            CurrencyPair currencyPair = trade.Product.CurrencyPair;

            return(MultiCurrencyScenarioArray.of(ratesMarketData.ScenarioCount, i => pv01RatesCalibratedSum(trade, ratesMarketData.scenario(i).ratesProvider(), optionMarketData.scenario(i).volatilities(currencyPair), method)));
        }
 // present value for one scenario
 internal MultiCurrencyAmount presentValue(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
 {
     if (method == FxSingleBarrierOptionMethod.TRINOMIAL_TREE)
     {
         return(trinomialTreePricer.presentValue(trade, ratesProvider, checkTrinomialTreeVolatilities(volatilities)));
     }
     else
     {
         return(blackPricer.presentValue(trade, ratesProvider, checkBlackVolatilities(volatilities)));
     }
 }
 //-------------------------------------------------------------------------
 /// <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(ResolvedFxSingleBarrierOptionTrade trade, RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData, FxSingleBarrierOptionMethod method)
 {
     return(calc.pv01RatesMarketQuoteBucketed(trade, ratesLookup.marketDataView(marketData), fxLookup.marketDataView(marketData), method));
 }
        // market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01RatesMarketQuoteBucketed(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
        {
            CurrencyParameterSensitivities paramSens = parameterSensitivities(trade, ratesProvider, volatilities, method);

            return(MARKET_QUOTE_SENS.sensitivity(paramSens, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
 // point sensitivity
 private CurrencyParameterSensitivities parameterSensitivities(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
 {
     if (method == FxSingleBarrierOptionMethod.TRINOMIAL_TREE)
     {
         return(trinomialTreePricer.presentValueSensitivityRates(trade, ratesProvider, checkTrinomialTreeVolatilities(volatilities)));
     }
     else
     {
         PointSensitivities pointSens = blackPricer.presentValueSensitivityRatesStickyStrike(trade, ratesProvider, checkBlackVolatilities(volatilities));
         return(ratesProvider.parameterSensitivity(pointSens));
     }
 }
 /// <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(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
 {
     return(calc.presentValue(trade, ratesProvider, volatilities, method));
 }
        //-------------------------------------------------------------------------
        // calculates market quote bucketed PV01 for all scenarios
        internal ScenarioArray <CurrencyParameterSensitivities> pv01RatesMarketQuoteBucketed(ResolvedFxSingleBarrierOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxSingleBarrierOptionMethod 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 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(ResolvedFxSingleBarrierOptionTrade trade, RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData, FxSingleBarrierOptionMethod method)
 {
     return(calc.presentValue(trade, ratesLookup.marketDataView(marketData), fxLookup.marketDataView(marketData), method));
 }
 /// <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(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
 {
     return(calc.currentCash(trade, ratesProvider.ValuationDate, 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(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
 {
     return(calc.pv01RatesMarketQuoteBucketed(trade, ratesProvider, volatilities, method));
 }
예제 #15
0
 public virtual void test_of_lookup_notFound()
 {
     assertThrows(() => FxSingleBarrierOptionMethod.of("Rubbish"), typeof(System.ArgumentException));
 }
 //-------------------------------------------------------------------------
 // calculates current cash for all scenarios
 internal CurrencyScenarioArray currentCash(ResolvedFxSingleBarrierOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxSingleBarrierOptionMethod method)
 {
     return(CurrencyScenarioArray.of(ratesMarketData.ScenarioCount, i => currentCash(trade, ratesMarketData.scenario(i).ValuationDate, method)));
 }
예제 #17
0
 public virtual void test_of_lookup_null()
 {
     assertThrows(() => FxSingleBarrierOptionMethod.of(null), typeof(System.ArgumentException));
 }
 // current cash for one scenario
 internal CurrencyAmount currentCash(ResolvedFxSingleBarrierOptionTrade trade, LocalDate valuationDate, FxSingleBarrierOptionMethod method)
 {
     if (method == FxSingleBarrierOptionMethod.TRINOMIAL_TREE)
     {
         return(trinomialTreePricer.currentCash(trade, valuationDate));
     }
     else
     {
         return(blackPricer.currentCash(trade, valuationDate));
     }
 }
        // 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.ResolvedFxSingleBarrierOptionTrade trade, com.opengamma.strata.measure.rate.RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxSingleBarrierOptionMethod method)
        private Result <object> calculate(Measure measure, ResolvedFxSingleBarrierOptionTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData, FxSingleBarrierOptionMethod method)
        {
            SingleMeasureCalculation calculator = CALCULATORS.get(measure);

            if (calculator == null)
            {
                return(Result.failure(FailureReason.UNSUPPORTED, "Unsupported measure for FxSingleBarrierOptionTrade: {}", measure));
            }
            return(Result.of(() => calculator(trade, ratesMarketData, optionMarketData, 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(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxSingleBarrierOptionMethod method)
 {
     return(calc.pv01RatesMarketQuoteSum(trade, ratesProvider, volatilities, method));
 }