예제 #1
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());
        }
 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());
 }