//-------------------------------------------------------------------------
//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.
        }
Exemple #2
0
        //-------------------------------------------------------------------------
        public virtual void calibration_present_value()
        {
            RatesProvider result2 = CALIBRATOR.calibrate(CURVE_GROUP_DEFN, ALL_QUOTES, REF_DATA);

            // Test PV
            CurveNode[]           fwd3Nodes  = CURVES_NODES[0][0];
            IList <ResolvedTrade> fwd3Trades = new List <ResolvedTrade>();

            for (int i = 0; i < fwd3Nodes.Length; i++)
            {
                fwd3Trades.Add(fwd3Nodes[i].resolvedTrade(1d, ALL_QUOTES, REF_DATA));
            }
            // Fixing
            CurrencyAmount pvFixing2 = FIXING_PRICER.presentValue(((ResolvedIborFixingDepositTrade)fwd3Trades[0]).Product, result2);

            assertEquals(pvFixing2.Amount, 0.0, TOLERANCE_PV);
            // FRA
            for (int i = 0; i < FWD3_NB_FRA_NODES; i++)
            {
                CurrencyAmount pvFra2 = FRA_PRICER.presentValue(((ResolvedFraTrade)fwd3Trades[i + 1]), result2);
                assertEquals(pvFra2.Amount, 0.0, TOLERANCE_PV);
            }
            // IRS
            for (int i = 0; i < FWD3_NB_IRS_NODES; i++)
            {
                MultiCurrencyAmount pvIrs2 = SWAP_PRICER.presentValue(((ResolvedSwapTrade)fwd3Trades[i + 1 + FWD3_NB_FRA_NODES]).Product, result2);
                assertEquals(pvIrs2.getAmount(USD).Amount, 0.0, TOLERANCE_PV);
            }
        }
        //-------------------------------------------------------------------------
        public virtual void calibration_test()
        {
            RatesProvider result2 = CALIBRATOR.calibrate(CURVE_GROUP_DEFN, ALL_QUOTES, REF_DATA);

            // pv test
            CurveNode[]           fwd3Nodes  = CURVES_NODES[0][0];
            IList <ResolvedTrade> fwd3Trades = new List <ResolvedTrade>();

            for (int i = 0; i < fwd3Nodes.Length; i++)
            {
                fwd3Trades.Add(fwd3Nodes[i].resolvedTrade(1d, ALL_QUOTES, REF_DATA));
            }
            for (int i = 0; i < FWD6_NB_NODES; i++)
            {
                MultiCurrencyAmount pvIrs2 = SWAP_PRICER.presentValue(((ResolvedSwapTrade)fwd3Trades[i]).Product, result2);
                assertEquals(pvIrs2.getAmount(GBP).Amount, 0.0, TOLERANCE_PV);
            }
            // regression test for curve
            DiscountFactors dsc     = result2.discountFactors(GBP);
            double          prevDsc = 0d;

            for (int i = 0; i < 121; ++i)
            {
                double time   = ((double)i);
                double curDsc = dsc.discountFactor(time);
                if (i > 59)
                {
                    double fwd = prevDsc / curDsc - 1d;
                    assertEquals(fwd, 0.042, 2d * ONE_BP);
                }
                assertEquals(curDsc, DSC_EXP.get(i), ONE_PC);
                prevDsc = curDsc;
            }
        }
Exemple #4
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calibrates synthetic curves from the configuration of the new curves and an existing rates provider.
        /// </summary>
        /// <param name="group">  the curve group definition for the synthetic curves and instruments </param>
        /// <param name="inputProvider">  the input rates provider </param>
        /// <param name="refData">  the reference data, used to resolve the trades </param>
        /// <returns> the rates provider </returns>
        public ImmutableRatesProvider calibrate(RatesCurveGroupDefinition group, RatesProvider inputProvider, ReferenceData refData)
        {
            // Computes the synthetic market quotes
            MarketData marketQuotesSy = marketData(group, inputProvider, refData);

            // Calibrate to the synthetic instrument with the synthetic quotes
            return(calibrator.calibrate(group, marketQuotesSy, refData));
        }
