Пример #1
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());
        }
Пример #2
0
        public virtual void test_optionId_daily21_version()
        {
            SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(21), 11, PutCall.PUT, 12.34);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-FGBS-20170621-V11-P12.34"));
        }
Пример #3
0
        public virtual void test_optionId_weekly()
        {
            SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofWeekly(3), 0, PutCall.CALL, -1.45);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-FGBS-201706W3-CM1.45"));
        }
Пример #4
0
        //-------------------------------------------------------------------------
        public virtual void test_optionId_monthly()
        {
            SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY, 0, PutCall.PUT, 12.34);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-FGBS-201706-P12.34"));
        }
Пример #5
0
        public virtual void test_optionIdUnderlying_daily9_version()
        {
            SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(9), 3, PutCall.PUT, 12.34, YearMonth.of(2017, 9));

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-FGBS-20170609-V3-P12.34-U201709"));
        }