Package com.opengamma.financial.security.bond

Examples of com.opengamma.financial.security.bond.BondSecurity.accept()


  public BondFixedTransactionDefinition convert(final Trade trade) {
    Validate.notNull(trade, "trade");
    Validate.isTrue(trade.getSecurity() instanceof BondSecurity, "Can only handle trades with security type BondSecurity");
    final BondSecurity security = (BondSecurity) trade.getSecurity();
    final InstrumentDefinition<?> underlying = security.accept(_securityConverter);
    if (!(underlying instanceof BondFixedSecurityDefinition)) {
      throw new OpenGammaRuntimeException("Can only handle fixed coupon bonds");
    }
    final BondFixedSecurityDefinition bond = (BondFixedSecurityDefinition) underlying;
    final int quantity = trade.getQuantity().intValue(); // MH - 9-May-2013: changed from 1. // REVIEW: The quantity mechanism should be reviewed.
View Full Code Here


      final BondFutureDeliverable deliverable = basket.get(i);
      final BondSecurity bondSecurity = (BondSecurity) _securitySource.getSingle(deliverable.getIdentifiers());
      if (bondSecurity == null) {
        throw new OpenGammaRuntimeException("No security found with identifiers " + deliverable.getIdentifiers() + " in bond future deliverable basket");
      }
      deliverables[i] = (BondFixedSecurityDefinition) bondSecurity.accept(_bondConverter);
      conversionFactor[i] = deliverable.getConversionFactor();
    }
    return new BondFutureDefinition(tradingLastDate, noticeFirstDate, noticeLastDate, notional, deliverables, conversionFactor);
  }
}
View Full Code Here

    BondSecurity bond = (BondSecurity) target.getSecurity();
    final HolidaySource holidaySource = OpenGammaExecutionContext.getHolidaySource(context);
    final ConventionBundleSource conventionSource = OpenGammaExecutionContext.getConventionBundleSource(context);
    final RegionSource regionSource = OpenGammaExecutionContext.getRegionSource(context);
    BondSecurityConverter visitor = new BondSecurityConverter(holidaySource, conventionSource, regionSource);
    final BondFixedSecurityDefinition definition = (BondFixedSecurityDefinition) bond.accept(visitor);
    BondFixedSecurity derivative = definition.toDerivative(date, riskFreeCurveName, creditCurveName);
    return CALCULATOR.zSpreadFromCurvesAndClean(derivative, data, price);
  }

}
View Full Code Here

    final HolidaySource holidaySource = OpenGammaExecutionContext.getHolidaySource(executionContext);
    final ConventionBundleSource conventionSource = OpenGammaExecutionContext
        .getConventionBundleSource(executionContext);
    final RegionSource regionSource = OpenGammaExecutionContext.getRegionSource(executionContext);
    final BondSecurityConverter visitor = new BondSecurityConverter(holidaySource, conventionSource, regionSource);
    BondFixedSecurity bond = ((BondFixedSecurityDefinition) security.accept(visitor)).toDerivative(now, curveName);
    final YieldCurveBundle bundle;
    final YieldAndDiscountCurve curve = (YieldAndDiscountCurve) curveObject;
    bundle = new YieldCurveBundle(new String[] {curveName}, new YieldAndDiscountCurve[] {curve});
    double pv = PV01_CALCULATOR.visit(bond, bundle).get(curveName);
    final ValueSpecification specification = new ValueSpecification(ValueRequirementNames.PV01, target.toSpecification(),
View Full Code Here

    }
    final Double cleanPrice = (Double) cleanPriceObject;
    final String creditCurveName = riskFreeCurveName;
    final ValueProperties.Builder properties = getResultProperties(riskFreeCurveName, creditCurveName, curveName);
    final ValueSpecification resultSpec = new ValueSpecification(ValueRequirementNames.PRESENT_VALUE_Z_SPREAD_SENSITIVITY, target.toSpecification(), properties.get());
    final BondFixedSecurityDefinition definition = (BondFixedSecurityDefinition) security.accept(_visitor);
    final BondFixedSecurity bond = definition.toDerivative(date, curveName, riskFreeCurveName);
    final YieldAndDiscountCurve curve = (YieldAndDiscountCurve) curveObject;
    final YieldAndDiscountCurve riskFreeCurve = (YieldAndDiscountCurve) riskFreeCurveObject;
    final YieldCurveBundle data = new YieldCurveBundle(new String[] {curveName, riskFreeCurveName}, new YieldAndDiscountCurve[] {curve, riskFreeCurve});
    return Sets.newHashSet(new ComputedValue(resultSpec, CALCULATOR.presentValueZSpreadSensitivityFromCurvesAndClean(bond, data, cleanPrice)));
