public virtual void test_withInfo()
        {
            BillSecurity @base    = BillSecurity.builder().dayCount(DAY_COUNT).info(INFO).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();
            SecurityInfo info     = SecurityInfo.of(SECURITY_ID, SecurityPriceInfo.ofCurrencyMinorUnit(CCY));
            BillSecurity expected = BillSecurity.builder().dayCount(DAY_COUNT).info(info).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();

            assertEquals(@base.withInfo(info), expected);
        }
Example #2
0
        private static Trade trade()
        {
            SecurityInfo    info      = SecurityInfo.of(SecurityId.of("OG-Test", "1"), 20, CurrencyAmount.of(USD, 10));
            GenericSecurity security  = GenericSecurity.of(info);
            TradeInfo       tradeInfo = TradeInfo.builder().counterparty(StandardId.of("cpty", "a")).build();

            return(GenericSecurityTrade.builder().info(tradeInfo).security(security).quantity(123).price(456).build());
        }
Example #3
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Obtains an instance from a contract specification, expiry year-month and variant.
        /// <para>
        /// The security identifier will be automatically created using <seealso cref="EtdIdUtils"/>.
        /// The specification must be for a future.
        ///
        /// </para>
        /// </summary>
        /// <param name="spec">  the future contract specification </param>
        /// <param name="expiry">  the expiry year-month of the future </param>
        /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
        /// <returns> a future security based on this contract specification </returns>
        /// <exception cref="IllegalStateException"> if the product type of the contract specification is not {@code FUTURE} </exception>
        public static EtdFutureSecurity of(EtdContractSpec spec, YearMonth expiry, EtdVariant variant)
        {
            if (spec.Type != EtdType.FUTURE)
            {
                throw new System.InvalidOperationException(Messages.format("Cannot create an EtdFutureSecurity from a contract specification of type '{}'", spec.Type));
            }
            SecurityId securityId = EtdIdUtils.futureId(spec.ExchangeId, spec.ContractCode, expiry, variant);

            return(EtdFutureSecurity.builder().info(SecurityInfo.of(securityId, spec.PriceInfo)).contractSpecId(spec.Id).expiry(expiry).variant(variant).build());
        }
Example #4
0
        /// <summary>
        /// Obtains an instance from a contract specification, expiry year-month, variant,
        /// version, put/call, strike price and underlying expiry.
        /// <para>
        /// The security identifier will be automatically created using <seealso cref="EtdIdUtils"/>.
        /// The specification must be for an option.
        ///
        /// </para>
        /// </summary>
        /// <param name="spec">  the option contract specification </param>
        /// <param name="expiry">  the expiry year-month of the option </param>
        /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
        /// <param name="version">  the non-negative version, zero if versioning does not apply </param>
        /// <param name="putCall">  whether the option is a put or call </param>
        /// <param name="strikePrice">  the strike price of the option </param>
        /// <param name="underlyingExpiryMonth">  the expiry of the underlying instrument, such as a future, may be null </param>
        /// <returns> an option security based on this contract specification </returns>
        /// <exception cref="IllegalStateException"> if the product type of the contract specification is not {@code OPTION} </exception>
        public static EtdOptionSecurity of(EtdContractSpec spec, YearMonth expiry, EtdVariant variant, int version, PutCall putCall, double strikePrice, YearMonth underlyingExpiryMonth)
        {
            if (spec.Type != EtdType.OPTION)
            {
                throw new System.InvalidOperationException(Messages.format("Cannot create an EtdOptionSecurity from a contract specification of type '{}'", spec.Type));
            }
            SecurityId securityId = EtdIdUtils.optionId(spec.ExchangeId, spec.ContractCode, expiry, variant, version, putCall, strikePrice, underlyingExpiryMonth);

            return(EtdOptionSecurity.builder().info(SecurityInfo.of(securityId, spec.PriceInfo)).contractSpecId(spec.Id).expiry(expiry).variant(variant).version(version).putCall(putCall).strikePrice(strikePrice).underlyingExpiryMonth(underlyingExpiryMonth).build());
        }
 internal static CapitalIndexedBondSecurity createSecurity(CapitalIndexedBond product)
 {
     return(CapitalIndexedBondSecurity.builder().info(SecurityInfo.of(product.SecurityId, INFO.PriceInfo)).currency(product.Currency).notional(product.Notional).accrualSchedule(product.AccrualSchedule).rateCalculation(product.RateCalculation).dayCount(product.DayCount).yieldConvention(product.YieldConvention).legalEntityId(product.LegalEntityId).settlementDateOffset(product.SettlementDateOffset).exCouponPeriod(product.ExCouponPeriod).build());
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            BillSecurity test1 = BillSecurity.builder().dayCount(DAY_COUNT).info(INFO).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();

            coverImmutableBean(test1);
            BillSecurity test2 = BillSecurity.builder().dayCount(DayCounts.ACT_365F).info(SecurityInfo.of(SecurityId.of("OG-Test", "ID2"), PRICE_INFO)).legalEntityId(LegalEntityId.of("OG-Ticker", "LE2")).notional(AdjustablePayment.of(CurrencyAmount.of(CCY, 10), MATURITY_DATE_ADJ)).settlementDateOffset(DaysAdjustment.ofBusinessDays(2, EUTA, BUSINESS_ADJUST)).yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build();

            coverBeanEquals(test1, test2);
        }
Example #7
0
 internal static EtdOptionSecurity sut2()
 {
     return(EtdOptionSecurity.builder().info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10))).contractSpecId(EtdContractSpecId.of("test", "234")).expiry(YearMonth.of(2017, 9)).variant(EtdVariant.ofWeekly(2)).version(4).putCall(PutCall.CALL).strikePrice(3).underlyingExpiryMonth(YearMonth.of(2017, 12)).build());
 }
Example #8
0
 //-------------------------------------------------------------------------
 internal static EtdOptionSecurity sut()
 {
     return(EtdOptionSecurity.builder().info(SecurityInfo.of(SecurityId.of("A", "B"), SecurityPriceInfo.of(Currency.GBP, 100))).contractSpecId(EtdContractSpecId.of("test", "123")).expiry(YearMonth.of(2017, 6)).putCall(PutCall.PUT).strikePrice(2).build());
 }
        private static Security security()
        {
            SecurityInfo info = SecurityInfo.of(ID, 20, CurrencyAmount.of(USD, 10));

            return(GenericSecurity.of(info));
        }
 internal static EtdFutureSecurity sut2()
 {
     return(EtdFutureSecurity.builder().info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10))).contractSpecId(EtdContractSpecId.of("test", "234")).expiry(YearMonth.of(2017, 9)).variant(EtdVariant.ofWeekly(2)).build());
 }
 //-------------------------------------------------------------------------
 internal static EtdFutureSecurity sut()
 {
     return(EtdFutureSecurity.builder().info(SecurityInfo.of(SecurityId.of("A", "B"), SecurityPriceInfo.of(Currency.GBP, 100))).contractSpecId(EtdContractSpecId.of("test", "123")).expiry(YearMonth.of(2017, 6)).build());
 }