Examples of VarianceSwap


Examples of com.opengamma.analytics.financial.varianceswap.VarianceSwap

    final double[] observations = realizedTS.valuesArrayFast();
    final double[] observationWeights = {}; // TODO Case 2011-06-29 Calendar Add functionality for non-trivial weighting of observations
    final int nGoodBusinessDays = countExpectedGoodDays(_obsStartDate.toLocalDate(), valueDate.toLocalDate(), _calendar, _obsFreq);
    final int nObsDisrupted = nGoodBusinessDays - observations.length;
    ArgumentChecker.isTrue(nObsDisrupted >= 0, "Have more observations {} than good business days {}", observations.length, nGoodBusinessDays);
    return new VarianceSwap(timeToObsStart, timeToObsEnd, timeToSettlement, _varStrike, _varNotional, _currency, _annualizationFactor, _nObsExpected, nObsDisrupted,
        observations, observationWeights);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.varianceswap.VarianceSwap

  @Test
  public void testBlackVegaParallel() {

    final double expiry = 0.5;
    final double sigma = SURFACE.getZValue(expiry, 100.0);
    final VarianceSwap swap = new VarianceSwap(tPlusOne, expiry, expiry, varStrike, varNotional, Currency.EUR, annualization, nObsExpected, noObsDisrupted, noObservations, noObsWeights);
    final double zcb = MARKET.getDiscountCurve().getDiscountFactor(swap.getTimeToSettlement());

    final Double vegaParallel = DELTA_CAL.calcBlackVegaParallel(swap, MARKET);
    final double theoreticalVega = 2 * sigma * zcb * swap.getVarNotional();

    assertEquals(theoreticalVega, vegaParallel, 0.01);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.varianceswap.VarianceSwap

   * Variance is additive, hence a forward starting VarianceSwap may be decomposed into the difference of two spot starting ones.
   */
  public void swapForwardStarting() {

    // First, create a swap which starts in 1 year and observes for a further four
    final VarianceSwap swapForwardStarting1to5 = new VarianceSwap(expiry1, expiry5, expiry5, varStrike, varNotional, Currency.EUR, annualization, nObsExpected, noObsDisrupted, singleObsSoNoReturn,
        noObsWeights);

    final double pvFowardStart = PRICER.presentValue(swapForwardStarting1to5, MARKET);

    // Second, create two spot starting swaps. One that expires at the end of observations, one expiring at the beginnning
    final VarianceSwap swapSpotStarting1 = new VarianceSwap(now, expiry1, expiry5, varStrike, varNotional, Currency.EUR, annualization, nObsExpected, noObsDisrupted, singleObsSoNoReturn, noObsWeights);
    final VarianceSwap swapSpotStarting5 = new VarianceSwap(now, expiry5, expiry5, varStrike, varNotional, Currency.EUR, annualization, nObsExpected, noObsDisrupted, singleObsSoNoReturn, noObsWeights);

    final double pvSpot1 = PRICER.presentValue(swapSpotStarting1, MARKET);
    final double pvSpot5 = PRICER.presentValue(swapSpotStarting5, MARKET);

    final double pvDiffOfTwoSpotStarts = (5.0 * pvSpot5 - 1.0 * pvSpot1) / 4.0;
View Full Code Here

Examples of com.opengamma.analytics.financial.varianceswap.VarianceSwap

  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void onFirstObsWithoutObs() {

    final VarianceSwap swapOnFirstObsWithoutObs = new VarianceSwap(now, expiry5, expiry5, varStrike, varNotional, Currency.EUR, annualization, nObsExpected, noObsDisrupted, noObservations,
        noObsWeights);
    @SuppressWarnings("unused")
    final double pv = PRICER.presentValue(swapOnFirstObsWithoutObs, MARKET);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.varianceswap.VarianceSwap

  @Test
  /**
   * After lastObs but before settlement date, presentValue == RealizedVar
   */
  public void swapObservationsCompleted() {
    final VarianceSwap swapPaysTomorrow = new VarianceSwap(-1., -tPlusOne, tPlusOne, varStrike, varNotional, Currency.EUR, annualization, nObs - 1, 0, obs, obsWeight);

    final double pv = PRICER.presentValue(swapPaysTomorrow, MARKET);
    final double variance = new RealizedVariance().evaluate(swapPaysTomorrow);
    final double pvOfHedge = swapStartsNow.getVarNotional() * (variance - swapStartsNow.getVarStrike()) * MARKET.getDiscountCurve().getDiscountFactor(tPlusOne);
    assertEquals(pvOfHedge, pv, 0.01);
View Full Code Here

Examples of com.opengamma.analytics.financial.varianceswap.VarianceSwap

  @Test
  /**
   * After settlement, presentValue == 0.0
   */
  public void swapAfterSettlement() {
    final VarianceSwap swapEnded = new VarianceSwap(-1.0, -1.0 / 365, -1.0 / 365, varStrike, varNotional, Currency.EUR, annualization, nObs, 0, obs, obsWeight);
    final double pv = PRICER.presentValue(swapEnded, MARKET);
    assertEquals(0.0, pv, TOLERATED);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.varianceswap.VarianceSwap

    final Clock snapshotClock = executionContext.getValuationClock();
    final ZonedDateTime now = ZonedDateTime.now(snapshotClock).minusYears(2); //TODO remove me - just for testing

    final VarianceSwapDefinition defn = security.accept(_converter);
    final HistoricalTimeSeries timeSeries = (HistoricalTimeSeries) inputs.getValue(ValueRequirementNames.HISTORICAL_TIME_SERIES);
    final VarianceSwap deriv = defn.toDerivative(now, timeSeries.getTimeSeries());

    // 2. Build up the market data bundle
    final Object volSurfaceObject = inputs.getValue(getVolatilitySurfaceRequirement(security, surfaceName));
    if (volSurfaceObject == null) {
      throw new OpenGammaRuntimeException("Could not get Volatility Surface");
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.