示例#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
 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());
 }
示例#3
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());
 }