public void createFutureAutoId() { EtdFutureSecurity security = FUTURE_CONTRACT.createFuture(YearMonth.of(2015, 6), EtdVariant.MONTHLY); assertThat(security.getSecurityId()).isEqualTo(SecurityId.of(EtdIdUtils.ETD_SCHEME, "F-ECAG-FOO-201506")); assertThat(security.getExpiry()).isEqualTo(YearMonth.of(2015, 6)); assertThat(security.getContractSpecId()).isEqualTo(FUTURE_CONTRACT.getId()); assertThat(security.getVariant()).isEqualTo(EtdVariant.MONTHLY); assertThat(security.getInfo().getPriceInfo()).isEqualTo(FUTURE_CONTRACT.getPriceInfo()); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3355: // id return ((EtdContractSpec) bean).getId(); case 3575610: // type return ((EtdContractSpec) bean).getType(); case 913218206: // exchangeId return ((EtdContractSpec) bean).getExchangeId(); case -1402840545: // contractCode return ((EtdContractSpec) bean).getContractCode(); case -1724546052: // description return ((EtdContractSpec) bean).getDescription(); case -2126070377: // priceInfo return ((EtdContractSpec) bean).getPriceInfo(); case 405645655: // attributes return ((EtdContractSpec) bean).getAttributes(); } return super.propertyGet(bean, propertyName, quiet); }
public void createOptionAutoId() { EtdOptionSecurity security = OPTION_CONTRACT.createOption(YearMonth.of(2015, 6), EtdVariant.MONTHLY, 0, PutCall.CALL, 123.45); assertThat(security.getSecurityId()).isEqualTo(SecurityId.of(EtdIdUtils.ETD_SCHEME, "O-IFEN-BAR-201506-C123.45")); assertThat(security.getExpiry()).isEqualTo(YearMonth.of(2015, 6)); assertThat(security.getContractSpecId()).isEqualTo(OPTION_CONTRACT.getId()); assertThat(security.getVariant()).isEqualTo(EtdVariant.MONTHLY); assertThat(security.getPutCall()).isEqualTo(PutCall.CALL); assertThat(security.getStrikePrice()).isEqualTo(123.45); assertThat(security.getUnderlyingExpiryMonth()).isEmpty(); assertThat(security.getInfo().getPriceInfo()).isEqualTo(OPTION_CONTRACT.getPriceInfo()); }
public void createOptionWithUnderlyingAutoId() { EtdOptionSecurity security = OPTION_CONTRACT.createOption( YearMonth.of(2015, 6), EtdVariant.MONTHLY, 0, PutCall.CALL, 123.45, YearMonth.of(2015, 9)); assertThat(security.getSecurityId()).isEqualTo(SecurityId.of(EtdIdUtils.ETD_SCHEME, "O-IFEN-BAR-201506-C123.45-U201509")); assertThat(security.getExpiry()).isEqualTo(YearMonth.of(2015, 6)); assertThat(security.getContractSpecId()).isEqualTo(OPTION_CONTRACT.getId()); assertThat(security.getVariant()).isEqualTo(EtdVariant.MONTHLY); assertThat(security.getPutCall()).isEqualTo(PutCall.CALL); assertThat(security.getStrikePrice()).isEqualTo(123.45); assertThat(security.getUnderlyingExpiryMonth()).hasValue(YearMonth.of(2015, 9)); assertThat(security.getInfo().getPriceInfo()).isEqualTo(OPTION_CONTRACT.getPriceInfo()); }
/** * Obtains an instance from a contract specification, expiry year-month and variant. * <p> * The security identifier will be automatically created using {@link EtdIdUtils}. * The specification must be for a future. * * @param spec the future contract specification * @param expiry the expiry year-month of the future * @param variant the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' * @return a future security based on this contract specification * @throws IllegalStateException if the product type of the contract specification is not {@code FUTURE} */ public static EtdFutureSecurity of(EtdContractSpec spec, YearMonth expiry, EtdVariant variant) { if (spec.getType() != EtdType.FUTURE) { throw new IllegalStateException( Messages.format("Cannot create an EtdFutureSecurity from a contract specification of type '{}'", spec.getType())); } SecurityId securityId = EtdIdUtils.futureId(spec.getExchangeId(), spec.getContractCode(), expiry, variant); return EtdFutureSecurity.builder() .info(SecurityInfo.of(securityId, spec.getPriceInfo())) .contractSpecId(spec.getId()) .expiry(expiry) .variant(variant) .build(); }
spec.getExchangeId(), spec.getContractCode(), expiry, variant, version, putCall, strikePrice, underlyingExpiryMonth); return EtdOptionSecurity.builder() .info(SecurityInfo.of(securityId, spec.getPriceInfo())) .contractSpecId(spec.getId()) .expiry(expiry)