@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);
    }
  }
 static {
   s_ref.setExternalIdBundle(
       ExternalId.of(ExternalSchemes.BLOOMBERG_INDEX_FAMILY, "ICE LIBOR USD").toBundle());
   SortedMap<Tenor, ExternalId> entries = new TreeMap<>();
   entries.put(Tenor.ON, ExternalSchemes.bloombergTickerSecurityId("US00O/N Index"));
   entries.put(Tenor.THREE_MONTHS, ExternalSchemes.bloombergTickerSecurityId("US0003M Index"));
   entries.put(Tenor.SIX_MONTHS, ExternalSchemes.bloombergTickerSecurityId("US0006M Index"));
   entries.put(Tenor.NINE_MONTHS, ExternalSchemes.bloombergTickerSecurityId("US0009M Index"));
   entries.put(Tenor.TWELVE_MONTHS, ExternalSchemes.bloombergTickerSecurityId("US0012M Index"));
   s_ref.setMembers(entries);
   s_ref.setName("ICE LIBOR USD");
   s_ref.addAttribute("Test", "Value");
 }
 /**
  * Returns AAPL equity security for testing
  *
  * @return the equity security
  */
 public static EquitySecurity getEquitySecurity() {
   EquitySecurity equitySecurity =
       new EquitySecurity("NASDAQ/NGS (GLOBAL SELECT MARKET)", "XNGS", "APPLE INC", Currency.USD);
   equitySecurity.addExternalId(ExternalSchemes.bloombergTickerSecurityId("AAPL US Equity"));
   equitySecurity.addExternalId(ExternalSchemes.bloombergBuidSecurityId("EQ0010169500001000"));
   equitySecurity.addExternalId(ExternalSchemes.cusipSecurityId("037833100"));
   equitySecurity.addExternalId(ExternalSchemes.isinSecurityId("US0378331005"));
   equitySecurity.addExternalId(ExternalSchemes.sedol1SecurityId("2046251"));
   equitySecurity.setShortName("AAPL");
   equitySecurity.setName("APPLE INC");
   equitySecurity.setGicsCode(GICSCode.of("45202010"));
   return equitySecurity;
 }
  private IRFutureOptionTrade createIRFutureOptionTrade() {

    String exchange = "TestExchange";
    ExerciseType exerciseType = new EuropeanExerciseType();
    double pointValue = Double.NaN;
    boolean margined = true;
    double strike = 0.99;
    OptionType optionType = OptionType.PUT;
    ExternalId irFutureId = Iterables.getOnlyElement(_irFuture.getExternalIdBundle());
    IRFutureOptionSecurity irFutureOption =
        new IRFutureOptionSecurity(
            exchange,
            _irFuture.getExpiry(),
            exerciseType,
            irFutureId,
            pointValue,
            margined,
            _irFuture.getCurrency(),
            strike,
            optionType);
    // Need this for time series lookup
    irFutureOption.setExternalIdBundle(
        ExternalSchemes.syntheticSecurityId("Test future option").toBundle());

    Counterparty counterparty =
        new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
    BigDecimal tradeQuantity = BigDecimal.valueOf(1);
    SimpleTrade trade =
        new SimpleTrade(irFutureOption, tradeQuantity, counterparty, TRADE_DATE, TRADE_TIME);
    trade.setPremium(10.0);
    trade.setPremiumCurrency(Currency.USD);
    return new IRFutureOptionTrade(trade);
  }
 // -------------------------------------------------------------------------
 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 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);
 }
 private static MarketDataEnvironment createSuppliedData() {
   LocalDateDoubleTimeSeries optionPrice =
       ImmutableLocalDateDoubleTimeSeries.of(VALUATION_TIME.toLocalDate(), 0.975);
   RawId<Double> optionRawId =
       RawId.of(ExternalSchemes.syntheticSecurityId("Test future option").toBundle());
   MarketDataEnvironmentBuilder builder = new MarketDataEnvironmentBuilder();
   builder.add(optionRawId, optionPrice);
   builder.add(VolatilitySurfaceId.of("TestExchange"), new VolatilitySurface(TEST_SURFACE));
   builder.valuationTime(VALUATION_TIME);
   return builder.build();
 }
 private HistoricalTimeSeriesInfoDocument loadTimeSeries(ExternalIdBundle idBundle) {
   ReferenceDataProvider referenceDataProvider =
       ((BloombergToolContext) getToolContext()).getBloombergReferenceDataProvider();
   if (idBundle.getExternalId(ExternalSchemes.BLOOMBERG_BUID) == null
       && idBundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER) != null) {
     // For some reason loading some series by TICKER fails, but BUID works
     BiMap<String, ExternalIdBundle> map =
         BloombergDataUtils.convertToBloombergBuidKeys(
             Collections.singleton(idBundle), referenceDataProvider);
     if (map.size() != 1) {
       throw new OpenGammaRuntimeException("Failed to get buid");
     }
     for (String key : map.keySet()) {
       ReferenceDataResult buidResult =
           referenceDataProvider.getFields(
               Collections.singleton(key),
               Collections.singleton(BloombergConstants.FIELD_ID_BBG_UNIQUE));
       String buid =
           buidResult
               .getResult(key)
               .getFieldData()
               .getString(BloombergConstants.FIELD_ID_BBG_UNIQUE);
       idBundle = idBundle.withExternalId(ExternalSchemes.bloombergTickerSecurityId(buid));
     }
   }
   ExternalIdBundle searchBundle =
       idBundle.withoutScheme(
           ExternalSchemes
               .ISIN); // For things which move country, e.g. ISIN(VALE5 BZ Equity) == ISIN(RIODF
   // US Equity)
   Map<ExternalId, UniqueId> timeSeries =
       getToolContext()
           .getHistoricalTimeSeriesLoader()
           .addTimeSeries(
               searchBundle.getExternalIds(),
               "CMPL",
               "PX_LAST",
               LocalDate.now().minusYears(1),
               null);
   if (timeSeries.size() != 1) {
     throw new OpenGammaRuntimeException(
         "Failed to load time series " + idBundle + " " + timeSeries);
   }
   for (UniqueId uid : timeSeries.values()) {
     return getToolContext().getHistoricalTimeSeriesMaster().get(uid);
   }
   throw new OpenGammaRuntimeException("Unexpected state");
 }
 private InterestRateFutureSecurity createIRFuture() {
   Expiry expiry =
       new Expiry(ZonedDateTime.of(LocalDate.of(2014, 6, 18), LocalTime.of(0, 0), ZoneOffset.UTC));
   String tradingExchange = "";
   String settlementExchange = "";
   Currency currency = Currency.USD;
   double unitAmount = 1000;
   ExternalId underlyingId = InterestRateMockSources.getLiborIndexId();
   String category = "";
   InterestRateFutureSecurity irFuture =
       new InterestRateFutureSecurity(
           expiry,
           tradingExchange,
           settlementExchange,
           currency,
           unitAmount,
           underlyingId,
           category);
   // Need this for time series lookup
   ExternalId irFutureId = ExternalSchemes.syntheticSecurityId("Test future");
   irFuture.setExternalIdBundle(irFutureId.toBundle());
   return irFuture;
 }
 @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);
   }
 }
