예제 #1
1
  public void testUpdateTimeSeriesAddNewLaterPointsOnly() {
    // Add the test series
    testAddTimeSeries();

    List<LocalDate> dates = ImmutableList.of(_today.plusDays(1));
    List<Double> values = ImmutableList.of(4d);
    ArrayLocalDateDoubleTimeSeries newTs = new ArrayLocalDateDoubleTimeSeries(dates, values);
    UniqueId id =
        _htsWriter.writeTimeSeries(
            DESCRIPTION,
            DATA_SOURCE,
            DATA_PROVIDER,
            DATA_FIELD,
            OBSERVATION_TIME,
            ExternalIdBundle.of(ID),
            newTs);

    ManageableHistoricalTimeSeries manageableTs = _htsMaster.getTimeSeries(id);
    LocalDateDoubleTimeSeries readTs = manageableTs.getTimeSeries();
    List<LocalDate> expectedDates =
        ImmutableList.of(_today.minusDays(2), _today.minusDays(1), _today, _today.plusDays(1));
    List<Double> expectedValues = ImmutableList.of(1d, 2d, 3d, 4d);
    ArrayLocalDateDoubleTimeSeries expectedTs =
        new ArrayLocalDateDoubleTimeSeries(expectedDates, expectedValues);
    assertEquals(expectedTs, readTs);
  }
