private Object readResolve() { return of(standardId); }
@Override public SecurityId getSecurityId() { return SecurityId.of(STANDARD_ID); }
public void test_equalsHashCode() { SecurityId a = SecurityId.of("A", "1"); SecurityId a2 = SecurityId.of("A", "1"); SecurityId b = SecurityId.of("B", "1"); assertEquals(a.equals(a), true); assertEquals(a.equals(a2), true); assertEquals(a.equals(b), false); assertEquals(a.equals(null), false); assertEquals(a.equals(ANOTHER_TYPE), false); }
private LocalDate calculateLastFixingDate(LocalDate valuationDate, ReferenceData refData) { SecurityId secId = SecurityId.of(rateId.getStandardId()); // quote must also be security IborFutureTrade trade = template.createTrade(valuationDate, secId, 1, 1, 1, refData); return trade.getProduct().getFixingDate(); }
@Override public IborFutureTrade trade(double quantity, MarketData marketData, ReferenceData refData) { LocalDate valuationDate = marketData.getValuationDate(); double price = marketPrice(marketData) + additionalSpread; SecurityId secId = SecurityId.of(rateId.getStandardId()); // quote must also be security return template.createTrade(valuationDate, secId, quantity, 1d, price, refData); }
private static SecurityTrade parseSecurityTrade(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver) { String securityIdScheme = row.findValue(SECURITY_ID_SCHEME_FIELD).orElse(DEFAULT_SECURITY_SCHEME); String securityIdValue = row.getValue(SECURITY_ID_FIELD); SecurityId securityId = SecurityId.of(securityIdScheme, securityIdValue); double price = LoaderUtils.parseDouble(row.getValue(PRICE_FIELD)); double quantity = parseTradeQuantity(row); return SecurityTrade.of(info, securityId, quantity, price); }
static SecurityPosition parseSecurityPosition(CsvRow row, PositionInfo info, PositionCsvInfoResolver resolver) { String securityIdScheme = row.findValue(SECURITY_ID_SCHEME_FIELD).orElse(DEFAULT_SECURITY_SCHEME); String securityIdValue = row.getValue(SECURITY_ID_FIELD); SecurityId securityId = SecurityId.of(securityIdScheme, securityIdValue); DoublesPair quantity = CsvLoaderUtils.parseQuantity(row); SecurityPosition position = SecurityPosition.ofLongShort(info, securityId, quantity.getFirst(), quantity.getSecond()); return resolver.completePosition(row, position); }
public void test_createTrade() { IborFutureTemplate base = IborFutureTemplate.of(MIN_PERIOD, NUMBER, CONVENTION); LocalDate date = LocalDate.of(2015, 10, 20); double quantity = 3; double price = 0.99; double notional = 100.0; SecurityId secId = SecurityId.of("OG-Future", "GBP-LIBOR-3M-Jun16"); IborFutureTrade trade = base.createTrade(date, secId, quantity, notional, price, REF_DATA); IborFutureTrade expected = CONVENTION.createTrade(date, secId, MIN_PERIOD, NUMBER, quantity, notional, price, REF_DATA); assertEquals(trade, expected); }
public void test_createTrade() { IborFutureTemplate base = IborFutureTemplate.of(YEAR_MONTH, CONVENTION); LocalDate date = LocalDate.of(2015, 10, 20); double quantity = 3; double price = 0.99; double notional = 100.0; SecurityId secId = SecurityId.of("OG-Future", "GBP-LIBOR-3M-Jun16"); IborFutureTrade trade = base.createTrade(date, secId, quantity, notional, price, REF_DATA); IborFutureTrade expected = CONVENTION.createTrade(date, secId, YEAR_MONTH, quantity, notional, price, REF_DATA); assertEquals(trade, expected); }
public void test_of_strings() { SecurityId test = SecurityId.of("A", "1"); assertEquals(test.getStandardId(), STANDARD_ID); assertEquals(test.getReferenceDataType(), Security.class); assertEquals(test.toString(), STANDARD_ID.toString()); }
public void test_of_standardId() { SecurityId test = SecurityId.of(STANDARD_ID); assertEquals(test.getStandardId(), STANDARD_ID); assertEquals(test.getReferenceDataType(), Security.class); assertEquals(test.toString(), STANDARD_ID.toString()); }
public void test_methods() { Position test = sut(); assertEquals(test.getId(), Optional.empty()); assertEquals(test.getInfo(), PositionInfo.empty()); assertEquals(test.getQuantity(), 123d); assertEquals(test.getSecurityId(), SecurityId.of(STANDARD_ID)); }
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()); }
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()); }
public void test_trade() { IborFutureCurveNode node = IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); double price = 0.99; MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, price).build(); IborFutureTrade trade = node.trade(1d, marketData, REF_DATA); IborFutureTrade expected = TEMPLATE.createTrade( VAL_DATE, SecurityId.of(STANDARD_ID), 1L, 1.0, price + SPREAD, REF_DATA); assertEquals(trade, expected); }
static EtdFutureSecurity sut() { return EtdFutureSecurity.builder() .info(SecurityInfo.of(SecurityId.of("A", "B"), SecurityPriceInfo.of(Currency.GBP, 100))) .contractSpecId(EtdContractSpecId.of("test", "123")) .expiry(YearMonth.of(2017, 6)) .build(); }
static EtdOptionSecurity sut() { return EtdOptionSecurity.builder() .info(SecurityInfo.of(SecurityId.of("A", "B"), SecurityPriceInfo.of(Currency.GBP, 100))) .contractSpecId(EtdContractSpecId.of("test", "123")) .expiry(YearMonth.of(2017, 6)) .putCall(PutCall.PUT) .strikePrice(2) .build(); }
static EtdFutureSecurity sut2() { return EtdFutureSecurity.builder() .info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10))) .contractSpecId(EtdContractSpecId.of("test", "234")) .expiry(YearMonth.of(2017, 9)) .variant(EtdVariant.ofWeekly(2)) .build(); }
static EtdOptionSecurity sut2() { return EtdOptionSecurity.builder() .info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10))) .contractSpecId(EtdContractSpecId.of("test", "234")) .expiry(YearMonth.of(2017, 9)) .variant(EtdVariant.ofWeekly(2)) .version(4) .putCall(PutCall.CALL) .strikePrice(3) .underlyingExpiryMonth(YearMonth.of(2017, 12)) .build(); }