示例#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());
        }
示例#2
0
        public virtual void test_futureId_flex()
        {
            SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofFlexFuture(26, EtdSettlementType.DERIVATIVE));

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "F-ECAG-FGBS-20170626D"));
        }
示例#3
0
        public virtual void test_futureId_daily()
        {
            SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(2));

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "F-ECAG-FGBS-20170602"));
        }
示例#4
0
        //-------------------------------------------------------------------------
        public virtual void test_futureId_monthly()
        {
            SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "F-ECAG-FGBS-201706"));
        }