//-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            DsfSecurity test = sut();

            assertEquals(test.Info, INFO);
            assertEquals(test.SecurityId, PRODUCT.SecurityId);
            assertEquals(test.Currency, PRODUCT.Currency);
            assertEquals(test.UnderlyingIds, ImmutableSet.of());
        }
Exemplo n.º 2
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         DsfSecurity other = (DsfSecurity)obj;
         return(JodaBeanUtils.equal(info, other.info) && JodaBeanUtils.equal(notional, other.notional) && JodaBeanUtils.equal(lastTradeDate, other.lastTradeDate) && JodaBeanUtils.equal(underlyingSwap, other.underlyingSwap));
     }
     return(false);
 }
        public virtual void test_builder_notUnitNotional()
        {
            SwapLeg fixedLeg10     = RateCalculationSwapLeg.builder().payReceive(RECEIVE).accrualSchedule(PeriodicSchedule.builder().startDate(LocalDate.of(2014, 9, 12)).endDate(LocalDate.of(2016, 9, 12)).frequency(P6M).businessDayAdjustment(BDA_MF).stubConvention(StubConvention.SHORT_INITIAL).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P6M).paymentDateOffset(DaysAdjustment.NONE).build()).notionalSchedule(NotionalSchedule.of(USD, 10d)).calculation(FixedRateCalculation.builder().dayCount(THIRTY_U_360).rate(ValueSchedule.of(0.015)).build()).build();
            SwapLeg knownAmountLeg = KnownAmountSwapLeg.builder().payReceive(RECEIVE).accrualSchedule(PeriodicSchedule.builder().startDate(LocalDate.of(2014, 9, 12)).endDate(LocalDate.of(2016, 9, 12)).frequency(P6M).businessDayAdjustment(BDA_MF).stubConvention(StubConvention.SHORT_INITIAL).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P6M).paymentDateOffset(DaysAdjustment.NONE).build()).amount(ValueSchedule.of(0.015)).currency(USD).build();
            SwapLeg iborLeg500     = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(LocalDate.of(2014, 9, 12)).endDate(LocalDate.of(2016, 9, 12)).frequency(P1M).businessDayAdjustment(BDA_MF).stubConvention(StubConvention.SHORT_INITIAL).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P3M).paymentDateOffset(DaysAdjustment.NONE).build()).notionalSchedule(NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(500d)).finalExchange(true).initialExchange(true).build()).calculation(IborRateCalculation.builder().index(INDEX).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, SAT_SUN, BDA_P)).build()).build();
            Swap    swap1          = Swap.of(fixedLeg10, SWAP.getLeg(PAY).get());
            Swap    swap2          = Swap.of(SWAP.getLeg(RECEIVE).get(), iborLeg500);
            Swap    swap3          = Swap.of(knownAmountLeg, SWAP.getLeg(PAY).get());

            assertThrowsIllegalArg(() => DsfSecurity.builder().info(INFO).notional(NOTIONAL).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap1).build());
            assertThrowsIllegalArg(() => DsfSecurity.builder().info(INFO).notional(NOTIONAL).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap2).build());
            // should succeed normally (no notional to validate on known amount leg)
            DsfSecurity.builder().info(INFO).notional(NOTIONAL).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap3).build();
        }
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            DsfSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo tradeInfo     = TradeInfo.of(PRODUCT.LastTradeDate.minusDays(1));
            DsfTrade  expectedTrade = DsfTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(123.50).build();

            assertEquals(test.createTrade(tradeInfo, 100, 123.50, ReferenceData.empty()), expectedTrade);

            PositionInfo positionInfo      = PositionInfo.empty();
            DsfPosition  expectedPosition1 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            DsfPosition expectedPosition2 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
 internal static DsfSecurity sut2()
 {
     return(DsfSecurity.builder().info(INFO2).notional(PRODUCT2.Notional).lastTradeDate(PRODUCT2.LastTradeDate).underlyingSwap(PRODUCT2.UnderlyingSwap).build());
 }