public virtual void coverage_builder() { MetaBean meta = MetaBean.of(typeof(FxRateId)); Bean test1 = meta.builder().set("pair", CurrencyPair.parse("EUR/GBP")).set("observableSource", OBS_SOURCE).build(); Bean test2 = meta.builder().set("pair", CurrencyPair.parse("EUR/GBP")).set("observableSource", OBS_SOURCE).build(); coverBeanEquals(test1, test2); }
// convention-based // ideally we'd use the trade date plus "period to start" to get the spot/payment date // but we don't have all the data and it gets complicated in places like TRY, RUB and AED private static FxSingleTrade parseConvention(CsvRow row, TradeInfo info) { CurrencyPair pair = CurrencyPair.parse(row.getValue(CONVENTION_FIELD)); BuySell buySell = LoaderUtils.parseBuySell(row.getValue(BUY_SELL_FIELD)); Currency currency = Currency.parse(row.getValue(CURRENCY_FIELD)); double notional = LoaderUtils.parseDouble(row.getValue(NOTIONAL_FIELD)); double fxRate = LoaderUtils.parseDouble(row.getValue(FX_RATE_FIELD)); LocalDate paymentDate = LoaderUtils.parseDate(row.getValue(PAYMENT_DATE_FIELD)); Optional <BusinessDayAdjustment> paymentAdj = parsePaymentDateAdjustment(row); CurrencyAmount amount = CurrencyAmount.of(currency, buySell.normalize(notional)); FxSingle fx = paymentAdj.map(adj => FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate, adj)).orElseGet(() => FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate)); return(FxSingleTrade.of(info, fx)); }
public virtual void test_builder() { assertThrowsIllegalArg(() => DiscountFxForwardRates.meta().builder().set(DiscountFxForwardRates.meta().currencyPair(), CurrencyPair.parse("GBP/USD")).build()); assertThrowsIllegalArg(() => DiscountFxForwardRates.meta().builder().set(DiscountFxForwardRates.meta().currencyPair().name(), CurrencyPair.parse("GBP/USD")).build()); }