//------------------------------------------------------------------------- //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(enabled = false) public void performance() public virtual void performance() { long start, end; int nbReps = 4; int nbTests = 100; for (int looprep = 0; looprep < nbReps; looprep++) { start = DateTimeHelper.CurrentUnixTimeMillis(); int hs = 0; for (int looptest = 0; looptest < nbTests; looptest++) { RatesProvider multicurve = CALIBRATOR.calibrate(GROUPS_IN_EUR, MARKET_QUOTES_EUR_INPUT.combinedWith(TS_LARGE_MD), REF_DATA); hs += multicurve.ValuationDate.DayOfMonth; } end = DateTimeHelper.CurrentUnixTimeMillis(); Console.WriteLine("Initial curve calibration time: " + (end - start) + " ms for " + nbTests + " calibrations. " + hs); } for (int looprep = 0; looprep < nbReps; looprep++) { start = DateTimeHelper.CurrentUnixTimeMillis(); int hs = 0; for (int looptest = 0; looptest < nbTests; looptest++) { RatesProvider multicurve1 = CALIBRATOR.calibrate(GROUPS_IN_EUR, MARKET_QUOTES_EUR_INPUT.combinedWith(TS_LARGE_MD), REF_DATA); RatesProvider multicurve2 = CALIBRATOR_SYNTHETIC.calibrate(GROUPS_SYN_EUR, multicurve1, REF_DATA); hs += multicurve2.ValuationDate.DayOfMonth; } end = DateTimeHelper.CurrentUnixTimeMillis(); Console.WriteLine("Initial + synthetic curve calibration time: " + (end - start) + " ms for " + nbTests + " calibrations. " + hs); } // Calibration time of the (initial + synthetic) curves is roughly twice as long as the initial calibration on its // own. There is almost no overhead to compute the synthetic quotes used as input to the second calibration. }
private void calibration_market_quote_sensitivity_check(System.Func <MarketData, RatesProvider> calibrator, RatesCurveGroupDefinition config, double shift, MarketData ts) { double notional = 100_000_000.0; double rate = 0.0400; SwapTrade trade = FixedIborSwapConventions.USD_FIXED_1Y_LIBOR_3M.createTrade(VAL_DATE_BD, Period.ofMonths(6), Tenor.TENOR_7Y, BuySell.BUY, notional, rate, REF_DATA); RatesProvider result = CALIBRATOR.calibrate(config, ALL_QUOTES_BD.combinedWith(ts), REF_DATA); ResolvedSwap product = trade.Product.resolve(REF_DATA); PointSensitivityBuilder pts = SWAP_PRICER.presentValueSensitivity(product, result); CurrencyParameterSensitivities ps = result.parameterSensitivity(pts.build()); CurrencyParameterSensitivities mqs = MQC.sensitivity(ps, result); double pv0 = SWAP_PRICER.presentValue(product, result).getAmount(USD).Amount; double[] mqsDscComputed = mqs.getSensitivity(DSCON_CURVE_NAME, USD).Sensitivity.toArray(); for (int i = 0; i < DSC_NB_NODES; i++) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES_BD.getValues()); IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES_BD.Values); map[QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i]))] = DSC_MARKET_QUOTES[i] + shift; ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE_BD, map); RatesProvider rpShifted = calibrator(marketData.combinedWith(ts)); double pvS = SWAP_PRICER.presentValue(product, rpShifted).getAmount(USD).Amount; assertEquals(mqsDscComputed[i], (pvS - pv0) / shift, TOLERANCE_PV_DELTA); } double[] mqsFwd3Computed = mqs.getSensitivity(FWD3_CURVE_NAME, USD).Sensitivity.toArray(); for (int i = 0; i < FWD3_NB_NODES; i++) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES_BD.getValues()); IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES_BD.Values); map[QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i]))] = FWD3_MARKET_QUOTES[i] + shift; ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE_BD, map); RatesProvider rpShifted = calibrator(marketData.combinedWith(ts)); double pvS = SWAP_PRICER.presentValue(product, rpShifted).getAmount(USD).Amount; assertEquals(mqsFwd3Computed[i], (pvS - pv0) / shift, TOLERANCE_PV_DELTA); } }
public virtual void calibration_present_value_oneGroup_fixing() { RatesProvider result = CALIBRATOR.calibrate(CURVE_GROUP_CONFIG, ALL_QUOTES_BD.combinedWith(TS_BD_LIBOR3M), REF_DATA); assertResult(result); }