コード例 #1
0
        public virtual void test_trade()
        {
            FxSwapCurveNode node     = FxSwapCurveNode.of(TEMPLATE, QUOTE_ID_PTS);
            FxSwapTrade     trade    = node.trade(1d, MARKET_DATA, REF_DATA);
            double          rate     = FX_RATE_NEAR.fxRate(EUR_USD);
            FxSwapTrade     expected = TEMPLATE.createTrade(VAL_DATE, BuySell.BUY, 1.0, rate, FX_RATE_PTS, REF_DATA);

            assertEquals(trade, expected);
            assertEquals(node.resolvedTrade(1d, MARKET_DATA, REF_DATA), trade.resolve(REF_DATA));
        }
コード例 #2
0
        //-------------------------------------------------------------------------
        public FxSwapTrade toTrade(TradeInfo tradeInfo, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double nearFxRate, double farLegForwardPoints)
        {
            Optional <LocalDate> tradeDate = tradeInfo.TradeDate;

            if (tradeDate.Present)
            {
                ArgChecker.inOrderOrEqual(tradeDate.get(), startDate, "tradeDate", "startDate");
            }
            double amount1 = BuySell.BUY.normalize(notional);

            return(FxSwapTrade.builder().info(tradeInfo).product(FxSwap.ofForwardPoints(CurrencyAmount.of(currencyPair.Base, amount1), FxRate.of(currencyPair, nearFxRate), farLegForwardPoints, startDate, endDate, BusinessDayAdjustment)).build());
        }
コード例 #3
0
        //-------------------------------------------------------------------------
        public virtual void test_createTrade()
        {
            FxSwapTemplate        @base     = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION);
            LocalDate             tradeDate = LocalDate.of(2015, 10, 29);
            FxSwapTrade           test      = @base.createTrade(tradeDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS, REF_DATA);
            LocalDate             spotDate  = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA);
            LocalDate             nearDate  = spotDate.plus(NEAR_PERIOD);
            LocalDate             farDate   = spotDate.plus(FAR_PERIOD);
            BusinessDayAdjustment bda       = CONVENTION.BusinessDayAdjustment;
            FxSwap expected = FxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, bda);

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
コード例 #4
0
        //-------------------------------------------------------------------------
        public virtual void test_toTrade_periods()
        {
            ImmutableFxSwapConvention @base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW);
            Period      startPeriod         = Period.ofMonths(3);
            Period      endPeriod           = Period.ofMonths(6);
            LocalDate   tradeDate           = LocalDate.of(2015, 5, 5);
            LocalDate   spotDate            = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA);
            LocalDate   nearDate            = spotDate.plus(startPeriod);
            LocalDate   farDate             = spotDate.plus(endPeriod);
            FxSwapTrade test     = @base.createTrade(tradeDate, startPeriod, endPeriod, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS, REF_DATA);
            FxSwap      expected = FxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, BDA_FOLLOW);

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
コード例 #5
0
        public virtual void test_toTrade_dates()
        {
            ImmutableFxSwapConvention @base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW);
            LocalDate   tradeDate           = LocalDate.of(2015, 5, 5);
            LocalDate   nearDate            = LocalDate.of(2015, 7, 5);
            LocalDate   nearDateAdj         = LocalDate.of(2015, 7, 6); // Adjusted: 5 is Sunday
            LocalDate   farDate             = LocalDate.of(2015, 9, 5);
            LocalDate   farDateAdj          = LocalDate.of(2015, 9, 7); // Adjusted: 5 is Saturday
            FxSwapTrade test     = @base.toTrade(tradeDate, nearDate, farDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS);
            FxSwap      expected = FxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, BDA_FOLLOW);

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
            ResolvedFxSwap resolvedExpected = ResolvedFxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), USD, FX_RATE_NEAR, FX_RATE_PTS, nearDateAdj, farDateAdj);

            assertEquals(test.Product.resolve(REF_DATA), resolvedExpected);
        }
コード例 #6
0
        // create an FX Swap trade
        private static Trade createTrade3()
        {
            FxSwap swap = FxSwap.ofForwardPoints(CurrencyAmount.of(GBP, 10000), FxRate.of(GBP, USD, 1.62), 0.03, LocalDate.of(2014, 6, 14), LocalDate.of(2014, 9, 14));

            return(FxSwapTrade.builder().product(swap).info(TradeInfo.builder().id(StandardId.of("example", "3")).addAttribute(AttributeType.DESCRIPTION, "GBP 10,000/USD @ 1.62 swap").counterparty(StandardId.of("example", "BigBankA")).settlementDate(LocalDate.of(2014, 9, 15)).build()).build());
        }
コード例 #7
0
        // calculate the end date
        private LocalDate calculateEnd(LocalDate valuationDate, ReferenceData refData)
        {
            FxSwapTrade trade = template.createTrade(valuationDate, BuySell.BUY, 1, 1, 0, refData);

            return(trade.Product.FarLeg.resolve(refData).PaymentDate);
        }