private ResolvedTradeParameterMetadata(ResolvedTrade trade, string label)
 {
     JodaBeanUtils.notNull(trade, "trade");
     JodaBeanUtils.notEmpty(label, "label");
     this.trade = trade;
     this.label = label;
 }
        //-------------------------------------------------------------------------
        // Check market data computation
        public virtual void market_data()
        {
            RatesCurveGroupDefinition group             = GROUPS_SYN_EUR;
            RatesProvider             multicurveTsLarge = MULTICURVE_INPUT_EUR_TSEMPTY.toBuilder().timeSeries(TS_LARGE).build();
            MarketData madTsEmpty = CALIBRATOR_SYNTHETIC.marketData(group, MULTICURVE_INPUT_EUR_TSEMPTY, REF_DATA);
            MarketData madTsLarge = CALIBRATOR_SYNTHETIC.marketData(group, multicurveTsLarge, REF_DATA);

            assertEquals(madTsEmpty.ValuationDate, VALUATION_DATE);
            foreach (CurveDefinition entry in group.CurveDefinitions)
            {
                ImmutableList <CurveNode> nodes = entry.Nodes;
                foreach (CurveNode node in nodes)
                {
                    ResolvedTrade tradeTsEmpty = node.resolvedTrade(1d, madTsEmpty, REF_DATA);
                    double        mqTsEmpty    = MQ_MEASURES.value(tradeTsEmpty, MULTICURVE_INPUT_EUR_TSEMPTY);
                    assertEquals(mqTsEmpty, (double?)madTsEmpty.getValue(node.requirements().GetEnumerator().next()), TOLERANCE_MQ);
                    ResolvedTrade tradeTsLarge = node.resolvedTrade(1d, madTsLarge, REF_DATA);
                    double        mqTsLarge    = MQ_MEASURES.value(tradeTsLarge, multicurveTsLarge);
                    assertEquals(mqTsLarge, (double?)madTsLarge.getValue(node.requirements().GetEnumerator().next()), TOLERANCE_MQ);
                    // Market Quote for Fixed v ibor swaps should have changed with the fixing
                    if ((tradeTsLarge is ResolvedSwapTrade) && (((ResolvedSwapTrade)tradeTsLarge)).Product.getLegs(SwapLegType.IBOR).size() == 1)
                    {
                        assertTrue(Math.Abs(mqTsEmpty - mqTsLarge) > TOLERANCE_MQ);
                    }
                }
            }
            assertEquals(madTsEmpty.TimeSeriesIds, ImmutableSet.of());
            assertEquals(madTsLarge.TimeSeriesIds, ImmutableSet.of(IndexQuoteId.of(EUR_EURIBOR_3M), IndexQuoteId.of(EUR_EURIBOR_6M)));
        }
Esempio n. 3
0
        // extract CDS index trades from credit curve
        private ImmutableList <ResolvedCdsIndexTrade> getBucketCdsIndex(ResolvedCdsIndex product, CreditRatesProvider ratesProvider)
        {
            CreditDiscountFactors creditCurve = ratesProvider.survivalProbabilities(product.CdsIndexId, product.Currency).SurvivalProbabilities;
            int nNodes = creditCurve.ParameterCount;

            ImmutableList.Builder <ResolvedCdsIndexTrade> builder = ImmutableList.builder();
            for (int i = 0; i < nNodes; ++i)
            {
                ParameterMetadata metadata = creditCurve.getParameterMetadata(i);
                ArgChecker.isTrue(metadata is ResolvedTradeParameterMetadata, "ParameterMetadata of credit curve must be ResolvedTradeParameterMetadata");
                ResolvedTradeParameterMetadata tradeMetadata = (ResolvedTradeParameterMetadata)metadata;
                ResolvedTrade trade = tradeMetadata.Trade;
                ArgChecker.isTrue(trade is ResolvedCdsIndexTrade, "ResolvedTrade must be ResolvedCdsIndexTrade");
                builder.add((ResolvedCdsIndexTrade)trade);
            }
            return(builder.build());
        }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 110621028:         // trade
                    this.trade_Renamed = (ResolvedTrade)newValue;
                    break;

                case 102727412:         // label
                    this.label_Renamed = (string)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        // Check synthetic calibration in the case of existing time-series with fixing on the valuation date
        public virtual void calibrate_ts_vd()
        {
            SyntheticRatesCurveCalibrator calibratorDefault = SyntheticRatesCurveCalibrator.standard();
            MarketData    mad           = calibratorDefault.marketData(GROUPS_SYN_EUR, MULTICURVE_INPUT_EUR_TSLARGE, REF_DATA);
            RatesProvider multicurveSyn = CALIBRATOR_SYNTHETIC.calibrate(GROUPS_SYN_EUR, MULTICURVE_INPUT_EUR_TSLARGE, REF_DATA);

            foreach (CurveDefinition entry in GROUPS_SYN_EUR.CurveDefinitions)
            {
                ImmutableList <CurveNode> nodes = entry.Nodes;
                foreach (CurveNode node in nodes)
                {
                    ResolvedTrade trade = node.resolvedTrade(1d, mad, REF_DATA);
                    double        mqIn  = MQ_MEASURES.value(trade, MULTICURVE_INPUT_EUR_TSLARGE);
                    double        mqSy  = MQ_MEASURES.value(trade, multicurveSyn);
                    assertEquals(mqIn, mqSy, TOLERANCE_MQ);
                }
            }
        }
        // Check synthetic calibration in case no time-series is present
        public virtual void calibrate_ts_empty()
        {
            MarketData    mad           = CALIBRATOR_SYNTHETIC.marketData(GROUPS_SYN_EUR, MULTICURVE_INPUT_EUR_TSEMPTY, REF_DATA);
            RatesProvider multicurveSyn = CALIBRATOR_SYNTHETIC.calibrate(GROUPS_SYN_EUR, MULTICURVE_INPUT_EUR_TSEMPTY, REF_DATA);

            foreach (CurveDefinition entry in GROUPS_SYN_EUR.CurveDefinitions)
            {
                ImmutableList <CurveNode> nodes = entry.Nodes;
                foreach (CurveNode node in nodes)
                {
                    ResolvedTrade trade = node.resolvedTrade(1d, mad, REF_DATA);
                    double        mqIn  = MQ_MEASURES.value(trade, MULTICURVE_INPUT_EUR_TSEMPTY);
                    double        mqSy  = MQ_MEASURES.value(trade, multicurveSyn);
                    assertEquals(mqIn, mqSy, TOLERANCE_MQ);
                }
            }
            assertEquals(mad.TimeSeriesIds, ImmutableSet.of());
        }