Пример #13
0
  public static synchronized void addFixedIncomeInstrumentConventions(
      final ConventionBundleMaster conventionMaster) {
    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified =
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following =
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
    final DayCount act360 = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    final DayCount thirty360 = DayCountFactory.INSTANCE.getDayCount("30/360");
    final Frequency quarterly =
        SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);
    final Frequency semiAnnual =
        SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);
    final ExternalId ch = ExternalSchemes.financialRegionId("CH");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);
    // TODO check that it's actually libor that we need
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF00O/N Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR O/N")),
        "CHF LIBOR O/N",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF00S/N Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR S/N")),
        "CHF LIBOR S/N",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF00T/N Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR T/N")),
        "CHF LIBOR T/N",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0001W Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 1w")),
        "CHF LIBOR 1w",
        act360,
        following,
        Period.ofDays(7),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0002W Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 2w")),
        "CHF LIBOR 2w",
        act360,
        following,
        Period.ofDays(14),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0001M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 1m")),
        "CHF LIBOR 1m",
        act360,
        following,
        Period.ofMonths(1),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0002M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 2m")),
        "CHF LIBOR 2m",
        act360,
        following,
        Period.ofMonths(2),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0003M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 3m")),
        "CHF LIBOR 3m",
        act360,
        following,
        Period.ofMonths(3),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0004M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 4m")),
        "CHF LIBOR 4m",
        act360,
        following,
        Period.ofMonths(4),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0005M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 5m")),
        "CHF LIBOR 5m",
        act360,
        following,
        Period.ofMonths(5),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0006M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 6m"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFLIBORP6M")),
        "CHF LIBOR 6m",
        act360,
        following,
        Period.ofMonths(6),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0007M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 7m")),
        "CHF LIBOR 7m",
        act360,
        following,
        Period.ofMonths(7),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0008M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 8m")),
        "CHF LIBOR 8m",
        act360,
        following,
        Period.ofMonths(8),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0009M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 9m")),
        "CHF LIBOR 9m",
        act360,
        following,
        Period.ofMonths(9),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0010M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 10m")),
        "CHF LIBOR 10m",
        act360,
        following,
        Period.ofMonths(10),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0011M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 11m")),
        "CHF LIBOR 11m",
        act360,
        following,
        Period.ofMonths(11),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SF0012M Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 12m")),
        "CHF LIBOR 12m",
        act360,
        following,
        Period.ofMonths(12),
        2,
        false,
        ch);

    // TODO need to check that these are right for deposit rates
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR1T Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 1d")),
        "CHF DEPOSIT 1d",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR2T Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 2d")),
        "CHF DEPOSIT 2d",
        act360,
        following,
        Period.ofDays(1),
        1,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR3T Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 3d")),
        "CHF DEPOSIT 3d",
        act360,
        following,
        Period.ofDays(1),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR1Z Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 1w")),
        "CHF DEPOSIT 1w",
        act360,
        following,
        Period.ofDays(7),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR2Z Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 2w")),
        "CHF DEPOSIT 2w",
        act360,
        following,
        Period.ofDays(14),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR3Z Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 3w")),
        "CHF DEPOSIT 3w",
        act360,
        following,
        Period.ofDays(21),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRA Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 1m")),
        "CHF DEPOSIT 1m",
        act360,
        following,
        Period.ofMonths(1),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRB Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 2m")),
        "CHF DEPOSIT 2m",
        act360,
        following,
        Period.ofMonths(2),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRC Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 3m")),
        "CHF DEPOSIT 3m",
        act360,
        following,
        Period.ofMonths(3),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRD Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 4m")),
        "CHF DEPOSIT 4m",
        act360,
        following,
        Period.ofMonths(4),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRE Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 5m")),
        "CHF DEPOSIT 5m",
        act360,
        following,
        Period.ofMonths(5),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRF Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 6m")),
        "CHF DEPOSIT 6m",
        act360,
        following,
        Period.ofMonths(6),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRG Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 7m")),
        "CHF DEPOSIT 7m",
        act360,
        following,
        Period.ofMonths(7),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRH Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 8m")),
        "CHF DEPOSIT 8m",
        act360,
        following,
        Period.ofMonths(8),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRI Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 9m")),
        "CHF DEPOSIT 9m",
        act360,
        following,
        Period.ofMonths(9),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRJ Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 10m")),
        "CHF DEPOSIT 10m",
        act360,
        following,
        Period.ofMonths(10),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDRK Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 11m")),
        "CHF DEPOSIT 11m",
        act360,
        following,
        Period.ofMonths(11),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR1 Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 1y")),
        "CHF DEPOSIT 1y",
        act360,
        following,
        Period.ofYears(1),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR2 Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 2y")),
        "CHF DEPOSIT 2y",
        act360,
        following,
        Period.ofYears(2),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR3 Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 3y")),
        "CHF DEPOSIT 3y",
        act360,
        following,
        Period.ofYears(3),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR4 Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 4y")),
        "CHF DEPOSIT 4y",
        act360,
        following,
        Period.ofYears(4),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("SFDR5 Curncy"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF DEPOSIT 5y")),
        "CHF DEPOSIT 5y",
        act360,
        following,
        Period.ofYears(5),
        2,
        false,
        ch);

    // TODO check reference rate
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF_SWAP")),
        "CHF_SWAP",
        thirty360,
        modified,
        annual,
        2,
        ch,
        act360,
        modified,
        semiAnnual,
        2,
        ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 6m"),
        ch,
        true);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF_3M_SWAP")),
        "CHF_3M_SWAP",
        thirty360,
        modified,
        annual,
        2,
        ch,
        act360,
        modified,
        quarterly,
        2,
        ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 3m"),
        ch,
        true);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF_6M_SWAP")),
        "CHF_6M_SWAP",
        thirty360,
        modified,
        annual,
        2,
        ch,
        act360,
        modified,
        semiAnnual,
        2,
        ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 6m"),
        ch,
        true);

    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF_3M_FRA")),
        "CHF_3M_FRA",
        thirty360,
        modified,
        annual,
        2,
        ch,
        act360,
        modified,
        quarterly,
        2,
        ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 3m"),
        ch,
        true);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF_6M_FRA")),
        "CHF_6M_FRA",
        thirty360,
        modified,
        annual,
        2,
        ch,
        act360,
        modified,
        semiAnnual,
        2,
        ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF LIBOR 6m"),
        ch,
        true);

    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(
                InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, IndexType.Libor + "_CHF_P3M")),
        IndexType.Libor + "_CHF_P3M",
        thirty360,
        modified,
        null,
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(
                InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, IndexType.Libor + "_CHF_P6M")),
        IndexType.Libor + "_CHF_P6M",
        thirty360,
        modified,
        null,
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(
                InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, IndexType.Euribor + "_CHF_P3M")),
        IndexType.Euribor + "_CHF_P3M",
        thirty360,
        modified,
        null,
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(
                InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, IndexType.Euribor + "_CHF_P6M")),
        IndexType.Euribor + "_CHF_P6M",
        thirty360,
        modified,
        null,
        2,
        false,
        ch);

    // Overnight Index Swap Convention have additional flag, publicationLag
    final Integer publicationLagON = 0; // TODO CASE PublicationLag CHF - Confirm 0
    // CHF Overnight Index
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalSchemes.bloombergTickerSecurityId("TOISTOIS Index"),
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF TOISTOIS")),
        "CHF TOIS TOIS",
        act360,
        following,
        Period.ofDays(1),
        2,
        false,
        ch,
        publicationLagON);
    // OIS
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF_OIS_SWAP")),
        "CHF_OIS_SWAP",
        act360,
        modified,
        annual,
        2,
        ch,
        act360,
        modified,
        annual,
        2,
        ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF TOISTOIS"),
        ch,
        true,
        publicationLagON);

    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHF_IBOR_INDEX")),
        "CHF_IBOR_INDEX",
        act360,
        following,
        2,
        false);

    // Identifiers for external data
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP1D"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP1D")),
        "CHFCASHP1D",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP1M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP1M")),
        "CHFCASHP1M",
        act360,
        modified,
        Period.ofMonths(1),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP2M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP2M")),
        "CHFCASHP2M",
        act360,
        modified,
        Period.ofMonths(2),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP3M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP3M")),
        "CHFCASHP3M",
        act360,
        modified,
        Period.ofMonths(3),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP4M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP4M")),
        "CHFCASHP4M",
        act360,
        modified,
        Period.ofMonths(4),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP5M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP5M")),
        "CHFCASHP5M",
        act360,
        modified,
        Period.ofMonths(5),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP6M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP6M")),
        "CHFCASHP6M",
        act360,
        modified,
        Period.ofMonths(6),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP7M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP7M")),
        "CHFCASHP7M",
        act360,
        modified,
        Period.ofMonths(7),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP8M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP8M")),
        "CHFCASHP8M",
        act360,
        modified,
        Period.ofMonths(8),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP9M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP9M")),
        "CHFCASHP9M",
        act360,
        modified,
        Period.ofMonths(9),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP10M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP10M")),
        "CHFCASHP10M",
        act360,
        modified,
        Period.ofMonths(10),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP11M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP11M")),
        "CHFCASHP11M",
        act360,
        modified,
        Period.ofMonths(11),
        2,
        false,
        ch);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "CHFCASHP12M"),
            ExternalId.of(InMemoryConventionBundleMaster.OG_SYNTHETIC_TICKER, "CHFCASHP12M")),
        "CHFCASHP12M",
        act360,
        modified,
        Period.ofMonths(12),
        2,
        false,
        ch);
  }