예제 #2
0
  public void testAddUpdateTimeSeriesSingleExistingPoint() {
    List<LocalDate> dates = ImmutableList.of(_today);
    List<Double> origValues = ImmutableList.of(1d);
    ArrayLocalDateDoubleTimeSeries origTs = new ArrayLocalDateDoubleTimeSeries(dates, origValues);
    UniqueId id =
        _htsWriter.writeTimeSeries(
            DESCRIPTION,
            DATA_SOURCE,
            DATA_PROVIDER,
            DATA_FIELD,
            OBSERVATION_TIME,
            ExternalIdBundle.of(ID),
            origTs);

    ManageableHistoricalTimeSeries manageableTs = _htsMaster.getTimeSeries(id);
    LocalDateDoubleTimeSeries readTs = manageableTs.getTimeSeries();
    assertEquals(origTs, readTs);

    List<Double> updatedValues = ImmutableList.of(2d);
    ArrayLocalDateDoubleTimeSeries updatedTs =
        new ArrayLocalDateDoubleTimeSeries(dates, updatedValues);
    id =
        _htsWriter.writeTimeSeries(
            DESCRIPTION,
            DATA_SOURCE,
            DATA_PROVIDER,
            DATA_FIELD,
            OBSERVATION_TIME,
            ExternalIdBundle.of(ID),
            updatedTs);

    manageableTs = _htsMaster.getTimeSeries(id);
    readTs = manageableTs.getTimeSeries();
    assertEquals(updatedTs, readTs);
  }
  @Test
  public void multiThreadedSecurityRequest() throws Exception {

    ExternalIdBundle apvKey =
        ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId(APV_EQUITY_OPTION_TICKER));
    ExternalIdBundle spxKey =
        ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId(SPX_INDEX_OPTION_TICKER));
    ExternalIdBundle aaplKey =
        ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId(AAPL_EQUITY_TICKER));
    ExternalIdBundle attKey =
        ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId(ATT_EQUITY_TICKER));

    ExecutorService pool = Executors.newFixedThreadPool(4);
    List<Future<Security>> apvresults = new ArrayList<Future<Security>>();
    List<Future<Security>> spxresults = new ArrayList<Future<Security>>();
    List<Future<Security>> aaplresults = new ArrayList<Future<Security>>();
    List<Future<Security>> attresults = new ArrayList<Future<Security>>();

    for (int i = 0; i < 10; i++) {
      apvresults.add(pool.submit(new BSMGetSecurityCallable(apvKey)));
      spxresults.add(pool.submit(new BSMGetSecurityCallable(spxKey)));
      aaplresults.add(pool.submit(new BSMGetSecurityCallable(aaplKey)));
      attresults.add(pool.submit(new BSMGetSecurityCallable(attKey)));
    }

    for (Future<Security> future : apvresults) {
      // Check that each one didn't throw an exception and returns the expected
      // APV security
      Security sec = future.get();
      assertAmericanVanillaEquityOptionSecurity(EXPECTED_APVL_EQUITYOPTION_SEC, sec);
    }

    for (Future<Security> future : spxresults) {
      // Check that each one didn't throw an exception and returns the expected
      // SPX security
      Security sec = future.get();
      assertEuropeanVanillaEquityIndexOptionSecurity(EXPECTED_SPX_INDEXOPTION_SEC, sec);
    }

    for (Future<Security> future : aaplresults) {
      // Check that each one didn't throw an exception and returns the expected
      // AAPL security
      Security sec = future.get();
      assertEquitySecurity(EXPECTED_AAPL_EQUITY_SEC, sec);
    }

    for (Future<Security> future : attresults) {
      // Check that each one didn't throw an exception and returns the expected
      // AT&T security
      Security sec = future.get();
      assertEquitySecurity(EXPECTED_ATT_EQUITY_SEC, sec);
    }
  }
 // -------------------------------------------------------------------------
 protected ManageableExchange example() {
   ManageableExchange exchange = new ManageableExchange();
   exchange.setUniqueId(UID);
   exchange.setName("NYSE");
   exchange.setRegionIdBundle(ExternalIdBundle.of(ExternalSchemes.countryRegionId(Country.US)));
   return exchange;
 }
 public static ValueRequirement getValueRequirement(
     SecuritySource secMaster, final UnderlyingType underlying, final Security security) {
   if (security instanceof EquityOptionSecurity) {
     final EquityOptionSecurity option = (EquityOptionSecurity) security;
     switch (underlying) {
       case SPOT_PRICE:
         Security optionUnderlying =
             secMaster.getSecurity(ExternalIdBundle.of(option.getUnderlyingId()));
         return new ValueRequirement(
             MarketDataRequirementNames.MARKET_VALUE,
             ComputationTargetType.SECURITY,
             optionUnderlying.getUniqueId());
       case SPOT_VOLATILITY:
         throw new NotImplementedException(
             "Don't know how to get spot volatility for " + option.getUniqueId());
       case IMPLIED_VOLATILITY:
         throw new NotImplementedException(
             "Don't know how to get implied volatility for " + option.getUniqueId());
       case INTEREST_RATE:
         return new ValueRequirement(
             ValueRequirementNames.YIELD_CURVE,
             ComputationTargetType.PRIMITIVE,
             option.getUniqueId());
       case COST_OF_CARRY:
         throw new NotImplementedException(
             "Don't know how to get cost of carry for " + option.getUniqueId());
       default:
         throw new NotImplementedException(
             "Don't know how to get ValueRequirement for " + underlying);
     }
   }
   throw new NotImplementedException(
       "Can only get ValueRequirements for options (was " + security + ")");
 }
  // -------------------------------------------------------------------------
  @SuppressWarnings({"rawtypes", "unchecked"})
  @Test
  public void testSearchBonds() {
    BondSecurity target =
        new GovernmentBondSecurity(
            "US TREASURY N/B",
            "Government",
            "US",
            "Treasury",
            Currency.USD,
            YieldConventionFactory.INSTANCE.getYieldConvention("US Treasury equivalent"),
            new Expiry(zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC)),
            "",
            200,
            SimpleFrequencyFactory.INSTANCE.getFrequency(SimpleFrequency.SEMI_ANNUAL_NAME),
            DayCountFactory.INSTANCE.getDayCount("Actual/Actual"),
            zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC),
            zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC),
            zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC),
            100d,
            100000000,
            5000,
            1000,
            100,
            100);
    target.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B")));
    Collection targetColl = ImmutableList.<Security>of(target);

    when(_underlying.getBondsWithIssuerName(eq("US TREASURY N/B"))).thenReturn(targetColl);

    Response test = _resource.searchBonds("US TREASURY N/B");
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
    assertEquals(FudgeListWrapper.of(targetColl), test.getEntity());
  }
  @Override
  public String classifyPosition(final Position position) {
    final Security security = resolveSecurity(position);
    if (security instanceof CreditDefaultSwapOptionSecurity) {
      final CreditDefaultSwapOptionSecurity cdsOption = (CreditDefaultSwapOptionSecurity) security;
      final ExternalId underlyingId = cdsOption.getUnderlyingId();
      final Security underlying = _securitySource.getSingle(underlyingId.toBundle());
      final String redCode =
          ((CreditDefaultSwapSecurity) underlying).getReferenceEntity().getValue();
      final Organization organisation = _organizationSource.getOrganizationByRedCode(redCode);
      return organisation.getObligor().getObligorShortName();

    } else if (security instanceof CreditDefaultSwapIndexSecurity) {
      final CreditDefaultSwapIndexSecurity cdsIndex = (CreditDefaultSwapIndexSecurity) security;
      final CreditDefaultSwapIndexDefinitionSecurity definition =
          (CreditDefaultSwapIndexDefinitionSecurity)
              _securitySource.getSingle(ExternalIdBundle.of(cdsIndex.getReferenceEntity()));
      return definition.getName();
    } else if (security instanceof CreditDefaultSwapSecurity) {
      final AbstractCreditDefaultSwapSecurity cds = (AbstractCreditDefaultSwapSecurity) security;
      final String redCode = cds.getReferenceEntity().getValue();
      final Organization organisation = _organizationSource.getOrganizationByRedCode(redCode);
      if (organisation != null) {
        return organisation.getObligor().getObligorShortName();
      } else {
        return redCode;
      }
    }

    return NOT_APPLICABLE;
  }
 @Test
 public void attEquityByBbgUnique() throws Exception {
   ExternalId bloombergIdentifier =
       getBloombergIdentifier(EXPECTED_ATT_EQUITY_SEC, ExternalSchemes.BLOOMBERG_BUID);
   Security sec = _securityProvider.getSecurity(ExternalIdBundle.of(bloombergIdentifier));
   assertEquitySecurity(EXPECTED_ATT_EQUITY_SEC, sec);
 }
 @Test
 public void invalidSecurity() throws Exception {
   ExternalIdBundle invalidKey =
       ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("INVALID"));
   Security sec = _securityProvider.getSecurity(invalidKey);
   assertNull(sec);
 }
 @Test
 public void spxIndexOptionByBbgUnique() throws Exception {
   ExternalId bloombergIdentifier =
       getBloombergIdentifier(EXPECTED_SPX_INDEXOPTION_SEC, ExternalSchemes.BLOOMBERG_BUID);
   Security sec = _securityProvider.getSecurity(ExternalIdBundle.of(bloombergIdentifier));
   assertEuropeanVanillaEquityIndexOptionSecurity(EXPECTED_SPX_INDEXOPTION_SEC, sec);
 }
 @Test
 public void apvEquityOptionByBbgUnique() throws Exception {
   ExternalId bloombergIdentifier =
       getBloombergIdentifier(EXPECTED_APVL_EQUITYOPTION_SEC, ExternalSchemes.BLOOMBERG_BUID);
   Security sec = _securityProvider.getSecurity(ExternalIdBundle.of(bloombergIdentifier));
   assertAmericanVanillaEquityOptionSecurity(EXPECTED_APVL_EQUITYOPTION_SEC, sec);
 }
 @Override
 public List<ExternalId> visitIRFutureOptionSecurity(final IRFutureOptionSecurity security) {
   final FutureSecurity underlyingSecurity =
       (FutureSecurity)
           _securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId()));
   return getContractType(underlyingSecurity);
 }
 private ExternalIdBundle getIndexIdForSwap(final FloatingInterestRateLeg floatingLeg) {
   if (floatingLeg.getFloatingRateType().isIbor()
       || floatingLeg.getFloatingRateType().equals(FloatingRateType.OIS)
       || floatingLeg.getFloatingRateType().equals(FloatingRateType.CMS)) {
     return getIndexIdBundle(floatingLeg.getFloatingReferenceRateId());
   }
   return ExternalIdBundle.of(floatingLeg.getFloatingReferenceRateId());
 }
 @Test
 public void invalidSecurities() throws Exception {
   ExternalIdBundle invalidKey =
       ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("INVALID"));
   Map<ExternalIdBundle, Security> securities =
       _securityProvider.getSecurities(ImmutableSet.of(invalidKey));
   assertNotNull(securities);
   assertTrue(securities.isEmpty());
 }
 public void testGetPreferred_default() {
   assertEquals(
       ExternalIdOrderConfig.DEFAULT_CONFIG.getPreferred(
           ExternalIdBundle.of(
               ExternalId.of(ExternalSchemes.BLOOMBERG_TCM, "tcm"),
               ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, "ticker"),
               ExternalId.of("Foo", "Bar"))),
       ExternalId.of(ExternalSchemes.BLOOMBERG_TCM, "tcm"));
 }
 @Test(enabled = false)
 public void currencyFuture() throws Exception {
   ExternalIdBundle id =
       ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("LNM0 Curncy"));
   Security audUsd = _securityProvider.getSecurity(id);
   assertNotNull(audUsd);
   assertTrue(audUsd instanceof FXFutureSecurity);
   assertSecurity(EXPECTED_AUDUSD_FUTURE_SEC, audUsd);
 }