Exemple #5
0
        //-------------------------------------------------------------------------
        public virtual void calibration_present_value()
        {
            RatesProvider result = CALIBRATOR.calibrate(CURVE_GROUP_CONFIG, ALL_QUOTES, REF_DATA);

            ImmutableList <CurveDefinition> definitions = CURVE_GROUP_CONFIG.CurveDefinitions;
            // Test PV Dsc
            ImmutableList <CurveNode> dscNodes  = definitions.get(0).Nodes;
            IList <ResolvedTrade>     dscTrades = new List <ResolvedTrade>();

            for (int i = 0; i < dscNodes.size(); i++)
            {
                dscTrades.Add(dscNodes.get(i).resolvedTrade(1d, ALL_QUOTES, REF_DATA));
            }
            // OIS
            for (int i = 0; i < DSC_NB_OIS_NODES; i++)
            {
                MultiCurrencyAmount pvIrs = SWAP_PRICER.presentValue(((ResolvedSwapTrade)dscTrades[i]).Product, result);
                assertEquals(pvIrs.getAmount(EUR).Amount, 0.0, TOLERANCE_PV);
            }
            // Test PV Fwd3
            ImmutableList <CurveNode> fwd3Nodes  = definitions.get(1).Nodes;
            IList <ResolvedTrade>     fwd3Trades = new List <ResolvedTrade>();

            for (int i = 0; i < fwd3Nodes.size(); i++)
            {
                fwd3Trades.Add(fwd3Nodes.get(i).resolvedTrade(1d, ALL_QUOTES, REF_DATA));
            }
            // IRS
            for (int i = 0; i < FWD3_NB_IRS_NODES; i++)
            {
                MultiCurrencyAmount pvIrs = SWAP_PRICER.presentValue(((ResolvedSwapTrade)fwd3Trades[i]).Product, result);
                assertEquals(pvIrs.getAmount(EUR).Amount, 0.0, TOLERANCE_PV);
            }
            // Test PV Fwd6
            ImmutableList <CurveNode> fwd6Nodes  = definitions.get(2).Nodes;
            IList <ResolvedTrade>     fwd6Trades = new List <ResolvedTrade>();

            for (int i = 0; i < fwd6Nodes.size(); i++)
            {
                fwd6Trades.Add(fwd6Nodes.get(i).resolvedTrade(1d, ALL_QUOTES, REF_DATA));
            }
            // IRS
            for (int i = 0; i < FWD6_NB_IRS_NODES; i++)
            {
                MultiCurrencyAmount pvIrs = SWAP_PRICER.presentValue(((ResolvedSwapTrade)fwd6Trades[i]).Product, result);
                assertEquals(pvIrs.getAmount(EUR).Amount, 0.0, TOLERANCE_PV);
            }
        }
Exemple #6
0
        public static RatesProvider calibrateEurStandard(LocalDate valuationDate, double[] dscOisQuotes, Period[] dscOisTenors, double fwd3FixingQuote, double[] fwd3FraQuotes, double[] fwd3IrsQuotes, Period[] fwd3FraTenors, Period[] fwd3IrsTenors, double fwd6FixingQuote, double[] fwd6FraQuotes, double[] fwd6IrsQuotes, Period[] fwd6FraTenors, Period[] fwd6IrsTenors)
        {
            /* Curve Discounting/EUR-EONIA */
            string[] dscIdValues = CalibrationEurStandard.dscIdValues(dscOisTenors);
            /* Curve EUR-EURIBOR-3M */
            double[] fwd3MarketQuotes = fwdMarketQuotes(fwd3FixingQuote, fwd3FraQuotes, fwd3IrsQuotes);
            string[] fwd3IdValues     = fwdIdValue(3, fwd3FixingQuote, fwd3FraQuotes, fwd3IrsQuotes, fwd3FraTenors, fwd3IrsTenors);
            /* Curve EUR-EURIBOR-6M */
            double[] fwd6MarketQuotes = fwdMarketQuotes(fwd6FixingQuote, fwd6FraQuotes, fwd6IrsQuotes);
            string[] fwd6IdValues     = fwdIdValue(6, fwd6FixingQuote, fwd6FraQuotes, fwd6IrsQuotes, fwd6FraTenors, fwd6IrsTenors);
            /* All quotes for the curve calibration */
            MarketData allQuotes = CalibrationEurStandard.allQuotes(valuationDate, dscOisQuotes, dscIdValues, fwd3MarketQuotes, fwd3IdValues, fwd6MarketQuotes, fwd6IdValues);
            /* All nodes by groups. */
            RatesCurveGroupDefinition config = CalibrationEurStandard.config(dscOisTenors, dscIdValues, fwd3FraTenors, fwd3IrsTenors, fwd3IdValues, fwd6FraTenors, fwd6IrsTenors, fwd6IdValues);

            /* Results */
            return(CALIBRATOR.calibrate(config, allQuotes, REF_DATA));
        }
        public virtual void check_pv_with_measures()
        {
            ImmutableRatesProvider multicurve = CALIBRATOR.calibrate(GROUP_DEFINITION, MARKET_QUOTES, REF_DATA);
            // the trades used for calibration
            IList <ResolvedTrade>           trades      = new List <ResolvedTrade>();
            ImmutableList <CurveDefinition> curveGroups = GROUP_DEFINITION.CurveDefinitions;

            foreach (CurveDefinition entry in curveGroups)
            {
                ImmutableList <CurveNode> nodes = entry.Nodes;
                foreach (CurveNode node in nodes)
                {
                    trades.Add(node.resolvedTrade(1d, MARKET_QUOTES, REF_DATA));
                }
            }
            // Check PV = 0
            foreach (ResolvedTrade trade in trades)
            {
                double pv = PV_MEASURES.value(trade, multicurve);
                assertEquals(pv, 0.0, TOLERANCE_PV);
            }
        }
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void calibration_present_value_oneGroup_no_fixing() throws java.io.IOException
        public virtual void calibration_present_value_oneGroup_no_fixing()
        {
            RatesProvider result = CALIBRATOR.calibrate(CURVE_GROUP_CONFIG, ALL_QUOTES_BD, REF_DATA);

            assertResult(result);
        }
Exemple #9
0
        //-------------------------------------------------------------------------
        public virtual void calibration_present_value_oneGroup()
        {
            RatesProvider result = CALIBRATOR.calibrate(CURVE_GROUP_CONFIG, ALL_QUOTES, REF_DATA);

            assertPresentValue(result);
        }