Package org.threeten.bp

Examples of org.threeten.bp.ZonedDateTime


    double t = 0;
    final double spot = data.getSpot();
    impliedTree[0][0] = spot;
    arrowDebreu[0] = 1;
    int previousNodes = 1;
    final ZonedDateTime date = data.getDate();
    for (int i = 1; i < _n + 1; i++) {
      final int nodes = RecombiningBinomialTree.NODES.evaluate(i);
      final BinomialOptionModel<StandardOptionDataBundle> crrModel = new BinomialOptionModel<>(CRR, i);
      t += dt;
      final double df1 = Math.exp(dt * data.getInterestRate(t));
 
View Full Code Here


      throw new NotImplementedException("Can only calculate fair price at the moment: asked for " + requiredGreeks);
    }
    if (requiredGreeks.size() > 1) {
      s_logger.warn("Can only calculate fair price - ignoring other greeks");
    }
    final ZonedDateTime date = dataBundle.getDate();
    final EuropeanVanillaOption option = EuropeanVanillaOption.fromDefinition(definition, date);
    final BlackFunctionData data = BlackFunctionData.fromDataBundle(dataBundle, definition);

    double fwd = data.getForward();
    double df = data.getDiscountFactor();
View Full Code Here

    assertEquals("Fixed coupon bond security: dirty price from yield", cleanPriceExpected, cleanPrice, 1E-8);
  }

  @Test
  public void dirtyPriceFromYieldUSStreetLastPeriod() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2016, 6, 3); // In last period
    final BondFixedSecurity bondSecurity = BOND_FIXED_SECURITY_DEFINITION.toDerivative(referenceDate, CURVES_NAME);
    final double yield = 0.04;
    final double dirtyPrice = METHOD.dirtyPriceFromYield(bondSecurity, yield);
    final double dirtyPriceExpected = (1 + RATE_FIXED / COUPON_PER_YEAR) / (1 + bondSecurity.getAccrualFactorToNextCoupon() * yield / COUPON_PER_YEAR);
    assertEquals("Fixed coupon bond security: dirty price from yield US Street - last period", dirtyPriceExpected, dirtyPrice, 1E-8);
View Full Code Here

    assertEquals("Fixed coupon bond security: modified duration from curves US Street", modifiedDurationExpected, modifiedDuration, 1E-8);
  }

  @Test
  public void modifiedDurationFromYieldUSStreetLastPeriod() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2016, 6, 3); // In last period
    final BondFixedSecurity bondSecurity = BOND_FIXED_SECURITY_DEFINITION.toDerivative(referenceDate, CURVES_NAME);
    final double yield = 0.04;
    final double dirtyPrice = METHOD.modifiedDurationFromYield(bondSecurity, yield);
    final double dirtyPriceExpected = bondSecurity.getAccrualFactorToNextCoupon() / COUPON_PER_YEAR / (1 + bondSecurity.getAccrualFactorToNextCoupon() * yield / COUPON_PER_YEAR);
    assertEquals("Fixed coupon bond security: modified duration from yield US Street - last period", dirtyPriceExpected, dirtyPrice, 1E-8);
View Full Code Here

      throw new NotImplementedException("Can only calculate fair price at the moment: asked for " + requiredGreeks);
    }
    if (requiredGreeks.size() > 1) {
      s_logger.warn("Can only calculate fair price - ignoring other greeks");
    }
    final ZonedDateTime date = dataBundle.getDate();
    final EuropeanVanillaOption option = EuropeanVanillaOption.fromDefinition(definition, date);
    final BlackFunctionData data = BlackFunctionData.fromDataBundle(dataBundle, definition);
    final double price = _pricer.price(data, option, _characteristicExponent, _alpha, _limitTolerance, _useVarianceReduction);
    final GreekResultCollection result = new GreekResultCollection();
    result.put(Greek.FAIR_PRICE, price);
View Full Code Here

    assertEquals("Fixed coupon bond security: dirty price from yield", cleanPriceExpected, cleanPrice, TOLERANCE_PRICE);
  }

  @Test
  public void dirtyPriceFromYieldGermanLastPeriod() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2022, 5, 15); // In last period
    final BondFixedSecurity bondSecurity = BOND_DE_SECURITY_DEFINITION.toDerivative(referenceDate, CURVES_NAME);
    final double yield = 0.02;
    final double dirtyPrice = METHOD.dirtyPriceFromYield(bondSecurity, yield);
    final double dirtyPriceExpected = (1 + RATE_DE / COUPON_PER_YEAR_DE) / (1 + bondSecurity.getAccrualFactorToNextCoupon() * yield / COUPON_PER_YEAR_DE);
    assertEquals("Fixed coupon bond security: dirty price from yield German bond - last period", dirtyPriceExpected, dirtyPrice, TOLERANCE_PRICE);
