@Override public LocalDate getValuationDate() { return underlying.getValuationDate(); }
@Override public LocalDate getValuationDate() { return underlying1.getValuationDate(); }
@ImmutableValidator private void validate() { if (!underlying1.getValuationDate().equals(underlying2.getValuationDate())) { throw new IllegalArgumentException("Unable to combine market data instances with different valuation dates"); } }
@Override public MarketDataBox<LocalDate> getValuationDate() { return MarketDataBox.ofSingleValue(underlying.getValuationDate()); }
@Override public SwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public SwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public SwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public IborFixingDepositTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.BUY : BuySell.SELL; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public SwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public FraTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public SwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public TermDepositTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.BUY : BuySell.SELL; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public SwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + additionalSpread; BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), fixedRate, refData); }
@Override public double initialGuess(MarketData marketData, ValueType valueType) { double rate = 1d - marketPrice(marketData); if (ValueType.ZERO_RATE.equals(valueType) || ValueType.FORWARD_RATE.equals(valueType)) { return rate; } if (ValueType.DISCOUNT_FACTOR.equals(valueType)) { double approximateMaturity = template.approximateMaturity(marketData.getValuationDate()); return Math.exp(-approximateMaturity * rate); } return 0d; }
@Override public FxSwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { FxRate fxRate = marketData.getValue(fxRateId); double rate = fxRate.fxRate(template.getCurrencyPair()); double fxPts = marketData.getValue(farForwardPointsId); BuySell buySell = quantity > 0 ? BuySell.BUY : BuySell.SELL; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), rate, fxPts, refData); }
@Override public SwapTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double marketQuote = marketData.getValue(spreadId) + additionalSpread; FxRate fxRate = marketData.getValue(fxRateId); double rate = fxRate.fxRate(template.getCurrencyPair()); BuySell buySell = quantity > 0 ? BuySell.SELL : BuySell.BUY; return template.createTrade(marketData.getValuationDate(), buySell, Math.abs(quantity), rate, marketQuote, refData); }
@Override public IborFutureTrade trade(double quantity, MarketData marketData, ReferenceData refData) { LocalDate valuationDate = marketData.getValuationDate(); double price = marketPrice(marketData) + additionalSpread; SecurityId secId = SecurityId.of(rateId.getStandardId()); // quote must also be security return template.createTrade(valuationDate, secId, quantity, 1d, price, refData); }
@Override public DummyFraTrade trade(double quantity, MarketData marketData, ReferenceData refData) { double fixedRate = marketData.getValue(rateId) + spread; return DummyFraTrade.of(marketData.getValuationDate(), fixedRate); }
/** * Creates a trade representing the CDS at the node. * <p> * This uses the observed market data to build the CDS trade that the node represents. * The resulting trade is not resolved. * The notional of the trade is taken from the 'quantity' variable. * The quantity is signed and will affect whether the trade is Buy or Sell. * The valuation date is defined by the market data. * * @param quantity the quantity or notional of the trade * @param marketData the market data required to build a trade for the instrument, including the valuation date * @param refData the reference data, used to resolve the trade dates * @return a trade representing the instrument at the node */ public CdsCalibrationTrade trade(double quantity, MarketData marketData, ReferenceData refData) { BuySell buySell = quantity > 0 ? BuySell.BUY : BuySell.SELL; LocalDate valuationDate = marketData.getValuationDate(); double quoteValue = marketData.getValue(observableId); CdsQuote quote = CdsQuote.of(quoteConvention, quoteValue); double notional = Math.abs(quantity); if (quoteConvention.equals(CdsQuoteConvention.PAR_SPREAD)) { return CdsCalibrationTrade.of( template.createTrade(legalEntityId, valuationDate, buySell, notional, quoteValue, refData), quote); } double coupon = getFixedRate().getAsDouble(); // always success return CdsCalibrationTrade.of( template.createTrade(legalEntityId, valuationDate, buySell, notional, coupon, refData), quote); }
public 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.getValuationDate(), VALUATION_DATE); for (CurveDefinition entry : group.getCurveDefinitions()) { ImmutableList<CurveNode> nodes = entry.getNodes(); for (CurveNode node : 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().iterator().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().iterator().next()), TOLERANCE_MQ); // Market Quote for Fixed v ibor swaps should have changed with the fixing if ((tradeTsLarge instanceof ResolvedSwapTrade) && // Swap Fixed v Ibor (((ResolvedSwapTrade) tradeTsLarge)).getProduct().getLegs(SwapLegType.IBOR).size() == 1) { assertTrue(Math.abs(mqTsEmpty - mqTsLarge) > TOLERANCE_MQ); } } } assertEquals(madTsEmpty.getTimeSeriesIds(), ImmutableSet.of()); assertEquals( madTsLarge.getTimeSeriesIds(), ImmutableSet.of(IndexQuoteId.of(EUR_EURIBOR_3M), IndexQuoteId.of(EUR_EURIBOR_6M))); }