예제 #17
0
  @Test
  public void test_search_twoKeys_All_noMatch() {
    UserSearchRequest request = new UserSearchRequest();
    request.addExternalIds(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "H")));
    request.getExternalIdSearch().setSearchType(ExternalIdSearchType.ALL);
    UserSearchResult test = _usrMaster.search(request);

    assertEquals(0, test.getDocuments().size());
  }
예제 #18
0
  @BeforeMethod
  public void configureService() {
    MockFinancialSecuritySource securitySource = new MockFinancialSecuritySource();
    ExternalId secId1 = ExternalId.of(ExternalScheme.of("d1"), "v1");
    ExternalId secId2 = ExternalId.of(ExternalScheme.of("d2"), "v2");

    MockSecurity sec1 = new MockSecurity("t1");
    sec1.setExternalIdBundle(ExternalIdBundle.of(secId1));
    sec1.setSecurityType("BOND");
    securitySource.addSecurity(sec1);

    MockSecurity sec2 = new MockSecurity("t2");
    sec2.setExternalIdBundle(ExternalIdBundle.of(secId2));
    securitySource.addSecurity(sec2);

    BondSecurity bondSec =
        new GovernmentBondSecurity(
            "US TREASURY N/B",
            "Government",
            "US",
            "Treasury",
            Currency.USD,
            YieldConventionFactory.INSTANCE.getYieldConvention("US Treasury equivalent"),
            new Expiry(ZonedDateTime.of(2011, 2, 1, 12, 0, 0, 0, TimeZone.UTC)),
            "",
            200,
            SimpleFrequencyFactory.INSTANCE.getFrequency(SimpleFrequency.SEMI_ANNUAL_NAME),
            DayCountFactory.INSTANCE.getDayCount("Actual/Actual"),
            ZonedDateTime.of(2011, 2, 1, 12, 0, 0, 0, TimeZone.UTC),
            ZonedDateTime.of(2011, 2, 1, 12, 0, 0, 0, TimeZone.UTC),
            ZonedDateTime.of(2011, 2, 1, 12, 0, 0, 0, TimeZone.UTC),
            100,
            100000000,
            5000,
            1000,
            100,
            100);
    bondSec.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B")));
    securitySource.addSecurity(bondSec);

    getSecuritySourceService().setUnderlying(securitySource);
    _uid1 = sec1.getUniqueId();
    _uid2 = sec2.getUniqueId();
  }
 public static ManageableRegion getTestRegion() {
   final ManageableRegion region = new ManageableRegion();
   region.setUniqueId(UniqueId.parse("Dummy~region"));
   region.setName("United States");
   region.setCurrency(Currency.USD);
   region.setCountry(Country.US);
   region.setTimeZone(ZoneId.of("America/New_York"));
   region.setExternalIdBundle(ExternalIdBundle.of(ExternalId.parse("dummy~region")));
   return region;
 }
  // -------------------------------------------------------------------------
  @Test
  public void test_addAndGet() throws Exception {
    MockConvention cnv =
        new MockConvention("London", ExternalIdBundle.of("Test", "OG"), Currency.GBP);
    ConventionDocument addDoc = new ConventionDocument(cnv);
    ConventionDocument added = _cnvMaster.add(addDoc);

    ConventionDocument loaded = _cnvMaster.get(added.getUniqueId());
    assertEquals(added, loaded);
  }
 private ManageableSecurity loadSecurity(final ExternalId ticker) {
   final ExternalIdBundle tickerBundle = ExternalIdBundle.of(ticker);
   final Collection<ExternalIdBundle> bundles = Collections.singleton(tickerBundle);
   final Map<ExternalIdBundle, UniqueId> loaded =
       getToolContext().getSecurityLoader().loadSecurities(bundles);
   final UniqueId loadedSec = loaded.get(tickerBundle);
   if (loadedSec == null) {
     throw new OpenGammaRuntimeException("Failed to load security for " + ticker);
   }
   return getToolContext().getSecurityMaster().get(loadedSec).getSecurity();
 }
 @Override
 public List<ExternalId> visitCreditDefaultSwapOptionSecurity(
     final CreditDefaultSwapOptionSecurity security) {
   final CreditDefaultSwapSecurity underlyingCDS =
       (CreditDefaultSwapSecurity)
           _securitySource.getSingle(
               ExternalIdBundle.of(security.getUnderlyingId())); // TODO version
   final ExternalId regionId = underlyingCDS.getRegionId();
   final String securityType = security.getSecurityType();
   return Arrays.asList(
       ExternalId.of(SECURITY_IDENTIFIER, securityType + SEPARATOR + regionId.getValue()));
 }
  private InterestRateSwapSecurity createFixedVsLibor3mSwap() {

    InterestRateSwapNotional notional = new InterestRateSwapNotional(Currency.USD, 100_000_000);
    PeriodFrequency freq6m = PeriodFrequency.of(Period.ofMonths(6));
    PeriodFrequency freq3m = PeriodFrequency.of(Period.ofMonths(3));
    Set<ExternalId> calendarUSNY =
        Sets.newHashSet(ExternalId.of(ExternalSchemes.ISDA_HOLIDAY, "USNY"));
    List<InterestRateSwapLeg> legs = new ArrayList<>();

    FixedInterestRateSwapLeg payLeg = new FixedInterestRateSwapLeg();
    payLeg.setNotional(notional);
    payLeg.setDayCountConvention(DayCounts.THIRTY_U_360);
    payLeg.setPaymentDateFrequency(freq6m);
    payLeg.setPaymentDateBusinessDayConvention(BusinessDayConventions.MODIFIED_FOLLOWING);
    payLeg.setPaymentDateCalendars(calendarUSNY);
    payLeg.setMaturityDateBusinessDayConvention(BusinessDayConventions.MODIFIED_FOLLOWING);
    payLeg.setAccrualPeriodFrequency(freq6m);
    payLeg.setAccrualPeriodBusinessDayConvention(BusinessDayConventions.MODIFIED_FOLLOWING);
    payLeg.setAccrualPeriodCalendars(calendarUSNY);
    payLeg.setRate(new Rate(0.0150));
    payLeg.setPayReceiveType(PayReceiveType.PAY);
    legs.add(payLeg);

    FloatingInterestRateSwapLeg receiveLeg = new FloatingInterestRateSwapLeg();
    receiveLeg.setNotional(notional);
    receiveLeg.setDayCountConvention(DayCounts.ACT_360);
    receiveLeg.setPaymentDateFrequency(freq3m);
    receiveLeg.setPaymentDateBusinessDayConvention(BusinessDayConventions.MODIFIED_FOLLOWING);
    receiveLeg.setPaymentDateCalendars(calendarUSNY);
    receiveLeg.setMaturityDateBusinessDayConvention(BusinessDayConventions.MODIFIED_FOLLOWING);
    receiveLeg.setAccrualPeriodFrequency(freq3m);
    receiveLeg.setAccrualPeriodBusinessDayConvention(BusinessDayConventions.MODIFIED_FOLLOWING);
    receiveLeg.setAccrualPeriodCalendars(calendarUSNY);
    receiveLeg.setResetPeriodFrequency(freq3m);
    receiveLeg.setResetPeriodBusinessDayConvention(BusinessDayConventions.MODIFIED_FOLLOWING);
    receiveLeg.setResetPeriodCalendars(calendarUSNY);
    receiveLeg.setFixingDateBusinessDayConvention(BusinessDayConventions.PRECEDING);
    receiveLeg.setFixingDateCalendars(calendarUSNY);
    receiveLeg.setFixingDateOffset(-2);
    receiveLeg.setFloatingRateType(FloatingRateType.IBOR);
    receiveLeg.setFloatingReferenceRateId(InterestRateMockSources.getLiborIndexId());
    receiveLeg.setPayReceiveType(PayReceiveType.RECEIVE);

    legs.add(receiveLeg);

    return new InterestRateSwapSecurity(
        ExternalIdBundle.of(ExternalId.of("UUID", GUIDGenerator.generate().toString())),
        "Fixed vs Libor 3m",
        LocalDate.of(2014, 9, 12), // effective date
        LocalDate.of(2021, 9, 12), // maturity date,
        legs);
  }