View Full Code Here

  private static final CouponCMS CMS_COUPON_RECEIVER = (CouponCMS) CMS_COUPON_RECEIVER_DEFINITION.toDerivative(REFERENCE_DATE);

  @Test
  public void testGetter() {
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final ZonedDateTime zonedDate = ZonedDateTime.of(LocalDateTime.of(REFERENCE_DATE.toLocalDate(), LocalTime.MIDNIGHT), ZoneOffset.UTC);
    final double fixingTime = actAct.getDayCountFraction(zonedDate, FIXING_DATE);
    assertEquals(fixingTime, CMS_COUPON_RECEIVER.getFixingTime(), 1E-10);
    assertEquals(SWAP, CMS_COUPON_RECEIVER.getUnderlyingSwap());
    assertEquals(NOTIONAL, CMS_COUPON_RECEIVER.getNotional(), 1E-10);
  }
View Full Code Here

    for (int i = 0; i < _numberOfCashInstruments; i++) {

      // TODO : Check if rate <= 0

      final ZonedDateTime startDate = _baseDate;
      final ZonedDateTime endDate = _cashDates[i];

      final double rateYF = TimeCalculator.getTimeBetween(startDate, endDate, ACT_360);

      // TODO : Check denom != 0
      final double denom = 1.0 + _cashRates[i] * rateYF;

      zcCashDiscount[i] = 1.0 / denom;

      final double rateYF2 = TimeCalculator.getTimeBetween(startDate, endDate, ACT_365);

      zcCashRates[i] = Math.pow(zcCashDiscount[i], -1.0 / (_basis * rateYF2)) - 1.0;

      //_zCurveDates[i] = _cashDates[i];

      _zCurveRates[i] = _cashRates[i];
      _zCurveCCRates[i] = zcCashRates[i];

      _zCurveDates.add(_cashDates[i]);
      _zCurveContinuouslyCompoundedRates.add(_zCurveCCRates[i]);
      _zCurveDiscountFactors.add(zcCashDiscount[i]);
    }

    final ZonedDateTime lastMMDate = _cashDates[_cashDates.length - 1];

    // ----------------------------------------------------------------------

    // Add the swap instruments

    // TODO : Check is numSwaps == 0

    // -----------------------------------

    // Compute the last stub date

    ZonedDateTime lastStubDate;

    if (_numberOfCashInstruments < 1) {
      lastStubDate = _baseDate;
    } else {
      lastStubDate = _cashDates[_numberOfCashInstruments - 1];
View Full Code Here

    final ZonedDateTime[] dl = JpmcdsZCGetSwapCouponDL(_baseDate, matDate, isEndStub);

    final ZonedDateTime[] cflDate = new ZonedDateTime[dl.length];
    final double[] cflAmount = new double[dl.length];

    ZonedDateTime prevDate = _baseDate;

    for (int i = 0; i < dl.length; i++) {

      // TODO : Need to sort out what day count conv is being used
      final double yearFraction = 0.5; //TimeCalculator.getTimeBetween(prevDate, dl[i], ACT_365);
      cflDate[i] = dl[i];
      cflAmount[i] = rate * yearFraction;
      prevDate = dl[i];
    }

    cflAmount[cflAmount.length - 1] += 1.0;

    // ---------------------

    // Adjust matDate
    final ZonedDateTime adjMatDate = modifiedFollowingBadDayConv.adjustDate(holidayCalendar, matDate);

    /* Add rate implied by cashflow list to the zeroCurve.
     */

    JpmcdsZCAddCashFlowList(cflDate, cflAmount, price, adjMatDate, lastMMDate);
View Full Code Here

    double sumNPV = 0.0;

    // TODO : cCheck if date == 0L and if there are no MM deposits already used to build the zc curve

    final ZonedDateTime lastZCDate = lastMMDate;

    // TODO : Check if date <= lastZCDate

    firstUncovered = cflDate.length - 1;
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.