Пример #14
0
/**
 * Tests the fields of an equity index. This test is intended to pick up any changes before
 * databases are affected.
 */
@Test(groups = TestGroup.UNIT)
public class EquityIndexTest {
  /** The index name */
  private static final String NAME = "BOND INDEX";
  /** The index description */
  private static final String DESCRIPTION = "BOND INDEX DESCRIPTION";
  /** The first index member */
  private static final ExternalIdBundle ID1 =
      ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("A"));
  /** The second index member */
  private static final ExternalIdBundle ID2 =
      ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("B"));
  /** The components */
  private static final List<EquityIndexComponent> COMPONENTS =
      Arrays.asList(
          new EquityIndexComponent(ID1, new BigDecimal(0.7)),
          new EquityIndexComponent(ID2, new BigDecimal(0.3)));
  /** The weighting type */
  private static final IndexWeightingType WEIGHTING_TYPE = IndexWeightingType.EQUAL;
  /** The index */
  private static final EquityIndex INDEX_NO_DESCRIPTION =
      new EquityIndex(NAME, COMPONENTS, WEIGHTING_TYPE);
  /** The index */
  private static final EquityIndex INDEX_WITH_DESCRIPTION =
      new EquityIndex(NAME, DESCRIPTION, COMPONENTS, WEIGHTING_TYPE);

  /** Tests that the components cannot be null */
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testNullComponents() {
    new EquityIndex(NAME, DESCRIPTION, null, WEIGHTING_TYPE);
  }

  /** Tests that the components cannot be empty */
  @Test
  public void testEmptyComponents() {
    new EquityIndex(NAME, DESCRIPTION, new ArrayList<EquityIndexComponent>(), WEIGHTING_TYPE);
  }

  /** Tests that the weighting type cannot be null */
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testNullWeightingType() {
    new EquityIndex(NAME, DESCRIPTION, COMPONENTS, null);
  }

  /** Tests the number of fields in the index. Will pick up additions / removals. */
  @Test
  public void testNumberOfFields() {
    List<Field> fields = IndexTestUtils.getFields(INDEX_NO_DESCRIPTION.getClass());
    assertEquals(15, fields.size());
    fields = IndexTestUtils.getFields(INDEX_WITH_DESCRIPTION.getClass());
    assertEquals(15, fields.size());
  }

  /** Tests that fields are set correctly and that fields that should be null are. */
  @Test
  public void test() {
    assertEquals(NAME, INDEX_NO_DESCRIPTION.getName());
    assertEquals(NAME, INDEX_WITH_DESCRIPTION.getName());
    assertNull(INDEX_NO_DESCRIPTION.getDescription());
    assertEquals(DESCRIPTION, INDEX_WITH_DESCRIPTION.getDescription());
    assertEquals(COMPONENTS, INDEX_NO_DESCRIPTION.getEquityComponents());
    assertEquals(COMPONENTS, INDEX_WITH_DESCRIPTION.getEquityComponents());
    assertEquals(WEIGHTING_TYPE, INDEX_NO_DESCRIPTION.getWeightingType());
    assertEquals(WEIGHTING_TYPE, INDEX_WITH_DESCRIPTION.getWeightingType());
  }
}
Пример #15
0
 /**
  * Sets the currency, stored in the identifier set.
  *
  * @param currency the currency to set, null to remove any currency
  */
 public void setCurrency(Currency currency) {
   setExternalIdBundle(getExternalIdBundle().withoutScheme(ExternalSchemes.ISO_CURRENCY_ALPHA3));
   if (currency != null) {
     addExternalId(ExternalSchemes.currencyRegionId(currency));
   }
 }
Пример #16
0
  /**
   * Adds conventions for deposits, implied deposits and cash.
   *
   * @param conventionMaster The convention master, not null
   */
  public static synchronized void addFixedIncomeInstrumentConventions(
      final ConventionBundleMaster conventionMaster) {
    ArgumentChecker.notNull(conventionMaster, "convention master");
    final BusinessDayConvention following = BusinessDayConventions.FOLLOWING;
    final BusinessDayConvention modified = BusinessDayConventions.MODIFIED_FOLLOWING;
    final DayCount act360 = DayCounts.ACT_360;
    final DayCount act365 = DayCounts.ACT_365;
    final Frequency quarterly =
        SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);
    final ExternalId kr = ExternalSchemes.financialRegionId("KR");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    for (int i = 1; i < 3; i++) {
      final String dayDepositName = "KRW DEPOSIT " + i + "d";
      final ExternalId dayBbgDeposit = bloombergTickerSecurityId("KWDR" + i + "T Curncy");
      final ExternalId daySimpleDeposit = simpleNameSecurityId(dayDepositName);
      final String weekDepositName = "KRW DEPOSIT " + i + "w";
      final ExternalId weekBbgDeposit = bloombergTickerSecurityId("KWDR" + i + "Z Curncy");
      final ExternalId weekSimpleDeposit = simpleNameSecurityId(weekDepositName);
      utils.addConventionBundle(
          ExternalIdBundle.of(dayBbgDeposit, daySimpleDeposit),
          dayDepositName,
          act360,
          following,
          Period.ofDays(i),
          0,
          false,
          kr);
      utils.addConventionBundle(
          ExternalIdBundle.of(weekBbgDeposit, weekSimpleDeposit),
          weekDepositName,
          act360,
          following,
          Period.ofDays(i * 7),
          0,
          false,
          kr);
    }

    for (int i = 1; i < 12; i++) {
      final String depositName = "KRW DEPOSIT " + i + "m";
      final ExternalId bbgDeposit =
          bloombergTickerSecurityId("KWDR" + BBG_MONTH_CODES[i - 1] + " Curncy");
      final ExternalId simpleDeposit = simpleNameSecurityId(depositName);
      final String impliedDepositName = "KRW IMPLIED DEPOSIT " + i + "m";
      final ExternalId tullettImpliedDeposit =
          tullettPrebonSecurityId("AMIDPKRWSPT" + (i < 10 ? "0" : "") + i + "M");
      final ExternalId simpleImpliedDeposit = simpleNameSecurityId(impliedDepositName);
      utils.addConventionBundle(
          ExternalIdBundle.of(bbgDeposit, simpleDeposit),
          depositName,
          act360,
          following,
          Period.ofMonths(i),
          0,
          false,
          kr);
      utils.addConventionBundle(
          ExternalIdBundle.of(tullettImpliedDeposit, simpleImpliedDeposit),
          impliedDepositName,
          act360,
          following,
          Period.ofMonths(i),
          0,
          false,
          kr);
    }

    for (int i = 1; i < 5; i++) {
      if (i == 1) {
        final String depositName = "KRW IMPLIED DEPOSIT 1y";
        final ExternalId tullettImpliedDeposit = tullettPrebonSecurityId("AMIDPKRWSPT12M");
        final ExternalId simpleImpliedDeposit = simpleNameSecurityId(depositName);
        utils.addConventionBundle(
            ExternalIdBundle.of(tullettImpliedDeposit, simpleImpliedDeposit),
            depositName,
            act360,
            following,
            Period.ofYears(1),
            0,
            false,
            kr);
      }
      final String depositName = "KRW DEPOSIT " + i + "y";
      final ExternalId bbgDeposit = bloombergTickerSecurityId("KWDR" + i + " Curncy");
      final ExternalId simpleDeposit = simpleNameSecurityId(depositName);
      utils.addConventionBundle(
          ExternalIdBundle.of(bbgDeposit, simpleDeposit),
          depositName,
          act360,
          following,
          Period.ofYears(i),
          0,
          false,
          kr);
    }

    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("KWCDC Curncy"),
            bloombergTickerSecurityId("KWCDC Index"),
            simpleNameSecurityId("KRW SWAP FIXING 3m")),
        "KRW SWAP FIXING 3m",
        act365,
        modified,
        Period.ofMonths(3),
        0,
        false,
        kr);
    utils.addConventionBundle(
        ExternalIdBundle.of(simpleNameSecurityId("KRW_SWAP")),
        "KRW_SWAP",
        act365,
        modified,
        quarterly,
        2,
        kr,
        act365,
        modified,
        quarterly,
        2,
        simpleNameSecurityId("KRW SWAP FIXING 3m"),
        kr,
        true);
  }