Esempio n. 7
0
        /// <summary>
        /// Constructs the synthetic market data from an existing rates provider and the configuration of the new curves.
        /// </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 market data </returns>
        public ImmutableMarketData marketData(RatesCurveGroupDefinition group, RatesProvider inputProvider, ReferenceData refData)
        {
            // Retrieve the set of required indices and the list of required currencies
            ISet <Index>     indicesRequired = new HashSet <Index>();
            IList <Currency> ccyRequired     = new List <Currency>();

            foreach (RatesCurveGroupEntry entry in group.Entries)
            {
                indicesRequired.addAll(entry.Indices);
                ((IList <Currency>)ccyRequired).AddRange(entry.DiscountCurrencies);
            }
            // Retrieve the required time series if present in the original provider
            IDictionary <IndexQuoteId, LocalDateDoubleTimeSeries> ts = new Dictionary <IndexQuoteId, LocalDateDoubleTimeSeries>();

            foreach (Index idx in Sets.intersection(inputProvider.TimeSeriesIndices, indicesRequired))
            {
                ts[IndexQuoteId.of(idx)] = inputProvider.timeSeries(idx);
            }

            LocalDate valuationDate = inputProvider.ValuationDate;
            ImmutableList <CurveDefinition> curveGroups = group.CurveDefinitions;
            // Create fake market quotes of 0, only to be able to generate trades
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, double> mapId0 = new java.util.HashMap<>();
            IDictionary <MarketDataId <object>, double> mapId0 = new Dictionary <MarketDataId <object>, double>();

            foreach (CurveDefinition entry in curveGroups)
            {
                ImmutableList <CurveNode> nodes = entry.Nodes;
                for (int i = 0; i < nodes.size(); i++)
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (com.opengamma.strata.data.MarketDataId<?> key : nodes.get(i).requirements())
                    foreach (MarketDataId <object> key in nodes.get(i).requirements())
                    {
                        mapId0[key] = 0.0d;
                    }
                }
            }
            ImmutableMarketData marketQuotes0 = ImmutableMarketData.of(valuationDate, mapId0);
            // Generate market quotes from the trades
//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> mapIdSy = new java.util.HashMap<>();
            IDictionary <MarketDataId <object>, object> mapIdSy = new Dictionary <MarketDataId <object>, object>();

            foreach (CurveDefinition entry in curveGroups)
            {
                ImmutableList <CurveNode> nodes = entry.Nodes;
                foreach (CurveNode node in nodes)
                {
                    ResolvedTrade trade = node.resolvedTrade(1d, marketQuotes0, refData);
                    double        mq    = measures.value(trade, inputProvider);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> k = node.requirements().iterator().next();
                    MarketDataId <object> k = node.requirements().GetEnumerator().next();
                    mapIdSy[k] = mq;
                }
            }
            // Generate quotes for FX pairs. The first currency is arbitrarily selected as starting point.
            // The crosses are automatically generated by the MarketDataFxRateProvider used in calibration.
            for (int loopccy = 1; loopccy < ccyRequired.Count; loopccy++)
            {
                CurrencyPair ccyPair = CurrencyPair.of(ccyRequired[0], ccyRequired[loopccy]);
                FxRateId     fxId    = FxRateId.of(ccyPair);
                mapIdSy[fxId] = FxRate.of(ccyPair, inputProvider.fxRate(ccyPair));
            }
            return(ImmutableMarketData.builder(valuationDate).addValueMap(mapIdSy).addTimeSeriesMap(ts).build());
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance specifying the trade and label.
 /// </summary>
 /// <param name="trade">  the resolved trade </param>
 /// <param name="label">  the label </param>
 /// <returns> the instance </returns>
 public static ResolvedTradeParameterMetadata of(ResolvedTrade trade, string label)
 {
     return(new ResolvedTradeParameterMetadata(trade, label));
 }
 //-----------------------------------------------------------------------
 /// <summary>
 /// Sets the trade that describes the parameter. </summary>
 /// <param name="trade">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder trade(ResolvedTrade trade)
 {
     JodaBeanUtils.notNull(trade, "trade");
     this.trade_Renamed = trade;
     return(this);
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(ResolvedTradeParameterMetadata beanToCopy)
 {
     this.trade_Renamed = beanToCopy.Trade;
     this.label_Renamed = beanToCopy.Label;
 }