IndexOutOfRangeException in PiecewiseFlatForward

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

IndexOutOfRangeException in PiecewiseFlatForward

Richard Howes-2

Hi,

 

I am new to QuantLib.

 

I have installed QuantLib.net on my WindowsXP machine.

 

I am getting an exception when I run the last line of the following C# code:

 

            static void Main(string[] args)

            {

                  IBusinessCalendar calendar = TARGET.Instance;

                  DateTime todaysDate = new DateTime(2001, 11, 1);

                  DateTime settlementDate = new DateTime(2001, 11, 3);

                 

                  // deposits

                  double d1wQuote=0.0382;

                  double d1mQuote=0.0372;

                  double d3mQuote=0.0363;

 

                  /*********************

                   ***  RATE HELPERS ***

                   *********************/

                  Actual360 depositDayCounter = Actual360.Instance;

                  int settlementDays = 2;

 

DepositRateHelper d1w = new DepositRateHelper(d1wQuote,1,                                                                          TimeUnit.Weeks,settlementDays, calendar, RollingConvention.ModifiedFollowing, depositDayCounter);

 

DepositRateHelper d1m = new DepositRateHelper(d1mQuote,1, TimeUnit.Months,settlementDays, calendar, RollingConvention.ModifiedFollowing, depositDayCounter);

 

DepositRateHelper d3m = new DepositRateHelper(d3mQuote,3, TimeUnit.Months,settlementDays, calendar, RollingConvention.ModifiedFollowing, depositDayCounter);

                                   

RateHelper[] depos = new RateHelper[3] {d1w, d1m, d3m};

                                   

TermStructure depoTermStruc = new (PiecewiseFlatForward(todaysDate, settlementDate,

                        depos,depositDayCounter,.0001);

                 

Console.WriteLine(depoTermStruc.Discount(30,true));

            }

 

When I inspect the objects during a debugging session I notice that the MaxTime and MaxDate fields of the TermStructure which I have created in the second-last line have System.IndexOutOfRangeException as a value.

 

Separately, are there any examples of QuantLib.net implementation as there are for regular QuantLib.

 

Thankyou in advance for your assistance,

 

Kind Regards,

Richard Howes