public void test_futureId_monthly() { SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "F-ECAG-FGBS-201706")); }
public void test_optionId_monthly() { SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY, 0, PutCall.PUT, 12.34); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706-P12.34")); }
/** * Builds a new specification from the data in this builder. * * @return a specification instance built from the data in this builder */ public EtdContractSpec build() { if (id == null) { id = EtdIdUtils.contractSpecId(type, exchangeId, contractCode); } return new EtdContractSpec(id, type, exchangeId, contractCode, description, priceInfo, attributes); }
.id(StandardId.of("OG", "123421")) .build()) .securityId(EtdIdUtils.futureId(ExchangeIds.ECAG, FGBL, YearMonth.of(2017, 6), EtdVariant.ofMonthly())) .longQuantity(15d) .shortQuantity(2d) .id(StandardId.of("OG", "123422")) .build()) .securityId(EtdIdUtils.futureId( ExchangeIds.ECAG, FGBL, YearMonth.of(2017, 6), EtdVariant.ofFlexFuture(13, EtdSettlementType.CASH))) .longQuantity(0d) .id(StandardId.of("OG", "123423")) .build()) .securityId(EtdIdUtils.futureId(ExchangeIds.ECAG, FGBL, YearMonth.of(2017, 6), EtdVariant.ofWeekly(2))) .longQuantity(0d) .shortQuantity(20d) .id(StandardId.of("OG", "123424")) .build()) .securityId(EtdIdUtils.futureId(ExchangeIds.ECAG, FGBL, YearMonth.of(2017, 6), EtdVariant.ofDaily(3))) .longQuantity(30d) .shortQuantity(0d) .id(StandardId.of("OG", "123431")) .build()) .securityId(EtdIdUtils.optionId( ExchangeIds.ECAG, OGBL, YearMonth.of(2017, 6), EtdVariant.ofMonthly(), 0, PutCall.PUT, 3d, YearMonth.of(2017, 9))) .longQuantity(15d)
double strikePrice) { return optionId(exchangeId, contractCode, expiryMonth, variant, version, putCall, strikePrice, null);
public void test_futureId_flex() { SecurityId test = EtdIdUtils.futureId( ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofFlexFuture(26, EtdSettlementType.DERIVATIVE)); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "F-ECAG-FGBS-20170626D")); }
/** * Parses the contract specification from the row. * * @param row the CSV row to parse * @param type the ETD type * @return the contract specification * @throws IllegalArgumentException if the specification is not found */ public default EtdContractSpec parseEtdContractSpec(CsvRow row, EtdType type) { ExchangeId exchangeId = ExchangeId.of(row.getValue(EXCHANGE_FIELD)); EtdContractCode contractCode = EtdContractCode.of(row.getValue(CONTRACT_CODE_FIELD)); EtdContractSpecId specId = EtdIdUtils.contractSpecId(type, exchangeId, contractCode); return getReferenceData().findValue(specId).orElseThrow( () -> new IllegalArgumentException("ETD contract specification not found in reference data: " + specId)); }
public void test_optionIdUnderlying_monthly() { SecurityId test = EtdIdUtils.optionId( ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY, 0, PutCall.PUT, 12.34, YearMonth.of(2017, 9)); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706-P12.34-U201709")); }
public void test_futureId_weekly() { SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofWeekly(2)); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "F-ECAG-FGBS-201706W2")); }
public void test_contractSpecId_option() { EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.OPTION, ExchangeIds.ECAG, OGBS); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-OGBS")); }
public void test_optionIdUnderlying_monthlySameMonth() { SecurityId test = EtdIdUtils.optionId( ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY, 0, PutCall.PUT, 12.34, YearMonth.of(2017, 6)); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706-P12.34")); }
public void test_futureId_daily() { SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(2)); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "F-ECAG-FGBS-20170602")); }
public void test_contractSpecId_future() { EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.FUTURE, ExchangeIds.ECAG, FGBS); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "F-ECAG-FGBS")); }
public 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.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706W3-CM1.45")); }
/** * 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(); }
public void test_optionId_daily9_version() { SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(9), 3, PutCall.PUT, 12.34); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-20170609-V3-P12.34")); }
/** * Parses an ETD future position from the CSV row without using reference data. * <p> * This returns a {@link SecurityPosition} based on a standard ETD identifier from {@link EtdIdUtils}. * * @param row the CSV row to parse * @param info the position information * @return the loaded positions, position-level errors are captured in the result * @throws IllegalArgumentException if the row cannot be parsed */ public default SecurityPosition parseEtdFutureSecurityPosition(CsvRow row, PositionInfo info) { ExchangeId exchangeId = ExchangeId.of(row.getValue(EXCHANGE_FIELD)); EtdContractCode contractCode = EtdContractCode.of(row.getValue(CONTRACT_CODE_FIELD)); Pair<YearMonth, EtdVariant> variant = CsvLoaderUtils.parseEtdVariant(row, EtdType.FUTURE); SecurityId securityId = EtdIdUtils.futureId(exchangeId, contractCode, variant.getFirst(), variant.getSecond()); DoublesPair quantity = CsvLoaderUtils.parseQuantity(row); SecurityPosition position = SecurityPosition.ofLongShort(info, securityId, quantity.getFirst(), quantity.getSecond()); return completePosition(row, position); }
public 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.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-20170621-V11-P12.34")); }
public 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.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-20170609-V3-P12.34-U201709")); }
public void test_optionIdUnderlying_weekly() { SecurityId test = EtdIdUtils.optionId( ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofWeekly(3), 0, PutCall.CALL, -1.45, YearMonth.of(2017, 9)); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706W3-CM1.45-U201709")); }