Package org.threeten.bp

Examples of org.threeten.bp.Period


    final LocalDate now = ZonedDateTime.now(snapshotClock).toLocalDate();
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final Set<String> samplingPeriodName = desiredValue.getConstraints().getValues(ValuePropertyNames.SAMPLING_PERIOD);
    final Set<String> scheduleCalculatorName = desiredValue.getConstraints().getValues(ValuePropertyNames.SCHEDULE_CALCULATOR);
    final Set<String> samplingFunctionName = desiredValue.getConstraints().getValues(ValuePropertyNames.SAMPLING_FUNCTION);
    final Period samplingPeriod = getSamplingPeriod(samplingPeriodName);
    final LocalDate startDate = now.minus(samplingPeriod);
    final Currency payCurrency = security.getNumerator();
    final Currency receiveCurrency = security.getDenominator();
    final HistoricalTimeSeries dbTimeSeries = (HistoricalTimeSeries) inputs.getValue(ValueRequirementNames.HISTORICAL_TIME_SERIES);
    if (dbTimeSeries == null) {
View Full Code Here


          }
        });*/

          ZonedDateTime start = cds.getStartDate();
          ZonedDateTime maturity = cds.getMaturityDate();
          Period period = Period.between(start.toLocalDate(), maturity.toLocalDate());
          Tenor tenor = Tenor.of(period);


          final CurveNodeIdMapper curveNodeIdMapper = configSource.getSingle(CurveNodeIdMapper.class,
                                                                             curveDefinitionID,
View Full Code Here

      final Currency putCurrency = security.accept(ForexVisitors.getPutCurrencyVisitor());
      final Currency callCurrency = security.accept(ForexVisitors.getCallCurrencyVisitor());
      final UnorderedCurrencyPair currencyPair = UnorderedCurrencyPair.of(putCurrency, callCurrency);
      final VolatilitySurfaceDefinition<Object, Object> definition = getSurfaceDefinition(currencyPair, surfaceName, definitionSource);
      final VolatilitySurfaceSpecification specification = getSurfaceSpecification(currencyPair, surfaceName, specificationSource);
      final Period samplingPeriod = getSamplingPeriod(desiredValue.getConstraint(ValuePropertyNames.SAMPLING_PERIOD));
      final LocalDate startDate = now.minus(samplingPeriod);
      final String scheduleCalculatorName = desiredValue.getConstraint(ValuePropertyNames.SCHEDULE_CALCULATOR);
      final Schedule scheduleCalculator = getScheduleCalculator(scheduleCalculatorName);
      final String samplingFunctionName = desiredValue.getConstraint(ValuePropertyNames.SAMPLING_FUNCTION);
      final TimeSeriesSamplingFunction samplingFunction = getSamplingFunction(samplingFunctionName);
View Full Code Here

  public void performanceBuildPV() {
    final int nbSwap = 2500;
    long startTime, endTime;
    final double strikeMin = 0.01;
    final double strikeMax = 0.02;
    final Period tenor = Period.ofYears(10);
    final SwapFixedIborSpreadDefinition[] swapDefinition = new SwapFixedIborSpreadDefinition[nbSwap + 1];
    final double[] pv = new double[nbSwap + 1];

    startTime = System.currentTimeMillis();
    for (int loopswap = 0; loopswap <= nbSwap; loopswap++) {
View Full Code Here

    final CurveNodeVisitor<InstrumentDefinition<?>> converter = new SwapNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
    Tenor legTenor = Tenor.TEN_YEARS;
    SwapNode swapNode = new SwapNode(Tenor.of(Period.ZERO), legTenor, SWAP_3M_IBOR_ID, LIBOR_1M_CMP_3M_ID, "Mapper");
    InstrumentDefinition<?> definition = swapNode.accept(converter);
    assertTrue(definition instanceof SwapDefinition);
    final Period paymentPeriod = Period.ofMonths(3);
    final Period compositionPeriod = Period.ofMonths(1);
    final IborIndex index3m = new IborIndex(Currency.USD, paymentPeriod, 2, THIRTY_360, MODIFIED_FOLLOWING, false, LIBOR_3M_ID.getValue()); // Not correct conventions. Only for testing.
    final IborIndex index1m = new IborIndex(Currency.USD, compositionPeriod, 2, THIRTY_360, MODIFIED_FOLLOWING, false, LIBOR_1M_ID.getValue());
    AnnuityCouponIborDefinition payLeg = AnnuityCouponIborDefinition.from(settlementDate, legTenor.getPeriod(), 1, index3m, true, CALENDAR);
    final AnnuityDefinition<CouponIborCompoundingSpreadDefinition> receiveLeg = AnnuityDefinitionBuilder.annuityIborCompoundingSpreadFrom(settlementDate, settlementDate.plus(legTenor.getPeriod()), paymentPeriod, 1, spread,
        index1m, StubType.SHORT_START, false, MODIFIED_FOLLOWING, true, CALENDAR, StubType.SHORT_START);
View Full Code Here

    final InstrumentDefinition<?> definition = futureNode.accept(converter);
    final Currency currency = Currency.USD;
    final DayCount dayCount = THIRTY_360;
    final BusinessDayConvention businessDayConvention = MODIFIED_FOLLOWING;
    final boolean eom = false;
    final Period indexTenor = Period.ofMonths(3);
    final int spotLagIndex = 2;
    final IborIndex iborIndex = new IborIndex(currency, indexTenor, spotLagIndex, dayCount, businessDayConvention, eom, "USD 3m Libor");
    final GeneratorSwapFixedIbor generator = new GeneratorSwapFixedIbor("", Period.ofMonths(6), ACT_360, iborIndex, CALENDAR);
    final SwapFixedIborDefinition underlying = SwapFixedIborDefinition.from(DateUtils.getUTCDate(2013, 6, 19), Period.ofYears(10), generator, 1, rate, false);
    final SwapFuturesPriceDeliverableSecurityDefinition securityDefinition = new SwapFuturesPriceDeliverableSecurityDefinition(DateUtils.getUTCDate(2013, 6, 17), underlying, 1);
View Full Code Here

        throw new UnsupportedOperationException("Can only handle 10 and 25 delta quotes");
      }
    } else {
      throw new UnsupportedOperationException("Can only handle ATM, risk reversal and butterfly quotes");
    }
    final Period period = tenor.getPeriod();
    if (period.getMonths() != 0) {
      bbgCode.append(period.getMonths());
      bbgCode.append('M');
    } else if (period.getYears() != 0) {
      bbgCode.append(period.getYears());
      if (period.getYears() < 10) {
        bbgCode.append(period.getYears());
        bbgCode.append('Y');
      }
    } else if (period.getDays() != 0 && period.getDays() % 7 == 0) {
      bbgCode.append(period.getDays() / 7);
      bbgCode.append('W');
    } else {
      throw new UnsupportedOperationException("Can only handle periods in weeks, months or years");
    }
    ticker.append(bbgCode);
View Full Code Here

  public void forwardPointsInterpolation() {
    final MulticurveProviderDiscount multicurves = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(0).getFirst();
    // FX swap description
    final double notionalEUR = 1E8; //100m
    final double fxEURUSDFwdInit = FX_EURUSD + 0.0010; // Should have no impact
    final Period startTenor = Period.ofMonths(0);
    final Period endTenor = Period.ofMonths(12);
    final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(NOW, USDLIBOR3M.getSpotLag(), TARGET);
    final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spot, startTenor, USDLIBOR3M, NYC);
    final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(spot, endTenor, USDLIBOR3M, NYC);
    final double[] points = DSC_EUR_MARKET_QUOTES;
    final double[] time = ((InterpolatedDoublesCurve) ((YieldCurve) multicurves.getCurve(EUR)).getCurve()).getXDataAsPrimitive();
View Full Code Here

    final ZonedDateTime endDate = capFloorSecurity.getMaturityDate();
    final double notional = capFloorSecurity.getNotional();
    final Currency currency = capFloorSecurity.getCurrency();
    final Frequency payFreq = capFloorSecurity.getFrequency();
    // FIXME: convert frequency to period in a better way
    final Period tenorPayment = getTenor(payFreq);
    final boolean isIbor = capFloorSecurity.isIbor();
    final ConventionBundle iborIndexConvention;
    final ExternalId regionId;
    if (isIbor) { // Cap/floor on Ibor
      iborIndexConvention = _conventionSource.getConventionBundle(capFloorSecurity.getUnderlyingId());
      if (iborIndexConvention == null) {
        throw new OpenGammaRuntimeException("Could not get ibor index convention for " + capFloorSecurity.getUnderlyingId());
      }
      regionId = iborIndexConvention.getRegion();
      final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, regionId);
      final IborIndex index = new IborIndex(currency, iborIndexConvention.getPeriod(), iborIndexConvention.getSettlementDays(), iborIndexConvention.getDayCount(),
          iborIndexConvention.getBusinessDayConvention(), iborIndexConvention.isEOMConvention(), "Ibor");
      return AnnuityCapFloorIborDefinition.from(startDate, endDate, notional, index, capFloorSecurity.getDayCount(), tenorPayment, capFloorSecurity.isPayer(), capFloorSecurity.getStrike(),
          capFloorSecurity.isCap(), calendar);
    }
    // Cap/floor on CMS
    final ConventionBundle swapIndexConvention = _conventionSource.getConventionBundle(capFloorSecurity.getUnderlyingId());
    if (swapIndexConvention == null) {
      throw new OpenGammaRuntimeException("Could not get swap index convention for " + capFloorSecurity.getUnderlyingId().toString());
    }
    iborIndexConvention = _conventionSource.getConventionBundle(swapIndexConvention.getSwapFloatingLegInitialRate());
    if (iborIndexConvention == null) {
      throw new OpenGammaRuntimeException("Could not get ibor index convention for " + swapIndexConvention.getSwapFloatingLegInitialRate());
    }
    regionId = swapIndexConvention.getSwapFloatingLegRegion();
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, regionId);
    final IborIndex iborIndex = new IborIndex(currency, tenorPayment, iborIndexConvention.getSettlementDays(), iborIndexConvention.getDayCount(),
        iborIndexConvention.getBusinessDayConvention(), iborIndexConvention.isEOMConvention());
    final Period fixedLegPaymentPeriod = getTenor(swapIndexConvention.getSwapFixedLegFrequency());
    final IndexSwap swapIndex = new IndexSwap(fixedLegPaymentPeriod, swapIndexConvention.getSwapFixedLegDayCount(), iborIndex, swapIndexConvention.getPeriod(), calendar);
    return AnnuityCapFloorCMSDefinition.from(startDate, endDate, notional, swapIndex, tenorPayment, capFloorSecurity.getDayCount(), capFloorSecurity.isPayer(), capFloorSecurity.getStrike(),
        capFloorSecurity.isCap(), calendar);
  }
View Full Code Here

    return AnnuityCapFloorCMSDefinition.from(startDate, endDate, notional, swapIndex, tenorPayment, capFloorSecurity.getDayCount(), capFloorSecurity.isPayer(), capFloorSecurity.getStrike(),
        capFloorSecurity.isCap(), calendar);
  }

  private static Period getTenor(final Frequency freq) {
    Period tenor;
    if (Frequency.ANNUAL_NAME.equals(freq.getConventionName())) {
      tenor = Period.ofMonths(12);
    } else if (Frequency.SEMI_ANNUAL_NAME.equals(freq.getConventionName())) {
      tenor = Period.ofMonths(6);
    } else if (Frequency.QUARTERLY_NAME.equals(freq.getConventionName())) {
View Full Code Here

TOP

Related Classes of org.threeten.bp.Period

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.