Pregunta

Estoy recibiendo el siguiente error al intentar fijar el precio de un intercambio de 20x10 a partir de una curva de bootstrap. El error son lanzados en la última línea de la función ImpliedRate

  

SwapRatesServiceTests.ImpliedRate_ForTwenty_x_TenYearSwap_ReturnsRate:   System.ApplicationException: 2ª Etapa: Mango vacío no puede ser sin referencia

No tengo la menor idea de por dónde empezar a depurar este problema. Cualquier ayuda será muy apreciada.

IMPORTANTE: Estoy utilizando la versión C # trago de QuantLib, por lo que mi código prod real a medida que se sigue basa en el ejemplo swapvaluation.cpp:

El método de prueba:

    [Test]
    public void ImpliedRate_ForTwenty_x_TenYearSwap_ReturnsRate() 
    {
        //Arrange
        var startingDate = new Date(10,Month.October,2030); // starting date of 20x10yr swap
        var length= 10;
        repo.Setup(r => r.Read(It.IsAny<string>())).Returns(LoadSwapPoints()); // LoadSwapPoints returns IEnumerable<RateHelpers>

        //Act
        service.ConstructSwapPoints(SettlementDate);
        var instrumentRate = service.ImpliedRate(startingDate, length);

        //Assert
        Assert.That(instrumentRate, Is.Not.Null); // this must change to a value test

    }

Esto es parte del método ConstructSwapPoints más grande

        var depoFRASwapInstruments = PointVector; // RateHelperVector populated with RateHelpers
        DayCounter termStructureDayCounter = new ActualActual(ActualActual.Convention.Actual365);

        QuoteHandleVector quotes = new QuoteHandleVector();
        DateVector quoteDates = new DateVector();

        py = CreatePiecewiseLinearCurve(settlementDate, depoFRASwapInstruments, termStructureDayCounter, quotes, quoteDates);
        DiscountingTermStructure = new RelinkableYieldTermStructureHandle(py); //RelinkableYieldTermStructureHandle
        //DiscountingTermStructure.linkTo(py); // alternate way

        PricingEngine = new DiscountingSwapEngine(DiscountingTermStructure); // DiscountingSwapEngine           

Con el método ImpliedRate como sigue (i he snipped algunas partes debido a restricciones de IP);

    public double ImpliedRate(Date startingDate, int length)
    {

        var swapMaturityDate = startingDate.Add(new Period(length, TimeUnit.Years));
        var curveMaturityDate = py.maxDate();

        Schedule fixedSchedule = new Schedule(startingDate, swapMaturityDate, new Period(Frequency.Quarterly), SouthAfricanCalender, Convention, Convention, DateGeneration.Rule.Forward, false);
        Schedule floatSchedule = new Schedule(startingDate, swapMaturityDate, new Period(Frequency.Quarterly), SouthAfricanCalender, Convention, Convention, DateGeneration.Rule.Forward, false);

        VanillaSwap impliedSwap = new VanillaSwap(
            _VanillaSwap.Type.Payer, 
            10000000.0, 
            fixedSchedule, 
            0.1, 
            Actual365FixedDayCounter, 
            floatSchedule, 
            new Jibar(new Period(Frequency.Quarterly)), 
            0, 
            Actual365FixedDayCounter);

        impliedSwap.setPricingEngine(PricingEngine);

        return impliedSwap.fairRate(); // <---exception thrown here
    }

Espero que mi terminología es correcta en el argot financiero es todavía nuevo para mí.

Edit: He añadido la etiqueta C ++, ya que la figura está realmente relacionado con algo de código subyacente C ++. Con la esperanza de que esta exposición puede revelar algunas ideas sobre lo que puede estar ocurriendo aquí.

scroll top