Package org.threeten.bp

Examples of org.threeten.bp.ZonedDateTime


    s_logger.info(sb.toString());
    return securities;
  }

  private CapFloorSecurity makeCapFloor(final Random random, final Tenor tenor) {
    final ZonedDateTime maturityDate = TRADE_DATE.plus(tenor.getPeriod()).atStartOfDay(ZoneOffset.UTC);
    final boolean payer = random.nextBoolean();
    final boolean cap = random.nextBoolean();
    final double strike = getSwapRate(CURRENCY, TRADE_DATE, tenor) * (1 + ((0.5 - random.nextDouble()) / 30));
    final double notional = 1000000 * (1 + random.nextInt(50));
    final ExternalId underlyingId = TICKERS.get(tenor);
    if (underlyingId == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + tenor);
    }
    final CapFloorSecurity security = new CapFloorSecurity(TRADE_DATE.atStartOfDay(ZoneOffset.UTC), maturityDate, notional, underlyingId, strike, PeriodFrequency.SEMI_ANNUAL,
        Currency.USD, ACT_360, payer, cap, false);
    security.setName("USD " + FORMAT.format(notional / 1000000) + (cap ? "MM cap " : "MM floor ") + "@ " + FORMAT.format(strike) +
        (payer ? "%, pay " : "%, receive ") + tenor.getPeriod().normalized().getYears() + "Y ISDA fixing" +
        " (" + TRADE_DATE.toString() + " - " + maturityDate.toLocalDate().toString() + ")");
    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }
View Full Code Here


    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }

  private SwapSecurity makeSwap(final Random random, final Tenor tenor) {
    final ZonedDateTime tradeDate = TRADE_DATE.atStartOfDay(ZoneOffset.UTC);
    final ZonedDateTime maturityDate = tradeDate.plus(tenor.getPeriod());
    final ExternalId iborReferenceRate = LIBOR_3M;
    final PeriodFrequency frequency = PeriodFrequency.QUARTERLY;
    final ExternalId cmsId = TICKERS.get(tenor);
    if (cmsId == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + tenor);
    }
    final InterestRateNotional notional = new InterestRateNotional(Currency.USD, 1000000 * (1 + random.nextInt(50)));
    final FloatingInterestRateLeg iborLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, notional, true,
        iborReferenceRate, FloatingRateType.IBOR);
    final FloatingInterestRateLeg cmsLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, notional, true,
        cmsId, FloatingRateType.CMS);
    SwapSecurity security;
    boolean payIbor;
    if (random.nextBoolean()) {
      security = new SwapSecurity(tradeDate, tradeDate, maturityDate, COUNTERPARTY, iborLeg, cmsLeg);
      payIbor = true;
    } else {
      security = new SwapSecurity(tradeDate, tradeDate, maturityDate, COUNTERPARTY, cmsLeg, iborLeg);
      payIbor = false;
    }
    security.setName(CURRENCY.getCode() + " " + FORMAT.format(notional.getAmount() / 1000000) + "MM Swap, pay " +
        (payIbor ? frequency.getPeriod().getMonths() + "M Libor, receive " + tenor.getPeriod().getYears() + "Y ISDA fixing (" :
          tenor.getPeriod().getYears() + "Y ISDA fixing, receive " + frequency.getPeriod().getMonths() + "M Libor (") +
          tradeDate.toLocalDate().toString() + " - " + maturityDate.toLocalDate().toString() + ")");
    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }
View Full Code Here

    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }

  private CapFloorCMSSpreadSecurity makeCMSCapFloorSpread(final Random random, final Tenor payTenor, final Tenor receiveTenor, final Tenor maturity, final double strike) {
    final ZonedDateTime tradeDate = TRADE_DATE.atStartOfDay(ZoneOffset.UTC);
    final ZonedDateTime maturityDate = tradeDate.plus(maturity.getPeriod());
    final boolean payer = random.nextBoolean();
    final boolean cap = random.nextBoolean();
    final ExternalId payIdentifier = TICKERS.get(payTenor);
    if (payIdentifier == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + payTenor);
    }
    final ExternalId receiveIdentifier = TICKERS.get(receiveTenor);
    if (receiveIdentifier == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + receiveTenor);
    }
    final double notional = 1000000 * (1 + random.nextInt(50));
    final CapFloorCMSSpreadSecurity security = new CapFloorCMSSpreadSecurity(tradeDate, maturityDate, notional, payIdentifier, receiveIdentifier, strike,
        PeriodFrequency.ANNUAL, CURRENCY, ACT_360, payer, cap);
    security.setName(CURRENCY.getCode() + " " + FORMAT.format(notional / 1000000) + (cap ? "MM cap spread " : "MM floor spread ") + "@ " + FORMAT.format(strike) +
        "%, pay " + payTenor.getPeriod().normalized().getYears() + "Y ISDA fixing" + ", receive " +
        receiveTenor.getPeriod().normalized().getYears() + "Y ISDA fixing" +
        " (" + tradeDate.toLocalDate().toString() + " - " + maturityDate.toLocalDate().toString() + ")");
    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }
View Full Code Here

    return bean;
  }

  @Override
  public NonDeliverableFXForwardSecurity createSecurity(final OperationContext context, NonDeliverableFXForwardSecurityBean bean) {
    ZonedDateTime forwardDate = zonedDateTimeBeanToDateTimeWithZone(bean.getForwardDate());
    ExternalId region = externalIdBeanToExternalId(bean.getRegion());
    Currency payCurrency = currencyBeanToCurrency(bean.getPayCurrency());
    double payAmount = bean.getPayAmount();
    Currency receiveCurrency = currencyBeanToCurrency(bean.getReceiveCurrency());
    double receiveAmount = bean.getReceiveAmount();
View Full Code Here

    return bean;
  }

  @Override
  public FXForwardSecurity createSecurity(final OperationContext context, FXForwardSecurityBean bean) {
    ZonedDateTime forwardDate = zonedDateTimeBeanToDateTimeWithZone(bean.getForwardDate());
    ExternalId region = externalIdBeanToExternalId(bean.getRegion());
    Currency payCurrency = currencyBeanToCurrency(bean.getPayCurrency());
    double payAmount = bean.getPayAmount();
    Currency receiveCurrency = currencyBeanToCurrency(bean.getReceiveCurrency());
    double receiveAmount = bean.getReceiveAmount();
View Full Code Here

  @Override
  public CapFloorCMSSpreadSecurity createSecurity() {
    final Currency currency = getRandomCurrency();
    final boolean payer = getRandom().nextBoolean();
    final boolean cap = getRandom().nextBoolean();
    final ZonedDateTime startDate = previousWorkingDay(ZonedDateTime.now().minusDays(getRandom(365) + 7), currency);
    final double notional = (double) getRandom(100000) * 1000;
    Tenor tenor1;
    Tenor tenor2;
    do {
      tenor1 = getRandom(SHORT_TENORS);
      tenor2 = getRandom(LONG_TENORS);
    } while (tenor1.compareTo(tenor2) >= 0);
    final int length = getRandom(tenor2.getPeriod().getYears() - 5) + 3;
    final ZonedDateTime maturityDate = nextWorkingDay(startDate.plusYears(length), currency);
    final ExternalId shortIdentifier = getUnderlying(currency, startDate.toLocalDate(), tenor1);
    final ExternalId longIdentifier = getUnderlying(currency, startDate.toLocalDate(), tenor2);
    final double strike = getRandom(STRIKES);
    final Frequency frequency = getRandom(FREQUENCY);
    final DayCount dayCount = getRandom(DAY_COUNT);
View Full Code Here

//    persistToPortfolio(Arrays.asList(vanillaSwaps, oisSwaps, basisSwaps, futures), Arrays.asList("EUR Vanilla Swaps", "EUR OIS Swaps", "EUR 3m/6m Basis Swaps", "STIR Futures"), PORTFOLIO_NAME);   
    persistToPortfolio(Arrays.asList(vanillaSwaps, oisSwaps, basisSwaps), Arrays.asList("EUR Vanilla Swaps", "EUR OIS Swaps", "EUR 3m/6m Basis Swaps"), PORTFOLIO_NAME);
  }

  private Collection<FinancialSecurity> getVanillaSwapSecurities(final Random random) {
    final ZonedDateTime tradeDate = DateUtils.getUTCDate(2013, 8, 1);
    final ZonedDateTime effectiveDate = DateUtils.getUTCDate(2013, 8, 5);
    final Collection<FinancialSecurity> securities = new ArrayList<>();
    for (int i = 0; i < N_VANILLA_SWAPS; i++) {
      final InterestRateNotional notional = new InterestRateNotional(CURRENCY, 10000000 * (1 + random.nextInt(9)));
      final int years = 1 + random.nextInt(30);
      final ZonedDateTime maturityDate = tradeDate.plusYears(years);
      final double rate = years * 0.001 + random.nextDouble() / 5000;
      final FixedInterestRateLeg fixedLeg = new FixedInterestRateLeg(ACT_360, SEMI_ANNUAL, REGION, MODIFIED_FOLLOWING, notional, false, rate);
      final Frequency frequency;
      final ExternalId euribor;
      final String frequencyLabel;
View Full Code Here

    }
    return securities;
  }

  private Collection<FinancialSecurity> getOISSwapSecurities(final Random random) {
    final ZonedDateTime tradeDate = DateUtils.getUTCDate(2013, 8, 1);
    final ZonedDateTime effectiveDate = DateUtils.getUTCDate(2013, 8, 5);
    final Collection<FinancialSecurity> securities = new ArrayList<>();
    for (int i = 0; i < N_OIS_SWAPS; i++) {
      final InterestRateNotional notional = new InterestRateNotional(CURRENCY, 10000000 * (1 + random.nextInt(9)));
      final int years = 1 + random.nextInt(30);
      final ZonedDateTime maturityDate = tradeDate.plusYears(years);
      final double rate = years * 0.001 + random.nextDouble() / 5000;
      final FixedInterestRateLeg fixedLeg = new FixedInterestRateLeg(ACT_360, SEMI_ANNUAL, REGION, MODIFIED_FOLLOWING, notional, false, rate);
      final Frequency frequency;
      if (random.nextBoolean()) {
        frequency = QUARTERLY;
View Full Code Here

    }
    return securities;
  }

  private Collection<FinancialSecurity> getBasisSwapSecurities(final Random random) {
    final ZonedDateTime tradeDate = DateUtils.getUTCDate(2013, 8, 1);
    final ZonedDateTime effectiveDate = DateUtils.getUTCDate(2013, 8, 5);
    final Collection<FinancialSecurity> securities = new ArrayList<>();
    for (int i = 0; i < N_BASIS_SWAPS; i++) {
      final InterestRateNotional notional = new InterestRateNotional(CURRENCY, 10000000 * (1 + random.nextInt(9)));
      final int years = 1 + random.nextInt(30);
      final ZonedDateTime maturityDate = tradeDate.plusYears(years);
      final double spread = years * 0.002 + random.nextDouble() / 1000.;
      final Frequency payFrequency, receiveFrequency;
      final ExternalId payRate, receiveRate;
      final FloatingInterestRateLeg payLeg, receiveLeg;
      final String frequencyLabel;
View Full Code Here

    }
    return securities;
  }

  private Collection<FinancialSecurity> getIRFutureSecurities(final Random random) {
    final ZonedDateTime tradeDate = DateUtils.getUTCDate(2014, 9, 1);
    final Collection<FinancialSecurity> securities = new ArrayList<>();
    final int[] amounts = new int[N_FUTURES];
    final double[] prices = new double[N_FUTURES];
    for (int i = 0; i < N_FUTURES; i++) {
      final int n = 1 + random.nextInt(5);
      final Expiry expiry = new Expiry(tradeDate.plusMonths(3 * n).with(THIRD_WED_ADJUSTER));
      final String letter = MONTHS.get(expiry.getExpiry().getMonth());
      final String year = Integer.toString(expiry.getExpiry().getYear() - 2010);
      final String code = "ER" + letter + year;
      final FutureSecurity security = new InterestRateFutureSecurity(expiry, "XLIF", "XLIF", CURRENCY, 2500, EURIBOR_3M, "Interest rate");
      security.setName(code);
View Full Code Here

TOP

Related Classes of org.threeten.bp.ZonedDateTime

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.