尝试使用Quantlib时定价仪器时出错

问题描述:

尝试从自举曲线定价20x10交换时,出现以下错误。错误坐上ImpliedRate函数的最后一行抛出尝试使用Quantlib时定价仪器时出错

SwapRatesServiceTests.ImpliedRate_ForTwenty_x_TenYearSwap_ReturnsRate: System.ApplicationException:2腿:空手柄无法提领

我没有最微弱的想法哪里开始调试这个问题。任何援助将不胜感激。

重要提示:我使用Quantlib的C#痛饮版本,所以我的实际督促代码如下基础上swapvaluation.cpp例如:

测试方法:

[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 

    } 

这是部分较大ConstructSwapPoints方法

 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   

随着ImpliedRate方法如下的(我已经剪断了一些零件出由于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 
    } 

我希望我的术语是正确的,因为财务术语对我来说还是新的。

编辑:我已经添加了C++标记,因为我的图形实际上与一些底层C++代码有关。希望这种曝光可能揭示一些可能在这里发生的事情。

+0

我还通过电子邮件发送quantlib用户群,所以我将与任何相关反馈更新接收。 – Ahmad 2010-10-25 09:29:36

基于从Quantlib mailing list

反馈Jibar索引需要有创造无风险曲线的参考。如果没有期限结构,Jibar可以回到过去的定价,但不会预测未来的定价。该Jibar构造需要更换与

new Jibar(new Period(Frequency.Quarterly), DiscountingTermStructure) 

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