예제 #24
0
 public static void addCorporateBondConvention(final ConventionBundleMaster conventionMaster) {
   Validate.notNull(conventionMaster, "convention master");
   conventionMaster.addConventionBundle(
       ExternalIdBundle.of(
           ExternalId.of(
               InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "GB_CORPORATE_BOND_CONVENTION")),
       "GB_CORPORATE_BOND_CONVENTION",
       false,
       true,
       6,
       0,
       true);
 }
  // -------------------------------------------------------------------------
  @Test(enabled = false)
  public void test_equity() throws Exception {
    EquitySecurity sec = new EquitySecurity("London", "LON", "OpenGamma Ltd", Currency.GBP);
    sec.setName("OpenGamma");
    sec.setGicsCode(GICSCode.of("20102010"));
    sec.setShortName("OG");
    sec.setExternalIdBundle(ExternalIdBundle.of("Test", "OG"));
    SecurityDocument addDoc = new SecurityDocument(sec);
    SecurityDocument added = _secMaster.add(addDoc);

    SecurityDocument loaded = _secMaster.get(added.getUniqueId());
    assertEquals(added, loaded);
  }
예제 #26
0
 public static void addTreasuryBondConvention(final ConventionBundleMaster conventionMaster) {
   Validate.notNull(conventionMaster, "convention master");
   final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);
   utils.addConventionBundle(
       ExternalIdBundle.of(simpleNameSecurityId("CA_TREASURY_BOND_CONVENTION")),
       "CA_TREASURY_BOND_CONVENTION",
       true,
       true,
       0,
       2,
       3,
       true,
       Tenor.TWO_YEARS);
 }