Пример #17
0
  public static synchronized void addFixedIncomeInstrumentConventions(
      final ConventionBundleMaster conventionMaster) {
    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified =
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following =
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
    final DayCount act360 = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    final DayCount act365 = DayCountFactory.INSTANCE.getDayCount("Actual/365");
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);
    final Frequency semiAnnual =
        SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency quarterly =
        SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);
    final ExternalId ca = ExternalSchemes.financialRegionId("CA");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);
    // TODO looked at BSYM and the codes seem right but need to check
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD00O/N Index"), simpleNameSecurityId("CAD LIBOR O/N")),
        "CAD LIBOR O/N",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD00S/N Index"), simpleNameSecurityId("CAD LIBOR S/N")),
        "CAD LIBOR S/N",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD00T/N Index"), simpleNameSecurityId("CAD LIBOR T/N")),
        "CAD LIBOR T/N",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0001W Index"), simpleNameSecurityId("CAD LIBOR 1w")),
        "CAD LIBOR 1w",
        act360,
        following,
        Period.ofDays(1),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0002W Index"), simpleNameSecurityId("CAD LIBOR 2w")),
        "CAD LIBOR 2w",
        act360,
        following,
        Period.ofDays(1),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0001M Index"), simpleNameSecurityId("CAD LIBOR 1m")),
        "CAD LIBOR 1m",
        act360,
        following,
        Period.ofMonths(1),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0002M Index"), simpleNameSecurityId("CAD LIBOR 2m")),
        "CAD LIBOR 2m",
        act360,
        following,
        Period.ofMonths(2),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0003M Index"), simpleNameSecurityId("CAD LIBOR 3m")),
        "CAD LIBOR 3m",
        act360,
        following,
        Period.ofMonths(3),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0004M Index"), simpleNameSecurityId("CAD LIBOR 4m")),
        "CAD LIBOR 4m",
        act360,
        following,
        Period.ofMonths(4),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0005M Index"), simpleNameSecurityId("CAD LIBOR 5m")),
        "CAD LIBOR 5m",
        act360,
        following,
        Period.ofMonths(5),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0006M Index"), simpleNameSecurityId("CAD LIBOR 6m")),
        "CAD LIBOR 6m",
        act360,
        following,
        Period.ofMonths(6),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0007M Index"), simpleNameSecurityId("CAD LIBOR 7m")),
        "CAD LIBOR 7m",
        act360,
        following,
        Period.ofMonths(7),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0008M Index"), simpleNameSecurityId("CAD LIBOR 8m")),
        "CAD LIBOR 8m",
        act360,
        following,
        Period.ofMonths(8),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0009M Index"), simpleNameSecurityId("CAD LIBOR 9m")),
        "CAD LIBOR 9m",
        act360,
        following,
        Period.ofMonths(9),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0010M Index"), simpleNameSecurityId("CAD LIBOR 10m")),
        "CAD LIBOR 10m",
        act360,
        following,
        Period.ofMonths(10),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0011M Index"), simpleNameSecurityId("CAD LIBOR 11m")),
        "CAD LIBOR 11m",
        act360,
        following,
        Period.ofMonths(11),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CD0012M Index"), simpleNameSecurityId("CAD LIBOR 12m")),
        "CAD LIBOR 12m",
        act360,
        following,
        Period.ofMonths(12),
        2,
        false,
        ca);

    // TODO need to check that these are right for deposit rates
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR1T Curncy"), simpleNameSecurityId("CAD DEPOSIT 1d")),
        "CAD DEPOSIT 1d",
        act365,
        following,
        Period.ofDays(1),
        0,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR2T Curncy"), simpleNameSecurityId("CAD DEPOSIT 2d")),
        "CAD DEPOSIT 2d",
        act365,
        following,
        Period.ofDays(1),
        0,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR3T Curncy"), simpleNameSecurityId("CAD DEPOSIT 3d")),
        "CAD DEPOSIT 3d",
        act365,
        following,
        Period.ofDays(1),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR1Z Curncy"), simpleNameSecurityId("CAD DEPOSIT 1w")),
        "CAD DEPOSIT 1w",
        act365,
        following,
        Period.ofDays(7),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR2Z Curncy"), simpleNameSecurityId("CAD DEPOSIT 2w")),
        "CAD DEPOSIT 2w",
        act365,
        following,
        Period.ofDays(14),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR3Z Curncy"), simpleNameSecurityId("CAD DEPOSIT 3w")),
        "CAD DEPOSIT 3w",
        act365,
        following,
        Period.ofDays(21),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRA Curncy"), simpleNameSecurityId("CAD DEPOSIT 1m")),
        "CAD DEPOSIT 1m",
        act365,
        following,
        Period.ofMonths(1),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRB Curncy"), simpleNameSecurityId("CAD DEPOSIT 2m")),
        "CAD DEPOSIT 2m",
        act365,
        following,
        Period.ofMonths(2),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRC Curncy"), simpleNameSecurityId("CAD DEPOSIT 3m")),
        "CAD DEPOSIT 3m",
        act365,
        following,
        Period.ofMonths(3),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRD Curncy"), simpleNameSecurityId("CAD DEPOSIT 4m")),
        "CAD DEPOSIT 4m",
        act365,
        following,
        Period.ofMonths(4),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRE Curncy"), simpleNameSecurityId("CAD DEPOSIT 5m")),
        "CAD DEPOSIT 5m",
        act365,
        following,
        Period.ofMonths(5),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRF Curncy"), simpleNameSecurityId("CAD DEPOSIT 6m")),
        "CAD DEPOSIT 6m",
        act365,
        following,
        Period.ofMonths(6),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRG Curncy"), simpleNameSecurityId("CAD DEPOSIT 7m")),
        "CAD DEPOSIT 7m",
        act365,
        following,
        Period.ofMonths(7),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRH Curncy"), simpleNameSecurityId("CAD DEPOSIT 8m")),
        "CAD DEPOSIT 8m",
        act365,
        following,
        Period.ofMonths(8),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRI Curncy"), simpleNameSecurityId("CAD DEPOSIT 9m")),
        "CAD DEPOSIT 9m",
        act365,
        following,
        Period.ofMonths(9),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRJ Curncy"), simpleNameSecurityId("CAD DEPOSIT 10m")),
        "CAD DEPOSIT 10m",
        act365,
        following,
        Period.ofMonths(10),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDRK Curncy"), simpleNameSecurityId("CAD DEPOSIT 11m")),
        "CAD DEPOSIT 11m",
        act365,
        following,
        Period.ofMonths(11),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR1 Curncy"), simpleNameSecurityId("CAD DEPOSIT 1y")),
        "CAD DEPOSIT 1y",
        act365,
        following,
        Period.ofYears(1),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR2 Curncy"), simpleNameSecurityId("CAD DEPOSIT 2y")),
        "CAD DEPOSIT 2y",
        act365,
        following,
        Period.ofYears(2),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR3 Curncy"), simpleNameSecurityId("CAD DEPOSIT 3y")),
        "CAD DEPOSIT 3y",
        act365,
        following,
        Period.ofYears(3),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR4 Curncy"), simpleNameSecurityId("CAD DEPOSIT 4y")),
        "CAD DEPOSIT 4y",
        act365,
        following,
        Period.ofYears(4),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDDR5 Curncy"), simpleNameSecurityId("CAD DEPOSIT 5y")),
        "CAD DEPOSIT 5y",
        act365,
        following,
        Period.ofYears(5),
        2,
        false,
        ca);
    // TODO check daycount
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDOR01 Index"),
            bloombergTickerSecurityId("CDOR01 RBC Index"),
            simpleNameSecurityId("CDOR 1m")),
        "CDOR 1m",
        act365,
        following,
        Period.ofMonths(1),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDOR02 Index"),
            bloombergTickerSecurityId("CDOR02 RBC Index"),
            simpleNameSecurityId("CDOR 2m")),
        "CDOR 2m",
        act365,
        following,
        Period.ofMonths(2),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDOR03 Index"),
            bloombergTickerSecurityId("CDOR03 RBC Index"),
            simpleNameSecurityId("CDOR 3m")),
        "CDOR 3m",
        act365,
        following,
        Period.ofMonths(3),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDOR06 Index"),
            bloombergTickerSecurityId("CDOR06 RBC Index"),
            simpleNameSecurityId("CDOR 6m")),
        "CDOR 6m",
        act365,
        following,
        Period.ofMonths(6),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CDOR12 Index"),
            bloombergTickerSecurityId("CDOR12 RBC Index"),
            simpleNameSecurityId("CDOR 12m")),
        "CDOR 12m",
        act365,
        following,
        Period.ofMonths(12),
        2,
        false,
        ca);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("CAONREPO Index"),
            simpleNameSecurityId("RBC OVERNIGHT REPO")),
        "RBC OVERNIGHT REPO",
        act365,
        following,
        Period.ofDays(1),
        0,
        false,
        ca,
        0);

    utils.addConventionBundle(
        ExternalIdBundle.of(simpleNameSecurityId("CAD_SWAP")),
        "CAD_SWAP",
        act365,
        modified,
        semiAnnual,
        0,
        ca,
        act365,
        modified,
        quarterly,
        0,
        simpleNameSecurityId("CDOR 3m"),
        ca,
        true);
    utils.addConventionBundle(
        ExternalIdBundle.of(simpleNameSecurityId("CAD_1Y_SWAP")),
        "CAD_1Y_SWAP",
        act365,
        modified,
        annual,
        0,
        ca,
        act365,
        modified,
        quarterly,
        0,
        simpleNameSecurityId("CDOR 3m"),
        ca,
        true);

    // Overnight Index Swap Convention have additional flag, publicationLag
    final Integer publicationLag = 1;
    utils.addConventionBundle(
        ExternalIdBundle.of(simpleNameSecurityId("CAD_OIS_SWAP")),
        "CAD_OIS_SWAP",
        act365,
        modified,
        annual,
        0,
        ca,
        act365,
        modified,
        annual,
        0,
        simpleNameSecurityId("RBC OVERNIGHT REPO"),
        ca,
        true,
        publicationLag);

    // TODO check the following details - copied from old CAD_FRA
    utils.addConventionBundle(
        ExternalIdBundle.of(simpleNameSecurityId("CAD_3M_FRA")),
        "CAD_3M_FRA",
        act365,
        following,
        quarterly,
        2,
        ca,
        act365,
        following,
        quarterly,
        2,
        simpleNameSecurityId("CDOR 3m"),
        ca,
        false);
    utils.addConventionBundle(
        ExternalIdBundle.of(simpleNameSecurityId("USD_6M_FRA")),
        "USD_6M_FRA",
        act365,
        following,
        semiAnnual,
        2,
        ca,
        act365,
        following,
        semiAnnual,
        2,
        simpleNameSecurityId("CDOR 6m"),
        ca,
        false);
    utils.addConventionBundle(
        ExternalIdBundle.of(simpleNameSecurityId("CAD_FRA")),
        "CAD_FRA",
        act365,
        following,
        quarterly,
        2,
        ca,
        act365,
        following,
        quarterly,
        2,
        simpleNameSecurityId("CDOR 3m"),
        ca,
        false);

    // TODO according to my information:
    // "Floating leg compounded quarterly at CDOR Flat paid semi-annually or annually for 1y"
    // Don't know how we're going to put that in
  }
