public void test_parseBuySell() { assertEquals(LoaderUtils.parseBuySell("BUY"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("Buy"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("buy"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("b"), BuySell.BUY); assertEquals(LoaderUtils.parseBuySell("SELL"), BuySell.SELL); assertEquals(LoaderUtils.parseBuySell("Sell"), BuySell.SELL); assertEquals(LoaderUtils.parseBuySell("sell"), BuySell.SELL); assertEquals(LoaderUtils.parseBuySell("s"), BuySell.SELL); assertThrowsIllegalArg(() -> LoaderUtils.parseBoolean("Rubbish")); }
private static double parseTradeQuantity(CsvRow row) { double quantity = LoaderUtils.parseDouble(row.getValue(QUANTITY_FIELD)); Optional<BuySell> buySellOpt = row.findValue(BUY_SELL_FIELD).map(str -> LoaderUtils.parseBuySell(str)); if (buySellOpt.isPresent()) { quantity = buySellOpt.get().normalize(quantity); } return quantity; }
private static TermDepositTrade parseRow(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver) { BuySell buySell = LoaderUtils.parseBuySell(row.getValue(BUY_SELL_FIELD)); double notional = LoaderUtils.parseDouble(row.getValue(NOTIONAL_FIELD)); double fixedRate = LoaderUtils.parseDoublePercent(row.getValue(FIXED_RATE_FIELD));
private static FraTrade parseRow(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver) { BuySell buySell = LoaderUtils.parseBuySell(row.getValue(BUY_SELL_FIELD)); double notional = LoaderUtils.parseDouble(row.getValue(NOTIONAL_FIELD)); double fixedRate = LoaderUtils.parseDoublePercent(row.getValue(FIXED_RATE_FIELD));
static SwapTrade parseWithConvention(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver, String conventionStr) { BuySell buySell = LoaderUtils.parseBuySell(row.getValue(BUY_SELL_FIELD)); double notional = LoaderUtils.parseDouble(row.getValue(NOTIONAL_FIELD)); double fixedRate = LoaderUtils.parseDoublePercent(row.getValue(FIXED_RATE_FIELD));
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); }
private static FxSwapTrade 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 nearFxRate = LoaderUtils.parseDouble(row.getValue(FX_RATE_FIELD)); double farFxRate = LoaderUtils.parseDouble(row.getValue(FAR_FX_RATE_DATE_FIELD)); LocalDate nearPaymentDate = LoaderUtils.parseDate(row.getValue(PAYMENT_DATE_FIELD)); LocalDate farPaymentDate = LoaderUtils.parseDate(row.getValue(FAR_PAYMENT_DATE_FIELD)); Optional<BusinessDayAdjustment> paymentAdj = FxSingleTradeCsvLoader.parsePaymentDateAdjustment(row); CurrencyAmount amount = CurrencyAmount.of(currency, buySell.normalize(notional)); FxRate nearRate = FxRate.of(pair, nearFxRate); FxRate farRate = FxRate.of(pair, farFxRate); FxSwap fx = paymentAdj .map(adj -> FxSwap.of(amount, nearRate, nearPaymentDate, farRate, farPaymentDate, adj)) .orElseGet(() -> FxSwap.of(amount, nearRate, nearPaymentDate, farRate, farPaymentDate)); return FxSwapTrade.of(info, fx); }