예제 #27
0
 public static void addCorporateBondConvention(final ConventionBundleMaster conventionMaster) {
   Validate.notNull(conventionMaster, "conventionMaster");
   final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);
   utils.addConventionBundle(
       ExternalIdBundle.of(
           ExternalId.of(
               InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CH_CORPORATE_BOND_CONVENTION")),
       "HU_CORPORATE_BOND_CONVENTION",
       true,
       true,
       0,
       3,
       true);
 }
 @Test(groups = {"bbgSecurityFutureTests"})
 public void euroBondFuture() throws Exception {
   ExternalIdBundle euroBund =
       ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("RXA Comdty"));
   Security bond = _securityProvider.getSecurity(euroBund);
   assertNotNull(bond);
   assertTrue(bond instanceof BondFutureSecurity);
   BondFutureSecurity euroBondFuture = (BondFutureSecurity) bond;
   assertEquals("FUTURE", euroBondFuture.getSecurityType());
   assertEquals("Bond", euroBondFuture.getContractCategory());
   assertEquals(EUR, euroBondFuture.getCurrency());
   String displayName = euroBondFuture.getName();
   assertNotNull(displayName);
   assertTrue(displayName.contains("EURO-BUND FUTURE"));
   Expiry expiry = euroBondFuture.getExpiry();
   assertNotNull(expiry);
   assertTrue(expiry.toInstant().isAfter(getTodayInstant()));
   assertEquals("XEUR", euroBondFuture.getTradingExchange());
   assertEquals("XEUR", euroBondFuture.getSettlementExchange());
   // assert identifiers are set
   Collection<ExternalId> identifiers = euroBondFuture.getExternalIdBundle().getExternalIds();
   assertNotNull(identifiers);
   assertTrue(identifiers.size() >= EXPECTED_IDENTIFICATION_SCHEME.length);
   ExternalIdBundle identifierBundle = ExternalIdBundle.of(identifiers);
   for (ExternalScheme expectedIDScheme : EXPECTED_IDENTIFICATION_SCHEME) {
     assertNotNull(identifierBundle.getExternalId(expectedIDScheme));
   }
   // assert deliverables are not empty
   Collection<BondFutureDeliverable> basket = euroBondFuture.getBasket();
   assertNotNull(basket);
   for (BondFutureDeliverable bondFutureDeliverable : basket) {
     ExternalIdBundle bundle = bondFutureDeliverable.getIdentifiers();
     assertNotNull(bundle);
     assertNotNull(bundle.getExternalId(ExternalSchemes.BLOOMBERG_BUID));
     assertTrue(bondFutureDeliverable.getConversionFactor() > 0);
   }
 }