View Full Code Here

    final HolidaySource holidaySource = OpenGammaExecutionContext.getHolidaySource(executionContext);
    final ConventionBundleSource conventionSource = OpenGammaExecutionContext
        .getConventionBundleSource(executionContext);
    final RegionSource regionSource = OpenGammaExecutionContext.getRegionSource(executionContext);
    final BondSecurityConverter visitor = new BondSecurityConverter(holidaySource, conventionSource, regionSource);
    final BondFixedSecurityDefinition bond = (BondFixedSecurityDefinition) security.accept(visitor);
    final ZonedDateTime firstCouponDate = bond.getCoupons().getNthPayment(0).getAccrualStartDate();
    final ZonedDateTime lastCouponDate = bond.getCoupons().getNthPayment(bond.getCoupons().getNumberOfPayments() - 1).getPaymentDate();
    final int t = DateUtils.getDaysBetween(firstCouponDate, lastCouponDate) / 365;
    final ValueSpecification specification = new ValueSpecification(ValueRequirementNames.BOND_TENOR, target.toSpecification(), createValueProperties().get());
    return Collections.singleton(new ComputedValue(specification, t));
View Full Code Here

            throw new IllegalArgumentException("YTM should be a double");
          }
          final InstrumentDefinition<?> definition = converter.visitGovernmentBondSecurity(bondSec);
          final String bondStringName = PROPERTY_PREFIX + "_" + CURRENCY.getCode();
          final InstrumentDerivative bond = definition.toDerivative(now, bondStringName);
          t[i] = bond.accept(LAST_DATE);
          ytm[i++] = ((Double) ytmObject / 100);
        }
        final DoubleMatrix1D initialValues = new DoubleMatrix1D(new double[] {1, 2, 3, 4, 2, 3 });
        final ParameterizedFunction<Double, DoubleMatrix1D, Double> parameterizedFunction = MODEL.getParameterizedFunction();
        final LeastSquareResults result = MINIMISER.solve(new DoubleMatrix1D(t), new DoubleMatrix1D(ytm), parameterizedFunction, initialValues);
View Full Code Here

  }

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final BondSecurity security = (BondSecurity) target.getSecurity();
    final BondFixedSecurityDefinition bond = (BondFixedSecurityDefinition) security.accept(_visitor);
    final AnnuityCouponFixedDefinition coupons = bond.getCoupons();
    final int n = coupons.getNumberOfPayments();
    final LocalDate[] dates = new LocalDate[n];
    final double[] payments = new double[n];
    for (int i = 0; i < n; i++) {
View Full Code Here

    BondSecurity security = (BondSecurity) target.getSecurity();
    final HolidaySource holidaySource = OpenGammaExecutionContext.getHolidaySource(context);
    final ConventionBundleSource conventionSource = OpenGammaExecutionContext.getConventionBundleSource(context);
    final RegionSource regionSource = OpenGammaExecutionContext.getRegionSource(context);
    BondSecurityConverter visitor = new BondSecurityConverter(holidaySource, conventionSource, regionSource);
    final BondFixedSecurityDefinition definition = (BondFixedSecurityDefinition) security.accept(visitor);
    BondFixedSecurity derivative = definition.toDerivative(date, riskFreeCurveName, creditCurveName);
    return CALCULATOR.zSpreadFromCurvesAndClean(derivative, data, price);
  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.