Пример #18
0
  public static synchronized void addFixedIncomeInstrumentConventions(
      final ConventionBundleMaster conventionMaster) {
    ArgumentChecker.notNull(conventionMaster, "convention master");
    final BusinessDayConvention following =
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
    final DayCount act360 = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    final ExternalId sg = ExternalSchemes.financialRegionId("TR");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    // TODO need to check that these are right for deposit rates
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR1T Curncy"), simpleNameSecurityId("TRY DEPOSIT 1d")),
        "TRY DEPOSIT 1d",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR2T Curncy"), simpleNameSecurityId("TRY DEPOSIT 2d")),
        "TRY DEPOSIT 2d",
        act360,
        following,
        Period.ofDays(1),
        0,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR3T Curncy"), simpleNameSecurityId("TRY DEPOSIT 3d")),
        "TRY DEPOSIT 3d",
        act360,
        following,
        Period.ofDays(1),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR1Z Curncy"), simpleNameSecurityId("TRY DEPOSIT 1w")),
        "TRY DEPOSIT 1w",
        act360,
        following,
        Period.ofDays(7),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR2Z Curncy"), simpleNameSecurityId("TRY DEPOSIT 2w")),
        "TRY DEPOSIT 2w",
        act360,
        following,
        Period.ofDays(14),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR3Z Curncy"), simpleNameSecurityId("TRY DEPOSIT 3w")),
        "TRY DEPOSIT 3w",
        act360,
        following,
        Period.ofDays(21),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRA Curncy"), simpleNameSecurityId("TRY DEPOSIT 1m")),
        "TRY DEPOSIT 1m",
        act360,
        following,
        Period.ofMonths(1),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRB Curncy"), simpleNameSecurityId("TRY DEPOSIT 2m")),
        "TRY DEPOSIT 2m",
        act360,
        following,
        Period.ofMonths(2),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRC Curncy"), simpleNameSecurityId("TRY DEPOSIT 3m")),
        "TRY DEPOSIT 3m",
        act360,
        following,
        Period.ofMonths(3),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRD Curncy"), simpleNameSecurityId("TRY DEPOSIT 4m")),
        "TRY DEPOSIT 4m",
        act360,
        following,
        Period.ofMonths(4),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRE Curncy"), simpleNameSecurityId("TRY DEPOSIT 5m")),
        "TRY DEPOSIT 5m",
        act360,
        following,
        Period.ofMonths(5),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRF Curncy"), simpleNameSecurityId("TRY DEPOSIT 6m")),
        "TRY DEPOSIT 6m",
        act360,
        following,
        Period.ofMonths(6),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRG Curncy"), simpleNameSecurityId("TRY DEPOSIT 7m")),
        "TRY DEPOSIT 7m",
        act360,
        following,
        Period.ofMonths(7),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRH Curncy"), simpleNameSecurityId("TRY DEPOSIT 8m")),
        "TRY DEPOSIT 8m",
        act360,
        following,
        Period.ofMonths(8),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRI Curncy"), simpleNameSecurityId("TRY DEPOSIT 9m")),
        "TRY DEPOSIT 9m",
        act360,
        following,
        Period.ofMonths(9),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRJ Curncy"), simpleNameSecurityId("TRY DEPOSIT 10m")),
        "TRY DEPOSIT 10m",
        act360,
        following,
        Period.ofMonths(10),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDRK Curncy"), simpleNameSecurityId("TRY DEPOSIT 11m")),
        "TRY DEPOSIT 11m",
        act360,
        following,
        Period.ofMonths(11),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR1 Curncy"), simpleNameSecurityId("TRY DEPOSIT 1y")),
        "TRY DEPOSIT 1y",
        act360,
        following,
        Period.ofYears(1),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR2 Curncy"), simpleNameSecurityId("TRY DEPOSIT 2y")),
        "TRY DEPOSIT 2y",
        act360,
        following,
        Period.ofYears(2),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR3 Curncy"), simpleNameSecurityId("TRY DEPOSIT 3y")),
        "TRY DEPOSIT 3y",
        act360,
        following,
        Period.ofYears(3),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR4 Curncy"), simpleNameSecurityId("TRY DEPOSIT 4y")),
        "TRY DEPOSIT 4y",
        act360,
        following,
        Period.ofYears(4),
        2,
        false,
        sg);
    utils.addConventionBundle(
        ExternalIdBundle.of(
            bloombergTickerSecurityId("TYDR5 Curncy"), simpleNameSecurityId("TRY DEPOSIT 5y")),
        "TRY DEPOSIT 5y",
        act360,
        following,
        Period.ofYears(5),
        2,
        false,
        sg);
  }
  private void addNodes(
      final ManageablePortfolioNode rootNode,
      final String underlying,
      final boolean includeUnderlying,
      final Period[] expiries) {
    final ExternalId ticker = ExternalSchemes.bloombergTickerSecurityId(underlying);
    ManageableSecurity underlyingSecurity = null;
    if (includeUnderlying) {
      underlyingSecurity = getOrLoadEquity(ticker);
    }

    final ExternalIdBundle bundle =
        underlyingSecurity == null
            ? ExternalIdBundle.of(ticker)
            : underlyingSecurity.getExternalIdBundle();
    final HistoricalTimeSeriesInfoDocument timeSeriesInfo = getOrLoadTimeSeries(ticker, bundle);
    final double estimatedCurrentStrike = getOrLoadMostRecentPoint(timeSeriesInfo);
    final Set<ExternalId> optionChain = getOptionChain(ticker);

    // TODO: reuse positions/nodes?
    final String longName = underlyingSecurity == null ? "" : underlyingSecurity.getName();
    final String formattedName =
        MessageFormatter.format("[{}] {}", underlying, longName).getMessage();
    final ManageablePortfolioNode equityNode = new ManageablePortfolioNode(formattedName);

    final BigDecimal underlyingAmount =
        VALUE_OF_UNDERLYING.divide(
            BigDecimal.valueOf(estimatedCurrentStrike), BigDecimal.ROUND_HALF_EVEN);

    if (includeUnderlying) {
      addPosition(equityNode, underlyingAmount, ticker);
    }

    final TreeMap<LocalDate, Set<BloombergTickerParserEQOption>> optionsByExpiry =
        new TreeMap<LocalDate, Set<BloombergTickerParserEQOption>>();
    for (final ExternalId optionTicker : optionChain) {
      s_logger.debug("Got option {}", optionTicker);

      final BloombergTickerParserEQOption optionInfo =
          BloombergTickerParserEQOption.getOptionParser(optionTicker);
      s_logger.debug("Got option info {}", optionInfo);

      final LocalDate key = optionInfo.getExpiry();
      Set<BloombergTickerParserEQOption> set = optionsByExpiry.get(key);
      if (set == null) {
        set = new HashSet<BloombergTickerParserEQOption>();
        optionsByExpiry.put(key, set);
      }
      set.add(optionInfo);
    }
    final Set<ExternalId> tickersToLoad = new HashSet<ExternalId>();

    final BigDecimal expiryCount = BigDecimal.valueOf(expiries.length);
    final BigDecimal defaultAmountAtExpiry =
        underlyingAmount.divide(expiryCount, BigDecimal.ROUND_DOWN);
    final BigDecimal spareAmountAtExpiry = defaultAmountAtExpiry.add(BigDecimal.ONE);
    int spareCount =
        underlyingAmount.subtract(defaultAmountAtExpiry.multiply(expiryCount)).intValue();

    for (final Period bucketPeriod : expiries) {
      final ManageablePortfolioNode bucketNode =
          new ManageablePortfolioNode(bucketPeriod.toString().substring(1));

      final LocalDate nowish =
          LocalDate.now()
              .withDayOfMonth(
                  20); // This avoids us picking different options every time this script is run
      final LocalDate targetExpiry = nowish.plus(bucketPeriod);
      final LocalDate chosenExpiry = optionsByExpiry.floorKey(targetExpiry);
      if (chosenExpiry == null) {
        s_logger.info("No options for {} on {}", targetExpiry, underlying);
        continue;
      }
      s_logger.info(
          "Using time {} for bucket {} ({})",
          new Object[] {chosenExpiry, bucketPeriod, targetExpiry});

      final Set<BloombergTickerParserEQOption> optionsAtExpiry = optionsByExpiry.get(chosenExpiry);
      final TreeMap<Double, Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>
          optionsByStrike = new TreeMap<>();
      for (final BloombergTickerParserEQOption option : optionsAtExpiry) {
        //        s_logger.info("option {}", option);
        final double key = option.getStrike();
        Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair =
            optionsByStrike.get(key);
        if (pair == null) {
          pair = Pair.of(null, null);
        }
        if (option.getOptionType() == OptionType.CALL) {
          pair = Pair.of(option, pair.getSecond());
        } else {
          pair = Pair.of(pair.getFirst(), option);
        }
        optionsByStrike.put(key, pair);
      }

      // cascading collar?
      final BigDecimal amountAtExpiry =
          spareCount-- > 0 ? spareAmountAtExpiry : defaultAmountAtExpiry;

      s_logger.info(" est strike {}", estimatedCurrentStrike);
      final Double[] strikes = optionsByStrike.keySet().toArray(new Double[0]);

      int strikeIndex = Arrays.binarySearch(strikes, estimatedCurrentStrike);
      if (strikeIndex < 0) {
        strikeIndex = -(1 + strikeIndex);
      }
      s_logger.info(
          "strikes length {} index {} strike of index {}",
          new Object[] {
            Integer.valueOf(strikes.length),
            Integer.valueOf(strikeIndex),
            Double.valueOf(strikes[strikeIndex])
          });

      int minIndex = strikeIndex - _numOptions;
      minIndex = Math.max(0, minIndex);
      int maxIndex = strikeIndex + _numOptions;
      maxIndex = Math.min(strikes.length - 1, maxIndex);

      s_logger.info("min {} max {}", Integer.valueOf(minIndex), Integer.valueOf(maxIndex));
      final StringBuffer sb = new StringBuffer("strikes: [");
      for (int j = minIndex; j <= maxIndex; j++) {
        sb.append(" ");
        sb.append(strikes[j]);
      }
      sb.append(" ]");
      s_logger.info(sb.toString());

      // Short Calls
      final ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> calls =
          new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>();
      for (int j = minIndex; j < strikeIndex; j++) {
        final Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair =
            optionsByStrike.get(strikes[j]);
        if (pair == null) {
          throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]);
        }
        calls.add(pair);
      }
      spreadOptions(
          bucketNode,
          calls,
          OptionType.CALL,
          -1,
          tickersToLoad,
          amountAtExpiry,
          includeUnderlying,
          calls.size());

      // Long Puts
      final ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> puts =
          new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>();
      for (int j = strikeIndex + 1; j <= maxIndex; j++) {
        final Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair =
            optionsByStrike.get(strikes[j]);
        if (pair == null) {
          throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]);
        }
        puts.add(pair);
      }
      spreadOptions(
          bucketNode,
          puts,
          OptionType.PUT,
          1,
          tickersToLoad,
          amountAtExpiry,
          includeUnderlying,
          puts.size());

      if (bucketNode.getChildNodes().size() + bucketNode.getPositionIds().size() > 0) {
        equityNode.addChildNode(bucketNode); // Avoid generating empty nodes
      }
    }

    for (final ExternalId optionTicker : tickersToLoad) {
      final ManageableSecurity loaded = getOrLoadSecurity(optionTicker);
      if (loaded == null) {
        throw new OpenGammaRuntimeException("Unexpected option type " + loaded);
      }

      // TODO [LAPANA-29] Should be able to do this for index options too
      if (includeUnderlying) {
        try {
          final HistoricalTimeSeriesInfoDocument loadedTs =
              getOrLoadTimeSeries(optionTicker, loaded.getExternalIdBundle());
          if (loadedTs == null) {
            throw new OpenGammaRuntimeException("Failed to get time series for " + loaded);
          }
        } catch (final Exception ex) {
          s_logger.info("Failed to get time series for " + loaded, ex);
        }
      }
    }

    if (equityNode.getPositionIds().size() + equityNode.getChildNodes().size() > 0) {
      rootNode.addChildNode(equityNode);
    }
  }
