/** * Obtains a template based on the specified period and index. * <p> * The period from the start date to the end is specified. * The convention will be created based on the index. * * @param depositPeriod the period between the start date and the end date * @param index the index that defines the market convention * @return the template */ public static IborFixingDepositTemplate of(Period depositPeriod, IborIndex index) { return of(depositPeriod, IborFixingDepositConvention.of(index)); }
/** * Creates a trade based on this template. * <p> * This returns a trade based on the specified date. * The notional is unsigned, with buy/sell determining the direction of the trade. * If buying the Ibor fixing deposit, the floating rate is paid from the counterparty, with the fixed rate being received. * If selling the Ibor fixing deposit, the floating received is paid to the counterparty, with the fixed rate being paid. * * @param tradeDate the date of the trade * @param buySell the buy/sell flag, see {@link IborFixingDeposit#getBuySell()} * @param notional the notional amount, in the payment currency of the template * @param fixedRate the fixed rate, typically derived from the market * @param refData the reference data, used to resolve the trade dates * @return the trade * @throws ReferenceDataNotFoundException if an identifier cannot be resolved in the reference data */ public IborFixingDepositTrade createTrade( LocalDate tradeDate, BuySell buySell, double notional, double fixedRate, ReferenceData refData) { return convention.createTrade(tradeDate, depositPeriod, buySell, notional, fixedRate, refData); }
@Override public IborFixingDepositConvention lookup(String name) { IborFixingDepositConvention value = BY_NAME.get(name); if (value == null) { IborFixingDepositConvention created = createByName(name); if (created != null) { String correctName = created.getName(); value = BY_NAME.computeIfAbsent(correctName, k -> created); BY_NAME.putIfAbsent(correctName.toUpperCase(Locale.ENGLISH), value); } } return value; }
@Test(dataProvider = "name") public void test_extendedEnum(IborFixingDepositConvention convention, String name) { IborFixingDepositConvention.of(name); // ensures map is populated ImmutableMap<String, IborFixingDepositConvention> map = IborFixingDepositConvention.extendedEnum().lookupAll(); assertEquals(map.get(name), convention); }
IborFixingDepositConvention c = IborFixingDepositConvention.of(EUR_EURIBOR_6M); ResolvedIborFixingDepositTrade fix0 = c.createTrade(VALUATION_DATE, EUR_EURIBOR_6M.getTenor().getPeriod(), BuySell.BUY, 1.0, 0.0, REF_DATA).resolve(REF_DATA); double rateFixing = MARKET_QUOTE.value(fix0, MULTICURVE_EUR_2_CALIBRATED); ResolvedIborFixingDepositTrade fix = c.createTrade(VALUATION_DATE, EUR_EURIBOR_6M.getTenor().getPeriod(), BuySell.BUY, 1.0, rateFixing, REF_DATA).resolve(REF_DATA); tradesE3.add(fix);
private static CurveNode curveIborFixingDepositCurveNode( String conventionStr, String label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { IborFixingDepositConvention convention = IborFixingDepositConvention.of(conventionStr); IborFixingDepositTemplate template = IborFixingDepositTemplate.of( convention.getIndex().getTenor().getPeriod(), convention); return IborFixingDepositCurveNode.builder() .template(template) .rateId(quoteId) .additionalSpread(spread) .label(label) .date(date) .dateOrder(order) .build(); }
/** * Obtains an instance from the specified unique name. * * @param uniqueName the unique name * @return the convention * @throws IllegalArgumentException if the name is not known */ @FromString public static IborFixingDepositConvention of(String uniqueName) { ArgChecker.notNull(uniqueName, "uniqueName"); return extendedEnum().lookup(uniqueName); }
@ImmutablePreBuild private static void preBuild(Builder builder) { if (builder.depositPeriod == null && builder.convention != null) { builder.depositPeriod = builder.convention.getIndex().getTenor().getPeriod(); } }
/** * Calculates the spot date from the trade date. * * @param tradeDate the trade date * @param refData the reference data, used to resolve the date * @return the spot date * @throws ReferenceDataNotFoundException if an identifier cannot be resolved in the reference data */ public default LocalDate calculateSpotDateFromTradeDate(LocalDate tradeDate, ReferenceData refData) { return getSpotDateOffset().adjust(tradeDate, refData); }
/** * Creates a trade based on this convention. * <p> * This returns a trade based on the specified dates. * The notional is unsigned, with buy/sell determining the direction of the trade. * If buying the Ibor fixing deposit, the floating rate is paid to the counterparty, with the fixed rate being received. * If selling the Ibor fixing deposit, the floating rate is received from the counterparty, with the fixed rate being paid. * * @param tradeDate the date of the trade * @param startDate the start date * @param endDate the end date * @param buySell the buy/sell flag * @param notional the notional amount, in the payment currency of the template * @param fixedRate the fixed rate, typically derived from the market * @return the trade */ public default IborFixingDepositTrade toTrade( LocalDate tradeDate, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double fixedRate) { TradeInfo tradeInfo = TradeInfo.of(tradeDate); return toTrade(tradeInfo, startDate, endDate, buySell, notional, fixedRate); }
/** * Obtains a convention based on the specified index. * <p> * This uses the index name to find the matching convention. * By default, this will always return a convention, however configuration may be added * to restrict the conventions that are registered. * * @param index the index, from which the index name is used to find the matching convention * @return the convention * @throws IllegalArgumentException if no convention is registered for the index */ public static IborFixingDepositConvention of(IborIndex index) { ArgChecker.notNull(index, "index"); return extendedEnum().lookup(index.getName()); }
@Test(dataProvider = "name") public void test_of_lookup(IborFixingDepositConvention convention, String name) { assertEquals(IborFixingDepositConvention.of(name), convention); }
double notional = 1d; double fixedRate = 0.045; IborFixingDepositTrade trade = convention.createTrade(tradeDate, depositPeriod, BUY, notional, fixedRate, REF_DATA); LocalDate startExpected = SPOT_ADJ.adjust(tradeDate, REF_DATA); LocalDate endExpected = startExpected.plus(depositPeriod);
@Test(dataProvider = "name") public void test_name(IborFixingDepositConvention convention, String name) { assertEquals(convention.getName(), name); }
/** * Obtains a template based on the specified index. * <p> * The period from the start date to the end date will be the tenor of the index. * The convention will be created based on the index. * * @param index the index that defines the market convention * @return the template */ public static IborFixingDepositTemplate of(IborIndex index) { return of(index.getTenor().getPeriod(), IborFixingDepositConvention.of(index)); }
public void test_of_lookup_null() { assertThrowsIllegalArg(() -> IborFixingDepositConvention.of((String) null)); }
public void test_of_lookup_notFound() { assertThrowsIllegalArg(() -> IborFixingDepositConvention.of("Rubbish")); }