Пример #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);
  }
Пример #3
0
 /**
  * Gets the best descriptive name.
  *
  * @return the best descriptive name, not null
  */
 public String getBestName() {
   Security security = getTarget();
   ObjectId objectId = getObjectId();
   ExternalIdBundle bundle = getExternalId();
   if (security != null) {
     // Try to retrieve the security's assigned name
     String name = security.getName();
     if (StringUtils.isNotBlank(name)) {
       return name;
     }
     bundle = security.getExternalIdBundle();
   }
   if (bundle != null && bundle.size() > 0) {
     if (bundle.getValue(ExternalSchemes.BLOOMBERG_TICKER) != null) {
       return bundle.getValue(ExternalSchemes.BLOOMBERG_TICKER);
     } else if (bundle.getValue(ExternalSchemes.RIC) != null) {
       return bundle.getValue(ExternalSchemes.RIC);
     } else if (bundle.getValue(ExternalSchemes.ACTIVFEED_TICKER) != null) {
       return bundle.getValue(ExternalSchemes.ACTIVFEED_TICKER);
     } else {
       return bundle.getExternalIds().iterator().next().getValue();
     }
   }
   if (objectId != null) {
     return objectId.toString();
   }
   return "";
 }
  @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);
    }
  }
  // -------------------------------------------------------------------------
  @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());
  }
 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 + ")");
 }
  private HistoricalTimeSeriesInfoDocument getOrLoadTimeSeries(
      final ExternalId ticker, final ExternalIdBundle idBundle) {

    final ExternalIdBundle searchBundle =
        idBundle.withoutScheme(
            ExternalSchemes
                .ISIN); // For things which move country, e.g. ISIN(VALE5 BZ Equity) == ISIN(RIODF
                        // US Equity)
    final HistoricalTimeSeriesInfoSearchRequest htsRequest =
        new HistoricalTimeSeriesInfoSearchRequest(searchBundle);
    htsRequest.setDataField("PX_LAST");
    final HistoricalTimeSeriesInfoSearchResult htsSearch =
        getToolContext().getHistoricalTimeSeriesMaster().search(htsRequest);
    switch (htsSearch.getDocuments().size()) {
      case 0:
        return loadTimeSeries(idBundle);
      case 1:
        break;
      default:
        throw new OpenGammaRuntimeException("Multiple time series match " + htsSearch);
    }
    final HistoricalTimeSeriesInfoDocument timeSeriesInfo = htsSearch.getDocuments().get(0);
    s_logger.debug("Loaded time series info {} for underlying {}", timeSeriesInfo, ticker);
    return timeSeriesInfo;
  }
  @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;
  }
 @Override
 public List<ExternalId> visitIRFutureOptionSecurity(final IRFutureOptionSecurity security) {
   final FutureSecurity underlyingSecurity =
       (FutureSecurity)
           _securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId()));
   return getContractType(underlyingSecurity);
 }
 // deprecated
 // -------------------------------------------------------------------------
 @GET
 @Path("exchangeSearches/single")
 public Response searchSingle(@QueryParam("id") List<String> externalIdStrs) {
   final ExternalIdBundle bundle = ExternalIdBundle.parse(externalIdStrs);
   Exchange result = getExchangeSource().getSingleExchange(bundle);
   return responseOkFudge(result);
 }
 @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);
 }
 // -------------------------------------------------------------------------
 protected ManageableExchange example() {
   ManageableExchange exchange = new ManageableExchange();
   exchange.setUniqueId(UID);
   exchange.setName("NYSE");
   exchange.setRegionIdBundle(ExternalIdBundle.of(ExternalSchemes.countryRegionId(Country.US)));
   return exchange;
 }
 @Test
 public void invalidSecurity() throws Exception {
   ExternalIdBundle invalidKey =
       ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("INVALID"));
   Security sec = _securityProvider.getSecurity(invalidKey);
   assertNull(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);
 }
 @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);
 }
Пример #16
0
 /**
  * Resolves the security using a security source.
  *
  * @param source the source to use to resolve, not null
  * @param versionCorrection the version-correction, not null
  * @return the resolved security, not null
  * @throws DataNotFoundException if the security could not be resolved
  * @throws RuntimeException if an error occurs while resolving
  */
 public Security resolve(SecuritySource source, VersionCorrection versionCorrection) {
   ObjectId objectId = getObjectId();
   if (objectId != null) {
     Security target = source.getSecurity(objectId, versionCorrection);
     setTarget(target);
     return target;
   }
   ExternalIdBundle bundle = getExternalId();
   if (bundle.size() > 0) {
     Security target = source.getSecurity(bundle, versionCorrection);
     if (target != null) {
       setTarget(target);
       return target;
     }
   }
   throw new DataNotFoundException("Unable to resolve security: " + getBestName());
 }
 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());
 }
 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
 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());
 }
 @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);
 }
 /**
  * Builds a URI.
  *
  * @param baseUri the base URI, not null
  * @param vc the version-correction, null means latest
  * @param bundle the bundle, may be null
  * @return the URI, not null
  */
 public static URI uriSearch(URI baseUri, VersionCorrection vc, ExternalIdBundle bundle) {
   UriBuilder bld = UriBuilder.fromUri(baseUri).path("exchanges");
   if (vc != null) {
     bld.queryParam("versionAsOf", vc.getVersionAsOfString());
     bld.queryParam("correctedTo", vc.getCorrectedToString());
   }
   bld.queryParam("id", bundle.toStringList().toArray());
   return bld.build();
 }
Пример #22
0
 /**
  * Checks if this bundle contains any key from the specified bundle.
  *
  * @param bundle the bundle to search for, empty returns false, not null
  * @return true if this bundle contains any key from the specified bundle
  */
 public boolean containsAny(final ExternalIdBundle bundle) {
   ArgumentChecker.notNull(bundle, "bundle");
   for (final ExternalId externalId : bundle.getExternalIds()) {
     if (_externalIds.contains(externalId)) {
       return true;
     }
   }
   return false;
 }
Пример #23
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());
  }
Пример #24
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();
  }
  // -------------------------------------------------------------------------
  @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);
  }
 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;
 }
 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();
 }
 // -------------------------------------------------------------------------
 @GET
 @Path("exchanges")
 public Response search(
     @QueryParam("versionAsOf") String versionAsOf,
     @QueryParam("correctedTo") String correctedTo,
     @QueryParam("id") List<String> externalIdStrs) {
   final VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo);
   final ExternalIdBundle bundle = ExternalIdBundle.parse(externalIdStrs);
   Collection<? extends Exchange> result = getExchangeSource().getExchanges(bundle, vc);
   return responseOkFudge(FudgeListWrapper.of(result));
 }
 @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);
  }