/** * 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); }
/** * 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_contractSpecId_option() { EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.OPTION, ExchangeIds.ECAG, OGBS); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-OGBS")); }
public void test_contractSpecId_future() { EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.FUTURE, ExchangeIds.ECAG, FGBS); assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "F-ECAG-FGBS")); }