Package org.threeten.bp

Examples of org.threeten.bp.ZonedDateTime


  }

  @Override
  public SwaptionSecurity createSecurity() {
    final int optionLength = getRandom(OPTION_LENGTH);
    ZonedDateTime expiry = ZonedDateTime.now().plusMonths(optionLength);
    final SwapSecurity underlying = createUnderlying(expiry.plusMonths(2), expiry);
    final Currency currency = FinancialSecurityUtils.getCurrency(underlying);
    expiry = nextWorkingDay(expiry, currency);
    final boolean isPayer = getRandom().nextBoolean();
    final boolean isLong = getRandom().nextBoolean();
    final boolean isCashSettled = getRandom().nextBoolean();
    final ZonedDateTime settlementDate = nextWorkingDay(expiry.plusDays(2), currency);
    final Double notional = underlying.getPayLeg().getNotional().accept(new NotionalVisitor<Double>() {

      @Override
      public Double visitCommodityNotional(final CommodityNotional notional) {
        return null;
View Full Code Here


    assertEquals(SamplingFrequency.ONE_LOOK, _stringConvert.convertFromString(SamplingFrequency.class, "One Look"));
  }

  @Test
  public void convertZonedDateTime() {
    ZonedDateTime date = LocalDate.of(2012, 12, 21).atTime(11, 0).atZone(ZoneId.of("UTC"));
    assertEquals("2012-12-21", _stringConvert.convertToString(date));
    assertEquals(date, _stringConvert.convertFromString(ZonedDateTime.class, "2012-12-21"));
  }
View Full Code Here

  /**
   * BondFutureSecurity contains a collection of bean instances (BondFutureDeliverable)
   */
  @Test
  public void bondFuture() throws JSONException {
    ZonedDateTime firstDeliveryDate = zdt(2012, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC);
    ZonedDateTime lastDeliveryDate = zdt(2013, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC);
    ZonedDateTime expiryDate = zdt(2013, 12, 22, 11, 0, 0, 0, ZoneOffset.UTC);
    ExternalIdBundle bundle1 = ExternalIdBundle.of(ExternalId.of("sch1", "123"), ExternalId.of("sch1", "234"));
    ExternalIdBundle bundle2 = ExternalIdBundle.of(ExternalId.of("sch1", "345"));
    List<BondFutureDeliverable> basket = Lists.newArrayList(
        new BondFutureDeliverable(bundle1, 111),
        new BondFutureDeliverable(bundle2, 222));
View Full Code Here

  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 boolean invertBarrierLevel = !CurrencyPair.of(putCurrency, callCurrency).equals(getCurrencyPair(putCurrency, callCurrency));
View Full Code Here

  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));
View Full Code Here

    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;
View Full Code Here

    return fxForwardSecurity;
  }
 
  protected NonDeliverableFXForwardSecurity createNDFXForwardSecurity(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 NonDeliverableFXForwardSecurity security = new NonDeliverableFXForwardSecurity(payCurrency, callAmount, receiveCurrency, putAmount, forwardDate,
        REGION, getRandom(BOOLEAN_VALUES));
   
    final String callAmountString = NOTIONAL_FORMATTER.format(callAmount);
    final String putAmountString = NOTIONAL_FORMATTER.format(putAmount);
View Full Code Here

  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;
View Full Code Here

 
  protected NonDeliverableFXOptionSecurity createNDFXOptionSecurity(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 NonDeliverableFXOptionSecurity optionSecurity = new NonDeliverableFXOptionSecurity(putCurrency, callCurrency, putAmount, callAmount, expiry, settlementDate,
        getRandom(BOOLEAN_VALUES), new EuropeanExerciseType(), getRandom(BOOLEAN_VALUES));
   
    final String callAmountString = NOTIONAL_FORMATTER.format(callAmount);
View Full Code Here

    ExternalId underlyingId = updatedSecurity.getUnderlyingId();
    SecuritySearchRequest searchRequest = new SecuritySearchRequest();
    searchRequest.setExternalIdSearch(new ExternalIdSearch(underlyingId));
    SecuritySearchResult searchResult = _securityMaster.search(searchRequest);
    SwapSecurity updatedUnderlying = (SwapSecurity) searchResult.getSingleSecurity();
    ZonedDateTime tradeDate = ZonedDateTime.of(LocalDateTime.of(2013, 1, 1, 11, 0), ZoneOffset.UTC);
    assertEquals(tradeDate, updatedUnderlying.getTradeDate());
  }
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.