/** * Creates an option security based on this contract specification. * <p> * The security identifier will be automatically created using {@link EtdIdUtils}. * The {@link #getType() type} must be {@link EtdType#OPTION} otherwise an exception will be thrown. * * @param expiryMonth the expiry month of the option * @param variant the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' * @param version the non-negative version, zero by default * @param putCall whether the option is a put or call * @param strikePrice the strike price of the option * @return an option security based on this contract specification * @throws IllegalStateException if the product type of the contract specification is not {@code OPTION} */ public EtdOptionSecurity createOption( YearMonth expiryMonth, EtdVariant variant, int version, PutCall putCall, double strikePrice) { return EtdOptionSecurity.of(this, expiryMonth, variant, version, putCall, strikePrice); }
/** * Obtains an instance from a contract specification, expiry year-month, variant, version, put/call and strike price. * <p> * The security identifier will be automatically created using {@link EtdIdUtils}. * The specification must be for an option. * * @param spec the option contract specification * @param expiry the expiry year-month of the option * @param variant the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' * @param version the non-negative version, zero if versioning does not apply * @param putCall whether the option is a put or call * @param strikePrice the strike price of the option * @return an option security based on this contract specification * @throws IllegalStateException if the product type of the contract specification is not {@code OPTION} */ public static EtdOptionSecurity of( EtdContractSpec spec, YearMonth expiry, EtdVariant variant, int version, PutCall putCall, double strikePrice) { return of(spec, expiry, variant, version, putCall, strikePrice, null); }
/** * Creates an option security based on this contract specification. * <p> * The security identifier will be automatically created using {@link EtdIdUtils}. * The {@link #getType() type} must be {@link EtdType#OPTION} otherwise an exception will be thrown. * * @param expiryMonth the expiry month of the option * @param variant the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' * @param version the non-negative version, zero by default * @param putCall whether the option is a put or call * @param strikePrice the strike price of the option * @param underlyingExpiryMonth the expiry of the underlying instrument, such as a future * @return an option security based on this contract specification * @throws IllegalStateException if the product type of the contract specification is not {@code OPTION} */ public EtdOptionSecurity createOption( YearMonth expiryMonth, EtdVariant variant, int version, PutCall putCall, double strikePrice, YearMonth underlyingExpiryMonth) { return EtdOptionSecurity.of(this, expiryMonth, variant, version, putCall, strikePrice, underlyingExpiryMonth); }
.id(StandardId.of("OG", "123431")) .build()) .security(EtdOptionSecurity.of( contract, YearMonth.of(2017, 6), EtdVariant.ofMonthly(), 0, PutCall.PUT, 3d, YearMonth.of(2017, 9))) .longQuantity(15d) .id(StandardId.of("OG", "123432")) .build()) .security(EtdOptionSecurity.of( contract, YearMonth.of(2017, 6), .id(StandardId.of("OG", "123433")) .build()) .security(EtdOptionSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofWeekly(2), 0, PutCall.PUT, 5.1d)) .longQuantity(0d) .shortQuantity(20d)