示例#1
0
        // market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedFraTrade trade, RatesProvider ratesProvider)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
        //-----------------------------------------------------------------------------------------------------------

        private void checkFraPvIsZero(FraCurveNode node, RatesProvider ratesProvider, MarketData marketDataMap)
        {
            ResolvedFraTrade trade          = node.resolvedTrade(1d, marketDataMap, REF_DATA);
            CurrencyAmount   currencyAmount = DiscountingFraTradePricer.DEFAULT.presentValue(trade, ratesProvider);
            double           pv             = currencyAmount.Amount;

            assertThat(pv).isCloseTo(0, offset(PV_TOLERANCE));
        }
示例#3
0
        // calculates the sensitivity
        private CurrencyParameterSensitivity calculateCurveSensitivity(ResolvedFraTrade trade, RatesMarketData marketData, CurveId curveId, Curve bumpedCurve)
        {
            MarketData                     bumpedMarketData    = marketData.MarketData.withValue(curveId, bumpedCurve);
            RatesProvider                  bumpedRatesProvider = marketData.withMarketData(bumpedMarketData).ratesProvider();
            PointSensitivities             pointSensitivities  = tradePricer.presentValueSensitivity(trade, bumpedRatesProvider);
            CurrencyParameterSensitivities paramSensitivities  = bumpedRatesProvider.parameterSensitivity(pointSensitivities);

            return(Iterables.getOnlyElement(paramSensitivities.Sensitivities));
        }
        // 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.fra.ResolvedFraTrade trade, com.opengamma.strata.measure.rate.RatesScenarioMarketData marketData)
        private Result <object> calculate(Measure measure, ResolvedFraTrade trade, RatesScenarioMarketData marketData)
        {
            SingleMeasureCalculation calculator = CALCULATORS.get(measure);

            if (calculator == null)
            {
                return(Result.failure(FailureReason.UNSUPPORTED, "Unsupported measure for FraTrade: {}", measure));
            }
            return(Result.of(() => calculator(trade, marketData)));
        }
        //-------------------------------------------------------------------------
//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.fra.FraTrade 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(FraTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
        {
            // resolve the trade once for all measures and all scenarios
            ResolvedFraTrade resolved = trade.resolve(refData);

            // use lookup to query market data
            RatesMarketDataLookup   ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup));
            RatesScenarioMarketData marketData  = ratesLookup.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, marketData);
            }
            return(results);
        }
示例#6
0
        // semi-parallel gamma PV01 for one scenario
        private CurrencyParameterSensitivities pv01SemiParallelGammaBucketed(ResolvedFraTrade trade, RatesMarketData marketData)
        {
            // find the curve identifiers and resolve to a single curve
            Currency         currency = trade.Product.Currency;
            ISet <IborIndex> indices  = trade.Product.allIndices();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableSet<com.opengamma.strata.data.MarketDataId<?>> discountIds = marketData.getLookup().getDiscountMarketDataIds(currency);
            ImmutableSet <MarketDataId <object> > discountIds = marketData.Lookup.getDiscountMarketDataIds(currency);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableSet<com.opengamma.strata.data.MarketDataId<?>> forwardIds = indices.stream().flatMap(idx -> marketData.getLookup().getForwardMarketDataIds(idx).stream()).collect(toImmutableSet());
            ImmutableSet <MarketDataId <object> > forwardIds = indices.stream().flatMap(idx => marketData.Lookup.getForwardMarketDataIds(idx).stream()).collect(toImmutableSet());
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Set<com.opengamma.strata.data.MarketDataId<?>> allIds = com.google.common.collect.Sets.union(discountIds, forwardIds);
            ISet <MarketDataId <object> > allIds = Sets.union(discountIds, forwardIds);

            if (allIds.Count != 1)
            {
                throw new System.ArgumentException(Messages.format("Implementation only supports a single curve, but lookup refers to more than one: {}", allIds));
            }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> singleId = allIds.iterator().next();
            MarketDataId <object> singleId = allIds.GetEnumerator().next();

            if (!(singleId is CurveId))
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                throw new System.ArgumentException(Messages.format("Implementation only supports a single curve, but lookup does not refer to a curve: {} {}", singleId.GetType().FullName, singleId));
            }
            CurveId curveId = (CurveId)singleId;
            Curve   curve   = marketData.MarketData.getValue(curveId);

            // calculate gamma
            CurrencyParameterSensitivity gamma = CurveGammaCalculator.DEFAULT.calculateSemiParallelGamma(curve, currency, c => calculateCurveSensitivity(trade, marketData, curveId, c));

            return(CurrencyParameterSensitivities.of(gamma).multipliedBy(ONE_BASIS_POINT * ONE_BASIS_POINT));
        }