Пример #20
0
  /**
   * Parses the specified file to populate the master.
   *
   * @param in the input reader to read, not closed, not null
   */
  public void parse(Reader in) {
    String name = null;
    try {
      Map<String, ManageableRegion> regions = new HashMap<String, ManageableRegion>();
      Map<UniqueId, Set<String>> subRegions = new HashMap<UniqueId, Set<String>>();

      // open CSV file
      @SuppressWarnings("resource")
      CSVReader reader = new CSVReader(in);
      List<String> columns = Arrays.asList(reader.readNext());

      // identify columns
      final int nameColumnIdx = columns.indexOf(NAME_COLUMN);
      final int formalNameColumnIdx = columns.indexOf(FORMAL_NAME_COLUMN);
      final int classificationColumnIdx = columns.indexOf(CLASSIFICATION_COLUMN);
      final int sovereignityColumnIdx = columns.indexOf(SOVEREIGNITY_COLUMN);
      final int countryColumnIdx = columns.indexOf(ISO_COUNTRY_2_COLUMN);
      final int currencyColumnIdx = columns.indexOf(ISO_CURRENCY_3_COLUMN);
      final int subRegionsColumnIdx = columns.indexOf(SUB_REGIONS_COLUMN);

      // parse
      String[] row = null;
      while ((row = reader.readNext()) != null) {
        name = row[nameColumnIdx].trim(); // the primary key
        String fullName = StringUtils.trimToNull(row[formalNameColumnIdx]);
        if (fullName == null) {
          fullName = name;
        }
        RegionClassification classification =
            RegionClassification.valueOf(row[classificationColumnIdx].trim());
        String sovereignity = StringUtils.trimToNull(row[sovereignityColumnIdx]);
        String countryISO = StringUtils.trimToNull(row[countryColumnIdx]);
        String currencyISO = StringUtils.trimToNull(row[currencyColumnIdx]);
        Set<String> rowSubRegions =
            new HashSet<String>(Arrays.asList(row[subRegionsColumnIdx].split(";")));
        rowSubRegions = trim(rowSubRegions);

        ManageableRegion region = new ManageableRegion();
        region.setClassification(classification);
        region.setName(name);
        region.setFullName(fullName);
        if (countryISO != null) {
          region.setCountry(Country.of(countryISO));
          region.addExternalId(ExternalSchemes.financialRegionId(countryISO)); // TODO: looks odd
        }
        if (currencyISO != null) {
          region.setCurrency(Currency.of(currencyISO));
        }
        if (sovereignity != null) {
          ManageableRegion parent = regions.get(sovereignity);
          if (parent == null) {
            throw new OpenGammaRuntimeException(
                "Cannot find parent '" + sovereignity + "'  for '" + name + "'");
          }
          region.getParentRegionIds().add(parent.getUniqueId());
        }
        for (Entry<UniqueId, Set<String>> entry : subRegions.entrySet()) {
          if (entry.getValue().remove(name)) {
            region.getParentRegionIds().add(entry.getKey());
          }
        }

        // store
        RegionDocument doc = getRegionMaster().add(new RegionDocument(region));
        if (rowSubRegions.size() > 0) {
          subRegions.put(doc.getUniqueId(), rowSubRegions);
        }
        regions.put(name, region);
      }
      for (Set<String> set : subRegions.values()) {
        if (set.size() > 0) {
          throw new OpenGammaRuntimeException("Cannot find children: " + set);
        }
      }

    } catch (Exception ex) {
      String detail = (name != null ? " while processing " + name : "");
      throw new OpenGammaRuntimeException(
          "Cannot open region data file (or file I/O problem)" + detail, ex);
    }
  }