예제 #29
0
 public static void addBondFutureConvention(final ConventionBundleMaster conventionMaster) {
   Validate.notNull(conventionMaster, "convention master");
   conventionMaster.addConventionBundle(
       ExternalIdBundle.of(
           ExternalId.of(
               InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME,
               "GBP_BOND_FUTURE_DELIVERABLE_CONVENTION")),
       "GBP_BOND_FUTURE_DELIVERABLE_CONVENTION",
       true,
       true,
       7,
       0,
       DayCountFactory.INSTANCE.getDayCount("Actual/365"),
       BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"),
       SimpleYieldConvention.MONEY_MARKET);
 }
 protected void assert202(final SecurityDocument test) {
   UniqueId uniqueId = UniqueId.of("DbSec", "201", "1");
   assertNotNull(test);
   assertEquals(uniqueId, test.getUniqueId());
   assertEquals(_version2Instant, test.getVersionFromInstant());
   assertEquals(null, test.getVersionToInstant());
   assertEquals(_version2Instant, test.getCorrectionFromInstant());
   assertEquals(null, test.getCorrectionToInstant());
   ManageableSecurity security = test.getSecurity();
   assertNotNull(security);
   assertEquals(uniqueId, security.getUniqueId());
   assertEquals("TestSecurity202", security.getName());
   assertEquals("EQUITY", security.getSecurityType());
   assertEquals(
       ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")),
       security.getExternalIdBundle());
 }