示例#7
0
 // currency exposure for one scenario
 internal MultiCurrencyAmount currencyExposure(ResolvedFraTrade trade, RatesProvider ratesProvider)
 {
     return(tradePricer.currencyExposure(trade, ratesProvider));
 }
示例#8
0
 //-------------------------------------------------------------------------
 // calculates currency exposure for all scenarios
 internal MultiCurrencyScenarioArray currencyExposure(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(MultiCurrencyScenarioArray.of(marketData.ScenarioCount, i => currencyExposure(trade, marketData.scenario(i).ratesProvider())));
 }
示例#9
0
 // cash flows for one scenario
 internal CashFlows cashFlows(ResolvedFraTrade trade, RatesProvider ratesProvider)
 {
     return(tradePricer.cashFlows(trade, ratesProvider));
 }
示例#10
0
 //-------------------------------------------------------------------------
 // calculates cash flows for all scenarios
 internal ScenarioArray <CashFlows> cashFlows(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => cashFlows(trade, marketData.scenario(i).ratesProvider())));
 }
示例#11
0
 // par spread for one scenario
 internal double parSpread(ResolvedFraTrade trade, RatesProvider ratesProvider)
 {
     return(tradePricer.parSpread(trade, ratesProvider));
 }
示例#12
0
 //-------------------------------------------------------------------------
 // calculates par spread for all scenarios
 internal DoubleScenarioArray parSpread(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(DoubleScenarioArray.of(marketData.ScenarioCount, i => parSpread(trade, marketData.scenario(i).ratesProvider())));
 }
示例#13
0
 // explain present value for one scenario
 internal ExplainMap explainPresentValue(ResolvedFraTrade trade, RatesProvider ratesProvider)
 {
     return(tradePricer.explainPresentValue(trade, ratesProvider));
 }
示例#14
0
 // present value for one scenario
 internal CurrencyAmount presentValue(ResolvedFraTrade trade, RatesProvider ratesProvider)
 {
     return(tradePricer.presentValue(trade, ratesProvider));
 }
示例#15
0
 // current cash for one scenario
 internal CurrencyAmount currentCash(ResolvedFraTrade trade, RatesProvider ratesProvider)
 {
     return(tradePricer.currentCash(trade, ratesProvider));
 }
示例#16
0
 //-------------------------------------------------------------------------
 // calculates semi-parallel gamma PV01 for all scenarios
 internal ScenarioArray <CurrencyParameterSensitivities> pv01SemiParallelGammaBucketed(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => pv01SemiParallelGammaBucketed(trade, marketData.scenario(i))));
 }
示例#17
0
        // calibrated bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01CalibratedBucketed(ResolvedFraTrade trade, RatesProvider ratesProvider)
        {
            PointSensitivities pointSensitivity = tradePricer.presentValueSensitivity(trade, ratesProvider);

            return(ratesProvider.parameterSensitivity(pointSensitivity).multipliedBy(ONE_BASIS_POINT));
        }
示例#18
0
 //-------------------------------------------------------------------------
 // calculates market quote sum PV01 for all scenarios
 internal MultiCurrencyScenarioArray pv01MarketQuoteSum(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(MultiCurrencyScenarioArray.of(marketData.ScenarioCount, i => pv01MarketQuoteSum(trade, marketData.scenario(i).ratesProvider())));
 }
示例#19
0
 //-------------------------------------------------------------------------
 // calculates present value for all scenarios
 internal CurrencyScenarioArray presentValue(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(CurrencyScenarioArray.of(marketData.ScenarioCount, i => presentValue(trade, marketData.scenario(i).ratesProvider())));
 }
示例#20
0
 //-------------------------------------------------------------------------
 // calculates single-node gamma PV01 for all scenarios
 internal ScenarioArray <CurrencyParameterSensitivities> pv01SingleNodeGammaBucketed(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => pv01SingleNodeGammaBucketed(trade, marketData.scenario(i).ratesProvider())));
 }
示例#21
0
 //-------------------------------------------------------------------------
 // calculates explain present value for all scenarios
 internal ScenarioArray <ExplainMap> explainPresentValue(ResolvedFraTrade trade, RatesScenarioMarketData marketData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => explainPresentValue(trade, marketData.scenario(i).ratesProvider())));
 }
示例#22
0
        // single-node gamma PV01 for one scenario
        private CurrencyParameterSensitivities pv01SingleNodeGammaBucketed(ResolvedFraTrade trade, RatesProvider ratesProvider)
        {
            CrossGammaParameterSensitivities crossGamma = CROSS_GAMMA.calculateCrossGammaIntraCurve(ratesProvider, p => p.parameterSensitivity(tradePricer.presentValueSensitivity(trade, p)));

            return(crossGamma.diagonal().multipliedBy(ONE_BASIS_POINT * ONE_BASIS_POINT));
        }