Beispiel #1
0
        // parse full definition
        private static FxSwapTrade parseFull(CsvRow row, TradeInfo info)
        {
            FxSingle nearFx = FxSingleTradeCsvLoader.parseFxSingle(row, "");
            FxSingle farFx  = FxSingleTradeCsvLoader.parseFxSingle(row, "Far ");

            return(FxSwapTrade.of(info, FxSwap.of(nearFx, farFx)));
        }
Beispiel #2
0
        // 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 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));
        }