Пример #21
0
 /**
  * Sets the time-zone, stored in the identifier set.
  *
  * @param timeZone the time-zone to set, null to remove any time-zone
  */
 public void setTimeZone(TimeZone timeZone) {
   setExternalIdBundle(getExternalIdBundle().withoutScheme(ExternalSchemes.TZDB_TIME_ZONE));
   if (timeZone != null) {
     addExternalId(ExternalSchemes.timeZoneRegionId(timeZone));
   }
 }
Пример #22
0
 /**
  * Sets the country, stored in the identifier set.
  *
  * @param country the country to set, null to remove any defined country
  */
 public void setCountry(Country country) {
   setExternalIdBundle(getExternalIdBundle().withoutScheme(ExternalSchemes.ISO_CURRENCY_ALPHA3));
   if (country != null) {
     addExternalId(ExternalSchemes.countryRegionId(country));
   }
 }
/**
 * Source of random, but reasonable, FX security instances.
 *
 * @param <T> the sub-type of the security
 */
public abstract class AbstractFXSecurityGenerator<T extends ManageableSecurity>
    extends SecurityGenerator<T> {

  private static final ExternalId REGION = ExternalSchemes.countryRegionId(Country.US);
  private static final double NOTIONAL = 100000;
  private static final DecimalFormat RATE_FORMATTER = new DecimalFormat("###.######");
  private static final DecimalFormat NOTIONAL_FORMATTER = new DecimalFormat("########.###");

  /** Structured random information for creating the security. */
  protected class Bundle {

    private final boolean _long;
    private final boolean _up;
    private final Currency _firstCurrency;
    private final Currency _secondCurrency;
    private final Currency _paymentCurrency;
    private final int _daysOffset;
    private final ZonedDateTime _tradeDate;

    public Bundle() {
      _long = getRandom().nextBoolean();
      _up = getRandom().nextBoolean();
      _firstCurrency = getRandomCurrency();
      Currency secondCurrency;
      do {
        secondCurrency = getRandomCurrency();
      } while (secondCurrency == _firstCurrency);
      _secondCurrency = secondCurrency;
      _daysOffset = 100 + getRandom().nextInt(600);
      _tradeDate =
          previousWorkingDay(
              ZonedDateTime.now().minusDays(getRandom(30)), _firstCurrency, _secondCurrency);
      _paymentCurrency = getRandom().nextBoolean() ? _firstCurrency : _secondCurrency;
    }
  }

  protected Bundle createBundle() {
    return new Bundle();
  }

  protected FXBarrierOptionSecurity createFXBarrierOptionSecurity(final Bundle bundle) {
    final Currency putCurrency = bundle._firstCurrency;
    final Currency callCurrency = bundle._secondCurrency;
    final double putAmount = putCurrency.equals(Currency.JPY) ? NOTIONAL * 100 : NOTIONAL;
    final ZonedDateTime settlementDate =
        nextWorkingDay(
            bundle._tradeDate.plusDays(bundle._daysOffset),
            bundle._firstCurrency,
            bundle._secondCurrency);
    final Expiry expiry = new Expiry(settlementDate, ExpiryAccuracy.DAY_MONTH_YEAR);
    final Double fxRate =
        getApproxFXRate(
            settlementDate.toLocalDate(), Pair.of(bundle._firstCurrency, bundle._secondCurrency));
    if (fxRate == null) {
      return null;
    }
    final double callAmount = NOTIONAL * fxRate;
    final String dateString = settlementDate.toString(DATE_FORMATTER);
    final BarrierType barrierType = bundle._up ? BarrierType.UP : BarrierType.DOWN;
    final BarrierDirection barrierDirection = BarrierDirection.KNOCK_IN;
    final MonitoringType monitoringType = MonitoringType.CONTINUOUS;
    final SamplingFrequency samplingFrequency = SamplingFrequency.DAILY_CLOSE;
    final double barrierLevel = bundle._up ? fxRate * 1.5 : fxRate / 1.5;
    final FXBarrierOptionSecurity fxBarrierOptionSecurity =
        new FXBarrierOptionSecurity(
            putCurrency,
            callCurrency,
            putAmount,
            callAmount,
            expiry,
            settlementDate,
            barrierType,
            barrierDirection,
            monitoringType,
            samplingFrequency,
            barrierLevel,
            bundle._long);
    final String callAmountString = NOTIONAL_FORMATTER.format(callAmount);
    final String putAmountString = NOTIONAL_FORMATTER.format(putAmount);
    final String barrierLevelString = RATE_FORMATTER.format(barrierLevel);
    final String barrierUnitString = callCurrency + "/" + putCurrency;
    fxBarrierOptionSecurity.setName(
        (bundle._long ? "Long " : "Short ")
            + (bundle._up ? "up" : "down")
            + " knock-in at "
            + barrierLevelString
            + " "
            + barrierUnitString
            + ", put "
            + putCurrency
            + " "
            + putAmountString
            + ", call "
            + callCurrency
            + " "
            + callAmountString
            + " on "
            + dateString);
    return fxBarrierOptionSecurity;
  }

  protected FXDigitalOptionSecurity createFXDigitalOptionSecurity(final Bundle bundle) {
    final Currency putCurrency = bundle._firstCurrency;
    final Currency callCurrency = bundle._secondCurrency;
    final Currency paymentCurrency = bundle._paymentCurrency;
    final double putAmount = putCurrency.equals(Currency.JPY) ? NOTIONAL * 100 : NOTIONAL;
    final ZonedDateTime expiry =
        nextWorkingDay(bundle._tradeDate.plusDays(bundle._daysOffset), putCurrency, callCurrency);
    final Double rate = getApproxFXRate(expiry.toLocalDate(), Pair.of(putCurrency, callCurrency));
    if (rate == null) {
      return null;
    }
    final double callAmount = rate * NOTIONAL;
    final ZonedDateTime settlementDate =
        nextWorkingDay(expiry.plusDays(2), putCurrency, callCurrency);
    final FXDigitalOptionSecurity security =
        new FXDigitalOptionSecurity(
            putCurrency,
            callCurrency,
            putAmount,
            callAmount,
            paymentCurrency,
            new Expiry(expiry),
            settlementDate,
            bundle._long);
    final StringBuilder sb = new StringBuilder("Digital ");
    sb.append(bundle._long ? "Long" : "Short");
    sb.append(" put ").append(putCurrency).append(' ').append(NOTIONAL_FORMATTER.format(putAmount));
    sb.append(", call ")
        .append(callCurrency)
        .append(' ')
        .append(NOTIONAL_FORMATTER.format(callAmount));
    sb.append(" on ").append(expiry.toString(DATE_FORMATTER));
    security.setName(sb.toString());
    return security;
  }

  protected FXForwardSecurity createFXForwardSecurity(final Bundle bundle) {
    final double putAmount = bundle._firstCurrency.equals(Currency.JPY) ? NOTIONAL * 100 : NOTIONAL;
    final ZonedDateTime forwardDate =
        nextWorkingDay(
            bundle._tradeDate.plusDays(bundle._daysOffset),
            bundle._firstCurrency,
            bundle._secondCurrency);
    final Double fxRate =
        getApproxFXRate(
            forwardDate.toLocalDate(), Pair.of(bundle._firstCurrency, bundle._secondCurrency));
    if (fxRate == null) {
      return null;
    }
    final double callAmount = NOTIONAL * fxRate;
    final Currency payCurrency = bundle._long ? bundle._secondCurrency : bundle._firstCurrency;
    final Currency receiveCurrency = bundle._long ? bundle._firstCurrency : bundle._secondCurrency;
    final String dateString = forwardDate.toString(DATE_FORMATTER);
    final FXForwardSecurity fxForwardSecurity =
        new FXForwardSecurity(
            payCurrency, callAmount, receiveCurrency, putAmount, forwardDate, REGION);
    final String callAmountString = NOTIONAL_FORMATTER.format(callAmount);
    final String putAmountString = NOTIONAL_FORMATTER.format(putAmount);
    fxForwardSecurity.setName(
        "Pay "
            + payCurrency
            + " "
            + callAmountString
            + ", receive "
            + receiveCurrency
            + " "
            + putAmountString
            + " on "
            + dateString);
    return fxForwardSecurity;
  }

  protected FXOptionSecurity createFXOptionSecurity(final Bundle bundle) {
    final Currency putCurrency = bundle._firstCurrency;
    final Currency callCurrency = bundle._secondCurrency;
    final double putAmount = bundle._firstCurrency.equals(Currency.JPY) ? NOTIONAL * 100 : NOTIONAL;
    final ZonedDateTime settlementDate = bundle._tradeDate.plusDays(bundle._daysOffset);
    final Double fxRate =
        getApproxFXRate(
            settlementDate.toLocalDate(), Pair.of(bundle._firstCurrency, bundle._secondCurrency));
    if (fxRate == null) {
      return null;
    }
    final double callAmount = NOTIONAL * fxRate;
    final Expiry expiry = new Expiry(settlementDate, ExpiryAccuracy.DAY_MONTH_YEAR);
    final String dateString = settlementDate.toString(DATE_FORMATTER);
    final FXOptionSecurity fxOptionSecurity =
        new FXOptionSecurity(
            putCurrency,
            callCurrency,
            putAmount,
            callAmount,
            expiry,
            settlementDate,
            bundle._long,
            new EuropeanExerciseType());
    final String callAmountString = NOTIONAL_FORMATTER.format(callAmount);
    final String putAmountString = NOTIONAL_FORMATTER.format(putAmount);
    fxOptionSecurity.setName(
        (bundle._long ? "Long " : "Short ")
            + "put "
            + putCurrency
            + " "
            + putAmountString
            + ", call "
            + callCurrency
            + " "
            + callAmountString
            + " on "
            + dateString);
    return fxOptionSecurity;
  }

  protected ManageableTrade createFXBarrierOptionSecurityTrade(
      final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister) {
    final FXBarrierOptionSecurity security = createFXBarrierOptionSecurity(bundle);
    if (security == null) {
      return null;
    }
    return new ManageableTrade(
        quantity,
        persister.storeSecurity(security),
        bundle._tradeDate.toLocalDate(),
        bundle._tradeDate.toOffsetTime(),
        ExternalId.of("ID", "COUNTERPARTY"));
  }

  protected ManageableTrade createFXDigitalOptionSecurityTrade(
      final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister) {
    final FXDigitalOptionSecurity security = createFXDigitalOptionSecurity(bundle);
    if (security == null) {
      return null;
    }
    return new ManageableTrade(
        quantity,
        persister.storeSecurity(security),
        bundle._tradeDate.toLocalDate(),
        bundle._tradeDate.toOffsetTime(),
        ExternalId.of("ID", "COUNTERPARTY"));
  }

  protected ManageableTrade createFXForwardSecurityTrade(
      final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister) {
    final FXForwardSecurity security = createFXForwardSecurity(bundle);
    if (security == null) {
      return null;
    }
    return new ManageableTrade(
        quantity,
        persister.storeSecurity(security),
        bundle._tradeDate.toLocalDate(),
        bundle._tradeDate.toOffsetTime(),
        ExternalId.of("ID", "COUNTERPARTY"));
  }

  protected ManageableTrade createFXOptionSecurityTrade(
      final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister) {
    final FXOptionSecurity security = createFXOptionSecurity(bundle);
    if (security == null) {
      return null;
    }
    return new ManageableTrade(
        quantity,
        persister.storeSecurity(security),
        bundle._tradeDate.toLocalDate(),
        bundle._tradeDate.toOffsetTime(),
        ExternalId.of("ID", "COUNTERPARTY"));
  }
}
  /**
   * Get US bond future security for testing
   *
   * @return the bond future security
   */
  public static BondFutureSecurity getBondFutureSecurity() {
    Expiry expiry =
        new Expiry(
            ZonedDateTime.of(LocalDateTime.of(2010, Month.JUNE, 21, 19, 0), ZoneOffset.UTC),
            ExpiryAccuracy.MIN_HOUR_DAY_MONTH_YEAR);
    Set<BondFutureDeliverable> basket = new HashSet<BondFutureDeliverable>();
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EV6")), 1.0858));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FB9")), 1.0132));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PX0")), 0.7984));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FG8")), 0.9169));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QD3")), 0.7771));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FF0")), 0.9174));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PW2")), 0.7825));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FE3")), 0.9454));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QH4")), 0.7757));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PU6")), 0.8675));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EX2")), 1.0765));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FT0")), 0.8054));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FJ2")), 1.0141));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810PT9")), 0.8352));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QE1")), 0.8109));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FP8")), 0.9268));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QA9")), 0.6606));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FM5")), 1.0286));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EY0")), 1.0513));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QB7")), 0.7616));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810QC5")), 0.795));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EZ7")), 1.0649));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810EW4")), 1.0));
    basket.add(
        new BondFutureDeliverable(
            ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId("GV912810FA1")), 1.0396));

    BondFutureSecurity sec =
        new BondFutureSecurity(
            expiry,
            "XCBT",
            "XCBT",
            Currency.USD,
            1000,
            basket,
            LocalDate.of(2010, 6, 01).atStartOfDay(ZoneOffset.UTC),
            LocalDate.of(2010, 6, 01).atStartOfDay(ZoneOffset.UTC),
            "Bond");
    sec.setName("US LONG BOND(CBT) Jun10");
    Set<ExternalId> identifiers = new HashSet<ExternalId>();
    identifiers.add(ExternalSchemes.bloombergBuidSecurityId("IX8530684-0"));
    identifiers.add(ExternalSchemes.cusipSecurityId("USM10"));
    identifiers.add(ExternalSchemes.bloombergTickerSecurityId("USM10 Comdty"));
    sec.setExternalIdBundle(ExternalIdBundle.of(identifiers));
    return sec;
  }