/// <summary> /// Builds a new specification from the data in this builder. /// </summary> /// <returns> a specification instance built from the data in this builder </returns> public EtdContractSpec build() { if (id_Renamed == null) { id_Renamed = EtdIdUtils.contractSpecId(type_Renamed, exchangeId_Renamed, contractCode_Renamed); } return(new EtdContractSpec(id_Renamed, type_Renamed, exchangeId_Renamed, contractCode_Renamed, description_Renamed, priceInfo_Renamed, attributes)); }
//------------------------------------------------------------------------- /// <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()); }
/// <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()); }
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")); }
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")); }
//------------------------------------------------------------------------- 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")); }
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")); }
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")); }
//------------------------------------------------------------------------- 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")); }
public virtual void test_contractSpecId_option() { EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.OPTION, ExchangeIds.ECAG, OGBS); assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-OGBS")); }
public virtual void test_contractSpecId_future() { EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.FUTURE, ExchangeIds.ECAG, FGBS); assertEquals(test.StandardId, StandardId.of("OG-ETD", "F-ECAG-FGBS")); }
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")); }